actions 相关的命令
1. 查询指定 receiver 的 actions 列表
获取授权或接收方中引用的特定帐户名称的所有 actions。使用方式 cleos get actions [OPTIONS] account_name [pos] [offset]。
$ cleos get actions inita 0 3
# seq when contract::action => receiver trx id... args
================================================================================================================
# 0 2019-07-25T03:45:04.500 eosio.token::transfer => inita e451b136... {"from":"eosio","to":"inita","quantity":"220000000.0000 EOS"...
# 1 2019-07-25T03:45:04.500 eosio::regproducer => eosio 8c73f261... {"producer":"inita","producer_key":"EOS84BLRbGbFahNJEpnnJHYC...
# 2 2019-07-25T03:45:04.500 eosio::delegatebw => eosio b92d94bb... {"from":"inita","receiver":"inita","stake_net_quantity":"100...
# 3 2019-07-25T03:45:04.500 eosio.token::transfer => eosio.token b92d94bb... {"from":"inita","to":"eosio.stake","quantity":"200000000.000...
$ cleos get actions inita 0, 1 --json --full --pretty
{
"actions": [{
"global_action_seq": 154,
"account_action_seq": 0,
"block_num": 22,
"block_time": "2019-07-25T03:45:04.500",
"action_trace": {
"receipt": {
"receiver": "inita",
"act_digest": "ceef7fb260bb7e72a69ab530be6392b7337c9176531873afbb42e0a668c468dc",
"global_sequence": 154,
"recv_sequence": 1,
"auth_sequence": [[
"eosio",
149
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": {
"from": "eosio",
"to": "inita",
"quantity": "220000000.0000 EOS",
"memo": "issue 220000000.0000 EOS to inita"
},
"hex_data": "0000000000ea3055000000000093dd7400f0373a0002000004454f5300000000216973737565203232303030303030302e3030303020454f5320746f20696e697461"
},
"context_free": false,
"elapsed": 5,
"console": "",
"trx_id": "e451b13683d50e2f492dd690ca6555db4e3261d295d6625a2356f4f3bf68d039",
"block_num": 22,
"block_time": "2019-07-25T03:45:04.500",
"producer_block_id": null,
"account_ram_deltas": [],
"except": null,
"inline_traces": []
}
},{
"global_action_seq": 168,
"account_action_seq": 1,
"block_num": 22,
"block_time": "2019-07-25T03:45:04.500",
"action_trace": {
"receipt": {
"receiver": "eosio",
"act_digest": "33c8fe3a5a20a865c665a4f1648681889c1b5486d992f0599193384528270d84",
"global_sequence": 168,
"recv_sequence": 100,
"auth_sequence": [[
"inita",
1
]
],
"code_sequence": 2,
"abi_sequence": 2
},
"act": {
"account": "eosio",
"name": "regproducer",
"authorization": [{
"actor": "inita",
"permission": "active"
}
],
"data": {
"producer": "inita",
"producer_key": "EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG",
"url": "windstamp.com",
"location": 1
},
"hex_data": "000000000093dd740003a116d15370513e051c1a0a5df6d40c9b3c11c354f3af17228a1a1d968dff48bc0c7375706572656f732e636f6d0100"
},
"context_free": false,
"elapsed": 278,
"console": "",
"trx_id": "8c73f261f7e15fe276633a8109584142e4348f7235a58e20b90137ca293d5999",
"block_num": 22,
"block_time": "2019-07-25T03:45:04.500",
"producer_block_id": null,
"account_ram_deltas": [{
"account": "inita",
"delta": 454
}
],
"except": null,
"inline_traces": []
}
}
],
"last_irreversible_block": 221
}
其中:
- inita 为账号名称
需要注意的是,需要 nodeos 打开插件 history-plugin 和选项 --filter-on=*,否则查询结果为空。
2. pack_action_data
将 json 格式描述的 action 转换成 packed 格式。使用方式 cleos convert pack_action_data [OPTIONS] account name unpacked_action_data。
$ cleos convert pack_action_data eosio.token transfer '{
"from": "eosio",
"to": "alice",
"quantity": "1.0000 EOS",
"memo": "memo"
}'
0000000000ea30550000000000855c34102700000000000004454f5300000000046d656d6f
其中:
- eosio.token 是合约账户
- transfer 是 action 名称
- 16 进制字符串是 packed_action_data。
3. unpack_action_data
从 packed 格式转换成 json 描述的 action 格式。使用方式 cleos convert unpack_action_data [OPTIONS] account name packed_action_data。
$ cleos convert unpack_action_data eosio.token transfer 0000000000ea30550000000000855c34102700000000000004454f5300000000046d656d6f
{
"from": "eosio",
"to": "alice",
"quantity": "1.0000 EOS",
"memo": "memo"
}
其中:
- eosio.token 是合约账户
- transfer 是 action 名称
- 16 进制字符串是 packed_action_data。
4. 提交一个 action
提交一个包含单个 action 的交易。使用方式 cleos push action [OPTIONS] account action data。
s$ cleos -v push action eosio buyram '{"payer" : "alice", "receiver" : "alice", "quant" : "1.0000 EOS"}' -p alice@active
executed transaction: 18349af7ae4b586b678d6d258bc8e9f409d7bd53863108124a3b146f9811588a 128 bytes 1114 us
# eosio <= eosio::buyram {"payer":"alice","receiver":"alice","quant":"1.0000 EOS"}
# eosio.token <= eosio.token::transfer {"from":"alice","to":"eosio.ram","quantity":"0.9950 EOS","memo":"buy ram"}
# alice <= eosio.token::transfer {"from":"alice","to":"eosio.ram","quantity":"0.9950 EOS","memo":"buy ram"}
# eosio.ram <= eosio.token::transfer {"from":"alice","to":"eosio.ram","quantity":"0.9950 EOS","memo":"buy ram"}
# eosio.token <= eosio.token::transfer {"from":"alice","to":"eosio.ramfee","quantity":"0.0050 EOS","memo":"ram fee"}
# alice <= eosio.token::transfer {"from":"alice","to":"eosio.ramfee","quantity":"0.0050 EOS","memo":"ram fee"}
# eosio.ramfee <= eosio.token::transfer {"from":"alice","to":"eosio.ramfee","quantity":"0.0050 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
附录 1. 一个 action
{
"from": "eosio",
"to": "alice",
"quantity": "1.0000 EOS",
"memo": "memo"
}
项目源代码
项目源代码会逐步上传到 Github,地址为 https://github.com/windstamp/blockchain。
Contributor
- Windstamp, https://github.com/windstamp
网友评论