rpc 账户间交易

管理员组 夜小白 4月前 59

rpc 账户间交易

查看eosio账户余额

curl http://192.168.1.56:8889/v1/chain/get_account -X POST -d '{"account_name":"eosio"}'

查看umidata账户余额

curl http://192.168.1.56:8889/v1/chain/get_account -X POST -d '{"account_name":"umidata"}'

将交易信息由JSON格式序列化为BIN格式字符串

从eosio转1000EOS给umidata:

curl http://192.168.1.56:8889/v1/chain/abi_json_to_bin -X POST -d ‘{"code":"eosio.token","action":"transfer","args":{"from":"eosio","to":"umidata","quantity":"1000.0000 SYS", "memo":"Please reply after receiving!"}}’

{"binargs":"0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"}

获取当前最新的区块编号

curl http://192.168.1.56:8889/v1/chain/get_info 
{"server_version":"e87d245d","chain_id":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f","head_block_num":106171,"last_irreversible_block_num":106170,"last_irreversible_block_id":"00019ebab528854189a3b25617d4b0512fe49d0c51fe9ceb500f8757361ae5b4","head_block_id":"00019ebb562d5999d235eab2a09582befd838ac5ab928d92aaaf61021d3d98df","head_block_time":"2018-09-18T06:03:55.000","head_block_producer":"eosio","virtual_block_cpu_limit":200000000,"virtual_block_net_limit":1048576000,"block_cpu_limit":199900,"block_net_limit":1048576,"server_version_string":"v1.2.3-dirty"}

根据区块编号获取区块详情

curl http://192.168.1.56:8889/v1/chain/get_block -X POST -d '{"block_num_or_id":106171}'
{"timestamp":"2018-09-18T06:03:55.000","producer":"eosio","confirmed":0,"previous":"00019ebab528854189a3b25617d4b0512fe49d0c51fe9ceb500f8757361ae5b4","transaction_mroot":"0000000000000000000000000000000000000000000000000000000000000000","action_mroot":"140de8499a74cce764c258d789130dbaecd53880f6368a52c25165c49536cc40","schedule_version":0,"new_producers":null,"header_extensions":[],"producer_signature":"SIG_K1_KASq5uj92Nk31JuwqwCPCndhMqnWEAC1CA5kLWEZTsEbLrN5QDYS6godWD9iAcuBtvEzyTU39p8eKRuUGaWL2FLBXvqzYx","transactions":[],"block_extensions":[],"id":"00019ebb562d5999d235eab2a09582befd838ac5ab928d92aaaf61021d3d98df","block_num":106171,"ref_block_prefix":3001693650}

获取到timestamp 和ref_block_prefix

签署交易

解锁钱包

curl http://192.168.1.56:8888/v1/wallet/unlock -X POST -d '["default", "PW5JJN8KLE2akHa62NeTCmjkUbmetLfA2edAvb3ge5TR59oDASpi3"]'
curl http://192.168.1.56:8888/v1/wallet/sign_transaction -X POST -d 
'[
    {
        "ref_block_num": 106171,
        "ref_block_prefix": 3001693650,
        "expiration": "2018-09-18T06:33:55.000",
        "actions": [
            {
                "account": "eosio.token",
                "name": "transfer",
                "authorization": [
                    {
                        "actor": "eosio",
                        "permission": "active"
                    }
                ],
                "data": "0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"
            }
        ],
        "signatures": [

        ]
    },
    [
        "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
    ],
    "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
]'
{"expiration":"2018-09-18T06:33:55","ref_block_num":40635,"ref_block_prefix":3001693650,"max_net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio.token","name":"transfer","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"}],"transaction_extensions":[],"signatures":["SIG_K1_K3XLwFZQGJDnAZqNxjzeiLZ62rJxPnaVsVxQcz9uGKtmSB8Q5KjcHtGxvQXqh6VDzS6yyK5Pt7o39zG9kHLBGgM6CUTMTK"],"context_free_data":[]}

提交交易

curl http://192.168.1.56:8889/v1/chain/push_transaction -X POST -d

