2.4.1 cleos-commands-contracts-system

针对智能合约 eosio.system 的 cleos 常用命令

发送合约 eosio.system 的 action 到区块链。使用方式 cleos system SUBCOMMAND。

1. 编译 & 部署

1.1 编译

1.2 部署

2. action

2.1 newaccount

在区块链上创建一个新的账户,并初始化资源。使用方式 cleos system newaccount [OPTIONS] creator name OwnerKey [ActiveKey]。

$ cleos system newaccount eosio windstamp EOS82MG6DQqUCuwwcF2dfUs4uvSqLNqgpUCEyCpg35TAZ411R4gzv --stake-net "1 EOS"  --stake-cpu "1 EOS" --buy-ram "1 EOS" -p eosio@active
executed transaction: 4775bcf312e1db4bbb108483faf4cf1d9fa7a891bc5744827df2608be10da256  344 bytes  1790 us
$ cleos system newaccount eosio furnace EOS82MG6DQqUCuwwcF2dfUs4uvSqLNqgpUCEyCpg35TAZ411R4gzv --stake-net "1 EOS"  --stake-cpu "1 EOS" --buy-ram "1 EOS" -p windstamp@active

其中:

  • eosio 表示智能合约 eosio.system
  • windstamp 表示待创建的新账户名称
  • EOS82MG6DQqUCuwwcF2dfUs4uvSqLNqgpUCEyCpg35TAZ411R4gzv 表示公钥,这里同时用于 owner 和 active
  • --stake-net "10 EOS" 表示质押 10 个 EOS 用于带宽
  • --stake-cpu "10 EOS" 表示质押 10 个 EOS 用于 CPU
  • --buy-ram "10 EOS" 表示购买 10 个 EOS 对应的内存

2.2 regproducer

注册一个新的生产者。使用方式 cleos system regproducer [OPTIONS] account producer_key [url] [location]。

$ cleos system regproducer alice EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG "alice.com" 0
executed transaction: 35dd245e2d8bdbd0ab9a5bba01445b57daa6f6be4f3b50663765c91cff7c1bf4  152 bytes  465 us
#         eosio <= eosio::regproducer           {"producer":"alice","producer_key":"EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG","url":"al...
warning: transaction executed locally, but may not be confirmed by the network yet         ]
$ cleos push action eosio regproducer '{"producer" : "alice", "producer_key" : "EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG", "url" : "alice.com", "location" : 1}' -p alice@active
executed transaction: 15412008a755d65b1bfda07ed023383e5f0f7adafb8f49ab9430240f85aaf5af  152 bytes  455 us
#         eosio <= eosio::regproducer           {"producer":"alice","producer_key":"EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG","url":"al...
warning: transaction executed locally, but may not be confirmed by the network yet         ]

2.3 unregprod

取消注册一个已有的生产者。使用方式 cleos system unregprod [OPTIONS] account。

$ cleos system unregprod alice
executed transaction: 799e5beef1c48f53b1587b1014e3784642b35f28f2d9e6d216e53bb8b639636e  104 bytes  449 us
#         eosio <= eosio::unregprod             {"producer":"alice"}
warning: transaction executed locally, but may not be confirmed by the network yet         ]

2.4 voteproducer

投票一个生产者。使用方式 cleos system voteproducer [OPTIONS] SUBCOMMAND。

$ cleos -v push action eosio voteproducer '{"voter" : "alice", "proxy" : "", "producers" : ["node1"]}' -p alice@active

2.4.1 proxy

通过代理进行投票,即先投票给代理,再由代理投票给生产者。使用方式 cleos system voteproducer proxy [OPTIONS] voter proxy。

$ cleos system voteproducer proxy alice windstamp

2.4.2 prods

投票给一个或多个生产者。使用方式 cleos system voteproducer prods [OPTIONS] voter producers...。

$ cleos system voteproducer prods bob alice

2.4.3 approve

添加一个生产者到已投票的生产者列表。使用方式 cleos system voteproducer approve [OPTIONS] voter producer。

$ cleos system voteproducer approve bob alice

2.4.4 unapprove

从生产者列表中移除一个生产者。使用方式 cleos system voteproducer unapprove [OPTIONS] voter producer。

$ cleos system voteproducer unapprove bob alice

2.5 listproducers

