dawn4.2 呼叫RPC介面 發交易
阿新 • • 發佈:2019-02-08
官方對RPC更新不是很及時,例子也不多,以下是筆記摘要
1.
http://193.93.219.219:8888/v1/chain/abi_json_to_bin{"action":"transfer","args":{"from":"unlimited111","memo":"go go go go go","quantity":"1 EOS","to":"unlimited345"},"authorization":{"actor":"e":"eosio.token"}
{"binargs":"1042482a3be9e2d450c8482a3be9e2d4010000000000000000454f53000000000e676f20676f20676f20676f20676f"}
2.
http://193.93.219.219:8888/v1/chain/get_info
{"server_version":"7d0229f7","chain_id":"a628a5a6123d6ed60242560f23354c557f4a02826e223bb38aad79ddeb9afbca","head_block_num":618636,"last_irreversible_block_num":608068,"last_irreversible_block_id":"000947440b091df52fb49eb7ad0355014eadc1bd5a1c1da7a82925ebb5387150","head_block_id":"0009708c11ad28b06a0ac02c3279afad3cfe7673058fa4860fc3e1f63d554726","head_block_time":"2018-05-30T06:40:59","head_block_producer":"nakedmolerat","virtual_block_cpu_limit":12940693,"virtual_block_net_limit":1048576000,"block_cpu_limit":123331,"block_net_limit":1027464}
3.
http://193.93.219.219:8888/v1/chain/get_block {"block_num_or_id":618636}
{"timestamp":"2018-05-30T06:40:59.500","producer":"nakedmolerat","confirmed":0,"previous":"0009708b7580fd46ed6a8f527440030aab55e84993f20818377ef7636ed6a61c","transaction_mroot":"0000000000000000000000000000000000000000000000000000000000000000","action_mroot":"acbc609f1015f3a9ff39135997da59ed728f0c7bddd4d5f49655ef259fb084f1","schedule_version":68,"new_producers":null,"header_extensions":[],"producer_signature":"SIG_K1_KWjX1d3wdMeCcRByARb9QK52LTZDpeFPeVrfpCdXVTdxtyBFdKjCkQ2XGDan1y5TixvvYSJaNtvGmmVBThNeSsbcWwCtF7","transactions":[],"block_extensions":[],"id":"0009708c11ad28b06a0ac02c3279afad3cfe7673058fa4860fc3e1f63d554726","block_num":618636,"ref_block_prefix":750783082}
4.
http://47.92.97.56:55553/v1/wallet/unlock ["wallet","PW5J26x3uoaEizL2UdWGqdhNh2LnUm55yDhefqUK7qk9det5HBKzC"]
5.
http://47.92.97.56:55553/v1/wallet/sign_transaction
[{"actions":[{"account":"unlimited111","authorization":[{"actor":"unlimited111","permission":"active"}],"data":"1042482a3be9e2d450c8482a3be9e2d4010000000000000000454f53000000000e676f20676f20676f20676f20676f","name":"transfer"}],"expiration":"2018-05-30T06:45:59.000","read_scope":[],"ref_block_num":618636,"ref_block_prefix":750783082,"scope":["unlimited111","unlimited345"],"signatures":[]},["EOS5ftydmBidTRo8fFsQMGKsF1haPaNV1d9p2DRDWoNCSdnpEdExh"],""]
{"expiration":"2018-05-30T06:45:59","ref_block_num":28812,"ref_block_prefix":750783082,"max_net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"unlimited111","name":"","authorization":[{"actor":"unlimited111","permission":"active"}],"data":"1042482a3be9e2d450c8482a3be9e2d4010000000000000000454f53000000000e676f20676f20676f20676f20676f"}],"transaction_extensions":[],"signatures":["SIG_K1_K4PokjYUcA9zFfgyJ2FnmhrbbkJq3GkMMBaTFKGWo1HdprcokncVJTk7YWui5W4GbxNyaAUYjRnua6wvxWBhMwKF9u1Qm2"],"context_free_data":[]}
6. 這一步返回error,不知道為什麼,聽說是4.2才出現的,後續繼續觀察
http://193.93.219.219:8888/v1/chain/push_transaction
{"compression":"none","signatures":["SIG_K1_KdU6MfydCxKRN9dMr5K7Agsy8yH3SJMYHaddqFiaejS4kqTGn8kXea8ZBoucxc7trnXJ6dRfvLUkjKVvReJ9HaUXbmoHy9"],"transaction":{"actions":[{"account":"unlimited111","authorization":[{"actor":"unlimited111","permission":"active"}],"data":"1042482a3be9e2d450c8482a3be9e2d4010000000000000000454f53000000000e676f20676f20676f20676f20676f","name":"transfer"}],"context_free_actions":[],"delay_sec":0,"expiration":"2018-05-30T06:45:59.000","max_kcpu_usage":0,"max_net_usage_words":0,"ref_block_num":618636,"ref_block_prefix":750783082,"region":0}}
{"code":500,"message":"Internal Service Error","error":{"code":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"unlimited111\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}
注意:
1.錢包連不通
netstat -anp|grep 55553發現是127.0.0.1:55553,改為0.0.0.0:55553就好了(在錢包啟動指明)2.官方RPC引數不完全,可以根據以下方式來確認
-j,--json print result as json
-d,--dont-broadcast don't broadcast transaction to the network (just print to stdout)