This first guide will walk you through a step-by-step installation of the required tools to start developing applications on Bitxor.
We will be using the test network, which uses the same technology and features of the main network. The testnet allows developers to experiment with the offered Bitxor’s transaction set in a live network without the loss of valuable assets.
An account is a deposit box where you can hold tokens (tokens) and interact with them by announcing transactions.
We are creating a new account with the Bitxor CLI, a command-line tool designed to architect solutions and interact with Bitxor networks in an efficient manner.
Bitxor CLI requires Node.js 12 LTS to execute. Open a new terminal and check the version installed with:
node --version
If you get an error or the version returned does not match v12.X, visit nodejs.org to install the requirement (Although it is recommended to install through nvm).
To install Bitxor CLI, run the next command.
npm install --global bitxor-cli
Then, generate a new account and save it as a profile.
bitxor-cli account generate
Enter network type (MAIN_NET, TEST_NET): TEST_NET
Do you want to save the account? [y/n]: y
Select an import type: » PrivateKey
Enter Bitxor Node URL. (Example: http://localhost:3000): <NODE_URL>
Insert the profile name: testnet
Do you want to set the account as the default profile? [y/n]: y
If everything goes well, you should see the account credentials displayed in the terminal.
Profile stored correctly
┌─────────────┬──────────────────────────────────────────────────────────────┐
│ Property │ Value │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ Address │ BXRYXK-VYBMO4-NBCUF3-AXKJMX-CGVSYQ-OS7ZG2-TLI │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ Public Key │ 203...C0A │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ Private Key │ AAA...AAA │
└─────────────┴──────────────────────────────────────────────────────────────┘
Note
Make sure to keep the private key secret and backed up safely somewhere offline.
If you get the error The CLI cannot reach the node
, the most common causes are:
Incorrect node URL: The URL used does not belong to an active node. Open the URL provided in a new browser tab and check if you get a response. If the test network node is not working, you can use another node url from this list or run your own testnet node by following the next guide.
Internet connection: The CLI resolves some values from the node. If you decide to use the tool without being connected to the internet, you will have to pass the options --network
, --generation-hash
, --namespace-id
, and divisibility
. Type bitxor-cli account generate --help
to know more about each parameter.
To announce a transaction, the sender should pay a fee to provide an incentive to those who validate and secure the network and run the infrastructure.
This cost is paid in bitxor
tokens, the default network currency of the public network.
Now that you have created your first account, let’s request bitxor
units from the testnet faucet.
Navigate here, indicate the amount of bitxor
you want to receive and the address, and click “CLAIM!”.
After the transaction gets confirmed, check if your account has received bitxor
using the command-line tool.
bitxor-cli account info --profile testnet
Balance Information
┌──────────────────┬─────────────────┬─────────────────┬───────────────────┐
│ Token Id │ Relative Amount │ Absolute Amount │ Expiration Height │
├──────────────────┼─────────────────┼─────────────────┼───────────────────┤
│ 5E62990DCAC5BE8A │ 750.0 │ 750000000 | Never │
└──────────────────┴─────────────────┴─────────────────┴───────────────────┘
Note
The faucet has a limited amount of bitxor
and must be replenished before it dries out. If you don’t need your test bitxor
units anymore, please send them back to the account indicated in the faucet’s page.
Now that you have your account filled with bitxor
units, it is time to choose a programming language.
Pick the one you feel most comfortable with, or follow your project requirements.
Then, create a folder for your new project and run the instructions for the selected language. If none of the languages fits your project, you can always query the blockchain directly using the REST gateway.
Note
Bitxor SDK requires Node.js 12 LTS to execute.
Create a package.json
file.
npm init
Install Bitxor SDK and RxJS library.
npm install bitxor-sdk rxjs
Install globally TypeScript dependency:
npm install --global typescript
typescript --version
Install ts-node to execute TypeScript files with node.
sudo npm install --global ts-node
Note
Bitxor SDK requires Node.js 12 LTS to execute.
Create a package.json
file.
npm init
Install Bitxor SDK and RxJS library.
npm install bitxor-sdk rxjs
Note
Bitxor SDK requires JDK 8 to execute.
Open a new Java gradle project. Use your favourite IDE or create a project from the command line.
gradle init --type java-application
Edit build.gradle
to use Maven central repository.
repositories {
mavenCentral()
}
Add bitxor-sdk
as a dependency.
dependencies {
compile "io.nem:bitxor-sdk-vertx-client"
}
Execute gradle build
and gradle run
to run your program.