使用

编译源码

#需要Go1.1.0+
#设置环境变量
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

#安装wget
sudo apt-get install wget

#下载cosmos-sdk
mkdir -p $GOPATH/src/github.com/cosmos/cosmos-sdk
git clone https://github.com/cosmos/cosmos-sdk.git
git checkout v0.17.3

#安装dep
#第一次
make get_tools
#升级
make update_tools

#编译并安装gaiad及gaiacli 
make get_vendor_deps
make install

#查看版本
gaiad version
gaiacli version

加入测试网络

#下载测试网配置
git clone https://github.com/cosmos/testnets

#拷贝5001配置文件
mkdir -p $HOME/.gaiad/config
cp -a testnets/gaia-5001/. $HOME/.gaiad/config/gentx

#初始化
gaiad unsafe_reset_all
gaiad init --gen-txs -o --chain-id=gaia-5001
{
  "chain_id": "gaia-5001",
  "node_id": "de87d2889c39ff159aad1b8320ca167fc20abcb9",
  "app_message": null
}


#修改配置文件,起一个自己的名字
vi ~/.gaiad/config/config.toml
moniker = "tnode01"

#接入测试网5001
gaiad start

#比较漫长的等待,等待区块同步完成

#可以通过Cosmos Monitor查看相关内容:
#http://IP:46657/

账号申请

#另起一个命令行
#查看节点情况
gaiacli status
{"node_info":{"id":"14a44f8842e8a509a8fa81b5dd6d1e4a81ede76a","listen_addr":"172.16.172.100:46656","network":"gaia-5001","version":"0.19.6","channels":"402022223303800","moniker":"node01","other":["amino_version=0.9.9","p2p_version=0.5.0","consensus_version=v1/0.2.2","rpc_version=0.7.0/3","tx_index=on","rpc_addr=cp://0.0.0.0:46657"]},"sync_info":{"latest_block_hash":"","latest_app_hash":"","latest_block_height":0,"latest_block_time":"1970-01-01T00:00:00Z","syncing":tue},"validator_info":{"address":"0DF31C99A66A8502DF3EC6119B34CAC8BC966F0A","pub_key":{"type":"AC26791624DE60","value":"UTPQHHJHJWeV3qU/iadXhvOd2uRFG7jRchfVYIYq+w="},"voting_power":100}}

#新增dc01
gaiacli keys add dc01
NAME:   ADDRESS:                                        PUBKEY:
dc01    C34E9EBFF95440DE8C597F30D609EE32807D142C        1624DE62209EE2218C2A639E23F117FC549DDD11900C7CE6EF238FF9846930B283DF5D1FA4

#查看
gaiacli keys show dc01

#查看key列表
gaiacli keys list
dc01    C34E9EBFF95440DE8C597F30D609EE32807D142C        1624DE62209EE2218C2A639E23F117FC549DDD11900C7CE6EF238FF9846930B283DF5D1FA4

#查看validator地址
gaiad show_validator
1624DE62205133D01C7247256795DEA53F89A75786F39DDAE4451BB8D17217D5608D58ABEC

#新增dc01
gaiacli keys add dc02
NAME:   ADDRESS:                                        PUBKEY:
dc02    E2F9D0D1E965125084F20FD79E17BFE1D40347DE        1624DE6220F50EDF6E1D7BD7493CF4CA7C727AC9D091C8EB7C32C45C98449EE4C73F6B14B2

申请代币

可以用Riot chat申请代币:

https://riot.im/app/#/room/#cosmos:matrix.org 中询问 @adrian:matrix.org 获得steak代币。

网站申请代币:

https://faucet.adrianbrink.com输入地址来领取代币(文档完成时还未开放)。

转账测试

#查看账号情况
gaiacli account C34E9EBFF95440DE8C597F30D609EE32807D142C
gaiacli account E2F9D0D1E965125084F20FD79E17BFE1D40347DE

#dc01转账给dc02
gaiacli send --amount=1000fermion --chain-id=gaia-5001 --sequence=1 --name=dc01 --to=E2F9D0D1E965125084F20FD79E17BFE1D40347DE

#查看账号情况
gaiacli account C34E9EBFF95440DE8C597F30D609EE32807D142C
gaiacli account E2F9D0D1E965125084F20FD79E17BFE1D40347DE

#查看150000高度时账号情况
gaiacli account C34E9EBFF95440DE8C597F30D609EE32807D142C --block=150000

成为Validator

#查看地址
gaiad show_validator
1624DE6220B83500DC8637F3F4591EE5042B92E7492F7F9C2CB0584E21A60C615EA0134213

#申请成为Validator
gaiacli declare-candidacy --amount=500steak --pubkey=1624DE62209EE2218C2A639E23F117FC549DDD11900C7CE6EF238FF9846930B283DF5D1FA4 --address-candidate=DA1E912BEE44F4ED30C893C93BC153F3411EA270 --moniker=satoshi --chain-id=gaia-5001 --sequence=1 --name=<key_name>

#修改信息
gaiacli edit-candidacy --details="neohope cosmos" --website="https://cosmos.network"

#检查配置信息
gaiacli candidate --address-candidate=DA1E912BEE44F4ED30C893C93BC153F3411EA270 --chain-id=gaia-5001

#确认已经成为candidacy
gaiacli validatorset

投票权委托

#委托
gaiacli delegate --amount=10steak --address-delegator=DA1E912BEE44F4ED30C893C93BC153F3411EA270 --address-candidate=<bonded_validator_address> --name=<key_name> --chain-id=gaia-5001 --sequence=1

#取消委托
gaiacli unbond --address-delegator=DA1E912BEE44F4ED30C893C93BC153F3411EA270 --address-candidate=<bonded_validator_address> --shares=MAX --name=<key_name> --chain-id=gaia-5001 --sequence=1

#查看投票权变化
gaiacli account DA1E912BEE44F4ED30C893C93BC153F3411EA270

#查看委托情况
gaiacli delegator-bond --address-delegator=DA1E912BEE44F4ED30C893C93BC153F3411EA270 --address-candidate=<bonded_validator_address> --chain-id=gaia-5001

最后更新于