新手问答 push_transaction 的 json 格式有什么规范呢

eoshily · 2018年07月03日 · 最后由 dnbstarz 回复于 2018年08月22日 · 11440 次阅读

使用rpc接口的push_transactionnewaccount,其中的json格式有什么规范呢?官网也没有给出范例

共收到 63 条回复

中间还需要abi_json_to_binsign_transaction,这些操作的json都是怎样的呢?搞了一天了。。。。

目前这块网上资料很少

strahe 回复

是的。你们网站自动创建账户后台怎么处理这些呢?

eoshily 回复

目前是封装的cleos

strahe 回复

soga

难道不是用eosjs吗?

你在使用cleos的时候,加上 --print-request --print-response 就可以分析了

Babena 回复

有这两个参数吗?我打出来似乎不行

grimraider 回复

不是,是rpc接口

const name = 'bcskill.com'
    const pubkey = 'EOS68mvUMCz73a5Xj2wnJxdTW1aPjmiKCeSAjVdXjTd3D3g9A38EE'
     eos.transaction(tr => {
        tr.newaccount({
          creator: 'dapp.exec',
          name,
          owner: pubkey,
          active: pubkey
        })

        tr.buyrambytes({
          payer: 'dapp.exec',
          receiver: name,
          bytes: 8192
        })

        tr.delegatebw({
          from: 'dapp.exec',
          receiver: name,
          stake_net_quantity: '10.0000 EOS',
          stake_cpu_quantity: '10.0000 EOS',
          transfer: 0
        })
    }).then(console.log)
    .catch(e => {
        console.error(e);
    })

curl http://seed.party.tc.ink:8888/v1/chain/push_transaction -X POST -d '{"compression":"none","packed_context_free_data":"","packed_trx":"4cce3d5bcab0b0b1f7de000000000100a6823403ea3055000000572d3ccdcd01104208c14f97b14a00000000a8ed323221104208c14f97b14a108418c34f97b14a102700000000000004535953000000000000","signatures":["SIG_K1_Jxohmfz7jXWueixcQWuKDZi5ZsEToBJQDDqwRrAoVCEXw78WzL5S9hs75Xcb1DaBnTwQjnPAyWS72D8jYKiZUxMmMPc661"]}'
这个结构就行

整个交易流程

前提:

有两个存在的账户
账户a有钱

REQUEST:

POST /v1/chain/get_currency_stats HTTP/1.0
Host: seed.party.tc.ink
content-length: 63
Accept: /
Connection: close

{
"json": false,
"code": "eosio.token",
"symbol": "SYS"

}

RESPONSE:

{
"SYS": {
"supply": "1000000000.0000 SYS",
"max_supply": "1000000000.0000 SYS",
"issuer": "eosio"
}

}

REQUEST:

POST /v1/chain/abi_json_to_bin HTTP/1.0
Host: seed.party.tc.ink
content-length: 167
Accept: /
Connection: close

{
"code": "eosio.token",
"action": "transfer",
"args": {
"from": "destiny11111",
"to": "destiny33221",
"quantity": "1.0000 SYS",
"memo": ""
}

}

RESPONSE:

{
"binargs": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"

}

REQUEST:

POST /v1/chain/get_info HTTP/1.0
Host: seed.party.tc.ink
content-length: 0
Accept: /
Connection: close


RESPONSE:

{
"server_version": "aa351733",
"chain_id": "cec278a9dced800d9a695adc1e265ed11efa0ad8a70cdaac1eb65718bbe2434f",
"head_block_num": 1183976,
"last_irreversible_block_num": 1183975,
"last_irreversible_block_id": "001210e7c283202dfdd95fb56123aa4f2e09af0a2505a544f6dd43b6181486cd",
"head_block_id": "001210e8cc1a2ab77f0da90d1d910bed243bf2c4cf9f2ded165c300d26910c3b",
"head_block_time": "2018-07-05T02:11:09.500",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 100000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 99900,
"block_net_limit": 1048576

}

REQUEST:

POST /v1/wallet/get_public_keys HTTP/1.0
Host: 127.0.0.1
content-length: 0
Accept: /
Connection: close


RESPONSE:

[
"EOS8fzQpvYNAb5et6oHSwkecEvL1yd2tmKiofgvhLjiqK27Qn9WiB"

]

REQUEST:

POST /v1/chain/get_required_keys HTTP/1.0
Host: seed.party.tc.ink
content-length: 662
Accept: /
Connection: close

{
"transaction": {
"expiration": "2018-07-05T02:11:39",
"ref_block_num": 4327,
"ref_block_prefix": 3042957821,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
}
],
"transaction_extensions": []
},
"available_keys": [
"EOS8fzQpvYNAb5et6oHSwkecEvL1yd2tmKiofgvhLjiqK27Qn9WiB"
]

}

