EOS RPC push_transaction
Why I always do something wrong with the push_transaction operation, who can tell how to fill in these parameters,and what is mean?
curl http://localhost:8888/v1/chain/push_transaction -X POST -d '{"ref_block_num":"100","ref_block_prefix":"137469861","expiration":"2017-09-25T06:28:49","scope":["initb","initc"],"actions":[{"code":"currency","type":"transfer","recipients":["initb","initc"],"authorization":[{"account":"initb","permission":"active"}],"data":"000000000041934b000000008041934be803000000000000"}],"signatures":[],"authorizations":[]}'
The ref_block_num and ref_block_prefix here are provided as a result of /v1/chain/get_block of the last_irreversible_block. You also need to use /v1/wallet/sign_transaction to get the right signature. Serialize json to binary hex. The resulting binary hex is usually used for the data field in push_transaction. In spite of this ,I was still wrong。Once you've resolved those issues,please enlighten me.
i have a same question where can i get a ref_block_num?
Looks like you are using 2.x interface. Dawn3's push_transaction is totally different from 2.x.
The request of push_transaction should be something like:
{
"compression": "none",
"packed_context_free_data": "00",
"packed_trx": "73e5db5a00008e955ed0c0000003666666",
"signatures": [
"EOSJws1o98U6Vc1ACqZiJvqQN5o8BpsKqzvMPkZRY7LeVnKKwwcJWvBxtkrsiumZ88d1tgQLhJpc38pVgB4d2ndUrQAnCrkwC"
]
}
Maybe EOSDevHelper will help you.
@spartucus hello, you have any clue about how to get packed_trx from original one ?
@LIU9293 Here is what you are looking for.
I am having similar problem. The version I am using is dawn 4.0. I use push_transaction rpc api but got the error:
{
"code":500,
"message":"Internal Service Error",
"error":{
"code":3010010,
"name":"packed_transaction_type_exception",
"what":"Invalid packed transaction",
"details":[
{
"message":"Missing signatures",
"file":"abi_serializer.hpp",
"line_number":393,
"method":"extract"
},
{
"message":"Failed to deserialize variant",
"file":"abi_serializer.hpp",
"line_number":487,
"method":"from_variant"
},
{
"message":"Invalid packed transaction",
"file":"chain_plugin.cpp",
"line_number":455,
"method":"push_transaction"
}
]
}
}
I give push_transaction the following params:
{
"signatures":[
"SIG_K1_KeH6wCsnUWRjrfGtqPpXFK4BJArfQ4FwuZARnpVyWkfgdrbrKMgH1msyvrvGyxABYj5UyNpMmipWhpyaruRaRFQbcuDBb4"
],
"compression":"none",
"packed_context_free_data":"",
"packed_trx":"000000005c95b1ca00000000007015d6010000000000000000454f5300000000087472616e73666572"
}
And I got the packed_trx above by using v1/chain/abi_json_to_bin, input params is like below:
"code":"eosio.token",
"action":"transfer",
"args":{
"from":"tester",
"to":"user",
"quantity":"1 EOS",
"memo":"transfer"
}
And I got the signature by using:
eosjs.modules.ecc.sign('signing tx', privateKey)
Cannot figure out what the problem is. Needing help!
Same problem. @spartucus Could please post some details about send transactions using RPC API?
my friend,I have the same problem. http://127.0.0.1:8888/v1/chain/push_transaction post data { "compression" : "none", "packed_context_free_data" : "", "packed_trx" : "0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446", "signatures" : [ "SIG_K1_Kc7XNr3aPsZ3asLXucmDJjMG8ACyRBxgryjd9Rm2xXJt1visyPiRQV1d4LqtvXZJmWtXQPzaJZRqjPC3QUerZxU6GhJVZ1" ] }
response: { "code": 500, "message": "Internal Service Error", "error": { "code": 3010010, "name": "packed_transaction_type_exception", "what": "Invalid packed transaction", "details": [{ "message": "Invalid packed transaction", "file": "chain_plugin.cpp", "line_number": 722, "method": "push_transaction" }, { "message": "read datastream of length 52 over by -2", "file": "datastream.cpp", "line_number": 6, "method": "throw_datastream_range_error" }, { "message": "error unpacking uint64_t", "file": "raw.hpp", "line_number": 616, "method": "unpack" }, { "message": "Error unpacking field value", "file": "raw.hpp", "line_number": 368, "method": "operator()" }, { "message": "error unpacking eosio::chain::name", "file": "raw.hpp", "line_number": 616, "method": "unpack" }, { "message": "Error unpacking field actor", "file": "raw.hpp", "line_number": 368, "method": "operator()" }, { "message": "error unpacking eosio::chain::permission_level", "file": "raw.hpp", "line_number": 616, "method": "unpack" }, { "message": "Error unpacking field authorization", "file": "raw.hpp", "line_number": 368, "method": "operator()" }, { "message": "error unpacking eosio::chain::action", "file": "raw.hpp", "line_number": 616, "method": "unpack" }, { "message": "Error unpacking field context_free_actions", "file": "raw.hpp", "line_number": 368, "method": "operator()" }] } }
the packed_trx is from the response of abi_json_to_bin : {"binargs":"0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446"}
where is the problem? Looking forward for you answer. Thank you.
same to me.
+1 Can someone tell me where the problem is?
@leekunkka maybe "packed_trx" is wrong
It is very likely that the way you pack the transaction is wrong. abi_json_to_bin returns you the serialized action which you put inside a transaction, which later will be signed by you and be packed as packed_transaction. If you are using javascript, recommend you to use eosjs because it helps you to do the packing, otherwise, it will be quite cumbersome.