所有基于cosmos的区块链项目的测试网启动方法
2021-05-29

Abstract

基于cosmos框架的区块链项目,在启动脚本上都大同小异。
这里做一下整理记录。方便后面的测试使用。

genesis file format

init

serverd init --gen-txs --home=$HOME/.gaiad1 --chain-id=test-chain

gentx

serverd gentx --name validator --amount 1000000000ucsdt

add-genesis-account

serverd add-genesis-account $(client keys show validator -a) 10000000000ucsdt

Collect-gentxs

serverd collect-gentxs

start

serverd start

总结

这边用xar-network来举例

# You can run all of these commands from your home directory
cd $HOME

# Initialize the genesis.json file that will help you to bootstrap the network
xard init --chain-id=testing testing

# Create a key to hold your validator account
xarcli keys add validator

# Add that key into the genesis.app_state.accounts array in the genesis file
# NOTE: this command lets you set the number of coins. Make sure this account has some coins
# with the genesis.app_state.staking.params.bond_denom denom, the default is staking
xard add-genesis-account $(xarcli keys show validator -a) 10000000000000uftm,10000000000ucsdt

# Generate the transaction that creates your validator
xard gentx --name validator --amount 1000000000ucsdt

# Add the generated bonding transaction to the genesis file
xard collect-gentxs

# Now its safe to start `xard`
xard start

这样就初始化了 validator并给了一些初始代币。