Devnet: Running Latest Development Node
Caution
This page is for building and running the latest development version of the chain for testing purposes only. The development branch is under active development and is highly unstable and subject to breaking changes. You should expect a moderate amount of troubleshooting work to be required. For anyone interested in joining the Cronos POS Chain testnet, please refer to our testnet documentation.
By following this tutorial, you can compile and run the latest development version of Cronos POS Chain from scratch. It is intended for testing purposes only.
Overview
We will be using pystarport, a dedicated script similar to cosmos starport without the scaffolding feature to build a local development network with multiple validators.
Install with Nix
Install nix
Follow official instructions: https://nixos.org/download.html
Use binary cache
If you are using Linux, enable the cachix binary cache:
Install pystarport
Install the binded version, which install chain-maind together, and find it by the absolute path:
Install the unbinded version of pystarport, which find whatever version of chain-maind it finds in PATH
:
Install pystarport manually
Pre-requisites
Python > 3.7.3
To install pystarport manually, run:
Customize your devnet
Jump to the next section to start it without customization.
You can customize your devnet based on examples/devnet.yaml
:
This configuration will give us 2 validators devnet with the chain-id chainmaind
; 4 accounts under the name of community
, ecosystem
reserve
and launch
with some allocated funds at the genesis.
You can also specify some network parameters in the genesis file of your devnet under genesis:
for different testing purposes. As in the above example, we have specified the unbonding_time
to be 10
seconds.
Start the devnet
Once we finish with the configuration, we are ready to start the chain: in the repository root directory, run
Afterward, keys will be generated according to the configuration specified, and the accounts' information will be generated in data/chainmaind/accounts.json
, for example:
Kindly save these mnemonics for key recovery later.
Blocks are now being generated! You can view the blockchain data by the RPC port of the awesome0
(first node): http://localhost:26657/. Furthermore, you can also use the swagger doc of awesome0
at http://localhost:26654/swagger/.
It is worth mentioning that the serve
command would truncate all the blocks previously generated and regenerate a new Genesis block, which means you'll also lose all of your transaction records. If you wish to restart the chain with the existing blocks, please run pystarport
with start
command:
Interact with the chain
After the chain has been started, we may open up another terminal and start interacting with the chain by chain-maind
.
Keys management
Restore the key
As in the last section, pre-created Hierarchical Deterministic (HD) mnemonic with genesis funds inside are prepared for you in the Devnet. To gain access to the funds, kindly restore the key by using the mnemonic before moving on to the next step.
Note: The keys are stored in your operating system by default, we will use --keyring-backend test
for simplicity. You may refer to a more detailed explanation here.
Firstly, restore the key name as
launch
:Now you can check the balance of it by running
We can see that there is
20000000000
basecro (=200
cro) in this address as expected.
Transfer CRO to another address
Once we have a restore the key and the address , we are now ready to transfer token between different addresses; we can create another address with the key name Bob
:
Now you can transfer tokens to Bob, for example, you can send
1
CRO to Bob's address byLastly, check
balance
of Bob's address:
Congratulations! You've successfully transferred tokens to Bob.
Staking Operation
Cronos POS Chain is based on tendermint with the Proof of Stake (POS) consensus algorithm. In this sub-section, we will be covering how to perform basic staking related transactions.
Check the current validator set
Firstly, we can check the details of the current validator set by the query command of chain-maind, for example:
will result in
Then we can see that there are two active validators awesome0
and awesome1
at the moment.
For each validator, we can see that it comes with an address and a public key:
"operator_address"
- The operator address, which is used for identifying the operators of validators;"consensus_pubkey"
- The consensus public key, which is used for identifying the validator nodes participating in consensus.
Delegating to a validator
One can delegate their tokens to validator(s) and earn rewards by participating in the consensus process. For example, if you would like to delegate 5
cro to the validator node "awesome0"
, It can be done by sending a transaction with the Staking
module:
In order to do the above transaction, please note that you would need the "operator address" of the validator. This is the "operator_address"
with the prefix crocncl
we found in the last section.
Check and collect the delegation reward
As mentioned earlier, rewards will be accumulated once we delegate to a validator. We can check this reward by querying the Distribution
module, for example:
Afterwards, we can send the following transaction to withdraw the rewards:
If you are interested in contributing to or joining our testnet, you can continue reading the following sections about Joining the Croeseid Testnet.
Last updated