列出生产者列表。使用方式 cleos system listproducers [OPTIONS]。

$ cleos system listproducers

2.6 delegatebw

质押资源,比如:CPU、网络带宽。使用方式 cleos system delegatebw [OPTIONS] from receiver stake_net_quantity stake_cpu_quantity。

$ cleos system delegatebw alice alice "1.0000 EOS" "1.0000 EOS"
$ cleos -v push action eosio delegatebw '{"from" : "alice", "receiver" : "alice", "stake_net_quantity" : "1.0000 EOS", "stake_cpu_quantity" : "1.0000 EOS", "transfer" : 0}' -p alice@active

2.7 undelegatebw

取消资源质押,比如:CPU、网络带宽。使用方式 cleos system undelegatebw [OPTIONS] from receiver unstake_net_quantity unstake_cpu_quantity。

$ cleos system undelegatebw alice alice "1.0000 EOS" "1.0000 EOS"

2.8 listbw

列出质押的资源。使用方式 cleos system listbw [OPTIONS] account。

$ cleos system listbw alice

2.9 bidname

名字绑定。使用方式 cleos system bidname [OPTIONS] bidder newname bid。

$ cleos system bidname alice aliceson "100.0000 EOS"

2.10 bidnameinfo

获取绑定名字的信息。使用方式 cleos system bidnameinfo [OPTIONS] newname。

$ cleos system bidnameinfo aliceson

2.13.11 buyram

购买内存。使用方式 cleos system buyram [OPTIONS] payer receiver amount。

$ cleos system buyram alice alice "100.0000 EOS"
$ cleos system buyram alice alice 1000 --bytes
$ cleos system buyram alice alice 1000 --kbytes
$ cleos -v push action eosio buyrambytes '{"payer" : "alice", "receiver" : "alice", "bytes" : 10000}' -p alice@active
$ cleos -v push action eosio buyram '{"payer" : "alice", "receiver" : "alice", "quant" : "100.0000 EOS"}' -p alice@active

2.12 sellram

出售内存。使用方式 cleos system sellram [OPTIONS] account bytes。

$ cleos system sellram alice 1000

2.13 claimrewards

领取生产者奖励。使用方式 cleos system claimrewards [OPTIONS] owner。

$ cleos system claimrewards eosio
$ cleos -v push action eosio claimrewards '{"owner":"eosio"}' -p eosio@active
$ cleos -v push action eosio claimrewards '{"owner":"node1"}' -p eosio@active

2.14 regproxy

注册成为代理。使用方式 cleos system regproxy [OPTIONS] proxy。

$ cleos system regproxy windstamp
$ cleos -v push action eosio regproxy '{"proxy" : "inita", "isproxy" : true}' -p inita@active

2.15 unregproxy

取消注册成为代理。使用方式 cleos system unregproxy [OPTIONS] proxy。

$ cleos system unregproxy windstamp

2.16 canceldelay

取消一个延迟的交易。使用方式 cleos system canceldelay [OPTIONS] canceling_account canceling_permission trx_id。

$ cleos system canceldelay alice active 4d20a431f0232f374308ca46c430f5363d54b2da07226c180e23a9120a1ff2c1

@TODO

2.17 rex

与 REX 相关的操作。使用方式 cleos system rex [OPTIONS] SUBCOMMAND。

2.17.1 deposit
2.17.2 withdraw
2.17.3 buyrex
2.17.4 lendrex
2.17.5 unstaketorex
2.17.6 sellrex
2.17.7 cancelrexorder
2.17.8 mvtosavings
2.17.9 mvfromsavings
2.17.10 rentcpu
2.17.11 rentnet
2.17.12 fundcpuloan
2.17.13 fundnetloan
2.17.14 defundcpuloan
2.17.15 defundnetloan
2.17.16 consolidate
2.17.17 updaterex
2.17.18 rexexec
2.17.19 closerex

Reference

  1. eosio.system合约分析, https://blog.csdn.net/yhc166188/article/details/82751511
  2. EOS 投票合约,终于等到你。, https://cloud.tencent.com/developer/article/1121478

项目源代码

项目源代码会逐步上传到 Github,地址为 https://github.com/windstamp/blockchain。

Contributor

  1. Windstamp, https://github.com/windstamp

你可能感兴趣的:(2.4.1 cleos-commands-contracts-system)