RESPONSE:

{
"required_keys": [
"EOS8fzQpvYNAb5et6oHSwkecEvL1yd2tmKiofgvhLjiqK27Qn9WiB"
]

}

REQUEST:

POST /v1/wallet/sign_transaction HTTP/1.0
Host: 127.0.0.1
content-length: 744
Accept: /
Connection: close

[{
"expiration": "2018-07-05T02:11:39",
"ref_block_num": 4327,
"ref_block_prefix": 3042957821,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
}
],
"transaction_extensions": [],
"signatures": [],
"context_free_data": []
},[
"EOS8fzQpvYNAb5et6oHSwkecEvL1yd2tmKiofgvhLjiqK27Qn9WiB"
],
"cec278a9dced800d9a695adc1e265ed11efa0ad8a70cdaac1eb65718bbe2434f"

]

RESPONSE:

{
"expiration": "2018-07-05T02:11:39",
"ref_block_num": 4327,
"ref_block_prefix": 3042957821,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_K7aH1RdsCs45QeCeMMEWgr8cTF47zFfLuEBggigVdzwS93bEUnh3rRUtJsngVM739KHr4zq1Uo8ZBA6RdcVH3ip55ieSoj"
],
"context_free_data": []

}

REQUEST:

POST /v1/chain/push_transaction HTTP/1.0
Host: seed.party.tc.ink
content-length: 378
Accept: /
Connection: close

{
"signatures": [
"SIG_K1_K7aH1RdsCs45QeCeMMEWgr8cTF47zFfLuEBggigVdzwS93bEUnh3rRUtJsngVM739KHr4zq1Uo8ZBA6RdcVH3ip55ieSoj"
],
"compression": "none",
"packed_context_free_data": "",
"packed_trx": "5b7e3d5be710fdd95fb5000000000100a6823403ea3055000000572d3ccdcd01104208c14f97b14a00000000a8ed323221104208c14f97b14a108418c34f97b14a102700000000000004535953000000000000"

}

RESPONSE:

{
"transaction_id": "301e62d9e4098ae7d3b989efbccceee90169a0afc48ea29bf506076c5276aca5",
"processed": {
"id": "301e62d9e4098ae7d3b989efbccceee90169a0afc48ea29bf506076c5276aca5",
"receipt": {
"status": "executed",
"cpu_usage_us": 1157,
"net_usage_words": 16
},
"elapsed": 1157,
"net_usage": 128,
"scheduled": false,
"action_traces": [{
"receipt": {
"receiver": "eosio.token",
"act_digest": "242c9220a851b570220b858ed2b6498decdd659224bb7f5df97f1e87496e9462",
"global_sequence": 1809845,
"recv_sequence": 204774,
"auth_sequence": [[
"destiny11111",
1
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": {
"from": "destiny11111",
"to": "destiny33221",
"quantity": "1.0000 SYS",
"memo": ""
},
"hex_data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
},
"elapsed": 780,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "301e62d9e4098ae7d3b989efbccceee90169a0afc48ea29bf506076c5276aca5",
"inline_traces": [{
"receipt": {
"receiver": "destiny11111",
"act_digest": "242c9220a851b570220b858ed2b6498decdd659224bb7f5df97f1e87496e9462",
"global_sequence": 1809846,
"recv_sequence": 2,
"auth_sequence": [[
"destiny11111",
2
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": {
"from": "destiny11111",
"to": "destiny33221",
"quantity": "1.0000 SYS",
"memo": ""
},
"hex_data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
},
"elapsed": 7,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "301e62d9e4098ae7d3b989efbccceee90169a0afc48ea29bf506076c5276aca5",
"inline_traces": []
},{
"receipt": {
"receiver": "destiny33221",
"act_digest": "242c9220a851b570220b858ed2b6498decdd659224bb7f5df97f1e87496e9462",
"global_sequence": 1809847,
"recv_sequence": 2,
"auth_sequence": [[
"destiny11111",
3
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "destiny11111",
"permission": "active"
}
],
"data": {
"from": "destiny11111",
"to": "destiny33221",
"quantity": "1.0000 SYS",
"memo": ""
},
"hex_data": "104208c14f97b14a108418c34f97b14a1027000000000000045359530000000000"
},
"elapsed": 8,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "301e62d9e4098ae7d3b989efbccceee90169a0afc48ea29bf506076c5276aca5",
"inline_traces": []
}
]
}
],
"except": null
}

}

rpc的看不到吧

destiny008 回复

rpc的用官网上的不行

请问一下,为什么我的abi_bin_to_json请求,返回空的

请问一下push_transaction中的packed_trx参数怎么填写

lan 回复

我现在没有搞rpc得接口

eoshily 回复

我现在解决了,谢谢😀

lan 回复

求助,这个参数怎么填的啊?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册