'{
    "transaction": {
        "expiration": "2018-09-18T06:33:55.000",
        "ref_block_num": 106171,
        "ref_block_prefix": 3001693650,
        "max_net_usage_words": 0,
        "max_cpu_usage_ms": 0,
        "delay_sec": 0,
        "context_free_actions": [

        ],
        "actions": [
            {
                "account": "eosio.token",
                "name": "transfer",
                "authorization": [
                    {
                        "actor": "eosio",
                        "permission": "active"
                    }
                ],
                "data": "0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"
            }
        ],
        "transaction_extensions": [

        ],
        "context_free_data": [

        ]
    },
    "signatures": [
        "SIG_K1_K3XLwFZQGJDnAZqNxjzeiLZ62rJxPnaVsVxQcz9uGKtmSB8Q5KjcHtGxvQXqh6VDzS6yyK5Pt7o39zG9kHLBGgM6CUTMTK"
    ],
    "compression": "none"
}'

查看umidata账户余额查看umidata账户余额

curl http://192.168.1.56:8889/v1/chain/get_account -X POST -d '{"account_name":"umidata"}'

{"transaction_id":"54f3410c5e1998fe48aa6bf40a7a7152ff6b78e07b89713b9df552696143076b","processed":{"id":"54f3410c5e1998fe48aa6bf40a7a7152ff6b78e07b89713b9df552696143076b","receipt":{"status":"executed","cpu_usage_us":8349,"net_usage_words":20},"elapsed":8349,"net_usage":160,"scheduled":false,"action_traces":[{"receipt":{"receiver":"eosio.token","act_digest":"b5853e8140370cf62128f9d41e0b4f194b562f104d5658c7a7b8872c063f0af7","global_sequence":109186,"recv_sequence":10,"auth_sequence":[["eosio",109183]],"code_sequence":1,"abi_sequence":1},"act":{"account":"eosio.token","name":"transfer","authorization":[{"actor":"eosio","permission":"active"}],"data":{"from":"eosio","to":"umidata","quantity":"1000.0000 SYS","memo":"Please reply after receiving!"},"hex_data":"0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"},"elapsed":6037,"cpu_usage":0,"console":"","total_cpu_usage":0,"trx_id":"54f3410c5e1998fe48aa6bf40a7a7152ff6b78e07b89713b9df552696143076b","inline_traces":[{"receipt":{"receiver":"eosio","act_digest":"b5853e8140370cf62128f9d41e0b4f194b562f104d5658c7a7b8872c063f0af7","global_sequence":109187,"recv_sequence":109170,"auth_sequence":[["eosio",109184]],"code_sequence":1,"abi_sequence":1},"act":{"account":"eosio.token","name":"transfer","authorization":[{"actor":"eosio","permission":"active"}],"data":{"from":"eosio","to":"umidata","quantity":"1000.0000 SYS","memo":"Please reply after receiving!"},"hex_data":"0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"},"elapsed":682,"cpu_usage":0,"console":"","total_cpu_usage":0,"trx_id":"54f3410c5e1998fe48aa6bf40a7a7152ff6b78e07b89713b9df552696143076b","inline_traces":[]},{"receipt":{"receiver":"umidata","act_digest":"b5853e8140370cf62128f9d41e0b4f194b562f104d5658c7a7b8872c063f0af7","global_sequence":109188,"recv_sequence":1,"auth_sequence":[["eosio",109185]],"code_sequence":1,"abi_sequence":1},"act":{"account":"eosio.token","name":"transfer","authorization":[{"actor":"eosio","permission":"active"}],"data":{"from":"eosio","to":"umidata","quantity":"1000.0000 SYS","memo":"Please reply after receiving!"},"hex_data":"0000000000ea3055000000c064939cd4809698000000000004535953000000001d506c65617365207265706c7920616674657220726563656976696e6721"},"elapsed":130,"cpu_usage":0,"console":"","total_cpu_usage":0,"trx_id":"54f3410c5e1998fe48aa6bf40a7a7152ff6b78e07b89713b9df552696143076b","inline_traces":[]}]}],"except":null}}
还没有人收藏过本帖~
最新回复 (0)
返回