push transaction by http rpc
body:
{ "ref_block_num":"10720", "ref_block_prefix":"3435223025", "expiration":"2017-12-08T10:28:49", "scope":["eosio.token","eosio"], "actions": [ { "code":"eosio.token", "type":"transfer", "recipients":["eosio.token","eosio"], "authorization": [ { "account":"eosio.token", "permission":"active"
}
],
"data": "00a6823403ea30550000000000ea30550a00000000000000005359530000000014656f73696f2e746f6b656e20746f20656f73696f"
}
],
"signatures":["SIG_K1_K3pbjG4VaSMCXA74kdQe22BYD7huwoD3nJyUTfaiBhGmoCf6ZQcoseqRb5mWmeJ9qkEhkBqHhKUS8NSxob92p35vXXFiCd"],
"authorizations":[],
"compression": "none"
}
response: { "code": 500, "message": "Internal Service Error", "error": { "code": 3010010, "name": "packed_transaction_type_exception", "what": "Invalid packed transaction", "details": [ { "message": "Missing transaction", "file": "abi_serializer.hpp", "line_number": 441, "method": "extract" }, { "message": "Failed to deserialize variant", "file": "abi_serializer.hpp", "line_number": 518, "method": "from_variant" }, { "message": "Invalid packed transaction", "file": "chain_plugin.cpp", "line_number": 526, "method": "push_transaction" } ] } }
closed as a duplicate of #2295
Why closed? Are you sure there is no issue when push transaction by http rpc?
@yankunsam HTTP request for transfer should look like
POST /v1/chain/push_transaction HTTP/1.0
Host: localhost
content-length: 380
Accept: */*
Connection: close
{
"signatures": [
"SIG_K1_KUtapJCfr7AyQbWGLVmX1rs1ALEt4JChfELCGjeA9WJFWtUTcX9WAwJW9UtrcWhwNRacu9EUVcYwZZLMs1oC6NqtdFX74C"
],
"compression": "none",
"packed_context_free_data": "",
"packed_trx": "9a0c175b4c007ec33354000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232220000000000ea305500000000007015d690d00300000000000453595300000000016d00"
}
where packed transaction is serialized form of
{
"expiration": "2018-06-05T22:23:06",
"ref_block_num": 429,
"ref_block_prefix": 3924558299,
"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": "0000000000ea305500000000007015d690d00300000000000453595300000000016d"
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_Kb7op8YUZReXMnMb5NyDEwxUtBjSr7CwysAJYNuyqD4KffKoHvVBiCMgFnoMmmNjEPNdFfjdzVJW473it71D1iZ2k82MtW"
],
"context_free_data": []
}
@yankunsam I don't quite understand how did you come up with your JSON, but it doesn't seem to be correct. So, I believe there is no issue with EOS software.
@moskvanaft I see your "actor" is "eosio". So you transfer from eosio to others? BTW, can I see your transaction signing request ? Thanks
Hi @yankunsam , maybe EOSDevHelper will help you.
@yankunsam there are 2 requests to generate the transaction
POST /v1/chain/abi_json_to_bin HTTP/1.0
Host: localhost
content-length: 120
Accept: */*
Connection: close
{
"code": "eosio.token",
"action": "transfer",
"args": [
"eosio",
"user",
"25.0000 SYS",
"m"
]
}
POST /v1/wallet/sign_transaction HTTP/1.0
Host: localhost
content-length: 738
Accept: */*
Connection: close
[{
"expiration": "2018-06-05T22:23:06",
"ref_block_num": 429,
"ref_block_prefix": 3924558299,
"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": "0000000000ea305500000000007015d690d00300000000000453595300000000016d"
}
],
"transaction_extensions": [],
"signatures": [],
"context_free_data": []
},[
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
],
"ea7bdcc30c18444c85bcf945efc467fef59244303f9190ef07545b80c209d3e0"
]
Tip: if you compile cleos from EOS master branch, you can use --print-request parameter, which will give you all requests cleos is doing when you run it. To get requests above I used
cleos --print-request push action -d eosio.token transfer '[ "eosio", "user", "25.0000 SYS", "m" ]' -p eosio
@moskvanaft Thanks. I will have a try by your advice. BTW, what "ea7bdcc30c18444c85bcf945efc467fef59244303f9190ef07545b80c209d3e0" is?
For eos v1.0.1, there is no "--print-request",
➜ Eoasis git:(master) ✗ cleos --wallet-url "http://127.0.0.1:8888" --print-request push action eosio.token transfer '["eosio.token","eosio","10.0000 SYS","m"]' -p eosio ERROR: ExtrasError: [--print-request] Push a transaction with a single action Usage: cleos push action [OPTIONS] account action data
@yankunsam , you've probably missed "if you compile cleos from EOS master branch" it's not in any official release yet
@yankunsam ea7bdcc30c18444c85bcf945efc467fef59244303f9190ef07545b80c209d3e0 is a chain id
@moskvanaft I try the master branch. I can get the right signature as the same content with the output of "cleos --print-request ". But I use the "curl xxx", so how to get the "packed_trx": "f067185b1f05404d779d000000000100a6823403ea3055000000572d3ccdcd0100a6823403ea305500000000a8ed32322200a6823403ea30550000000000ea3055a0860100000000000453595300000000016d00" by http api? Thanks
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.
@leekunkka How did you get your "packed_trx"? You packed transaction may be wrong.
my friend,thanks for you answer. my step is: 1、POST /v1/chain/abi_json_to_bin HTTP/1.1 Host: 192.168.1.189:8888 Accept: / Content-Length: 193 Content-Type: application/x-www-form-urlencoded
{ "action" : "transfer", "args" : { "from" : "currency", "memo" : "0xABASFDFDFDAFSDFDF", "quantity" : "123.1452 EOS", "to" : "fan1" }, "code" : "currency" } HTTP/1.1 200 OK Content-Length: 118 Content-type: application/json Server: WebSocket++/0.7.0
{"binargs":"0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446"}
2、GET /v1/chain/get_info HTTP/1.1 Host: 192.168.1.189:8888 Accept: /
HTTP/1.1 200 OK Content-Length: 541 Content-type: application/json Server: WebSocket++/0.7.0
{ "server_version": "00c78697", "chain_id": "706a7ddd808de9fc2b8879904f3b392256c83104c1d544b38302cc07d9fca477", "head_block_num": 399319, "last_irreversible_block_num": 399318, "last_irreversible_block_id": "000617d66c5b784150b17949d949867a9399f9d8bd86139b0c88406177709cc0", "head_block_id": "000617d7ca2e5e912dd0d777b12d327259f8ee01f7f71c25d5bfb5c32cab9a13", "head_block_time": "2018-06-12T10:18:04", "head_block_producer": "eosio", "virtual_block_cpu_limit": 200000000, "virtual_block_net_limit": 1048576000, "block_cpu_limit": 199900, "block_net_limit": 1048576 }
3、POST /v1/chain/get_block HTTP/1.1 Host: 192.168.1.189:8888 Accept: / Content-Length: 34 Content-Type: application/x-www-form-urlencoded
{ "block_num_or_id" : 399319 } HTTP/1.1 200 OK Content-Length: 670 Content-type: application/json Server: WebSocket++/0.7.0
{ "timestamp": "2018-06-12T10:18:04.500", "producer": "eosio", "confirmed": 0, "previous": "000617d66c5b784150b17949d949867a9399f9d8bd86139b0c88406177709cc0", "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000", "action_mroot": "88217b0517b6d0c1960a61b30df7fac2c355a0380a20bb0131ed1e4b6dad21f1", "schedule_version": 0, "new_producers": null, "header_extensions": [], "producer_signature": "SIG_K1_KX32oxFt1vgHbbUbgYiAyp8WghCuvGWMd1igsE9KVsMepEmHB2XtNjJW3FarqD9MPgv3PfGqgcLiafgCEzwCTu7qJzCNHX", "transactions": [], "block_extensions": [], "id": "000617d7ca2e5e912dd0d777b12d327259f8ee01f7f71c25d5bfb5c32cab9a13", "block_num": 399319, "ref_block_prefix": 2010632237 }
4、POST /v1/wallet/unlock HTTP/1.1 Host: 192.168.1.189:8900 Accept: / Content-Length: 71 Content-Type: application/x-www-form-urlencoded
[ "default", "PW5HzEvw2ziqnWkVvoi8gfXvDeAmtV9vr6wHbhmRha6b77BqBE9Vs" ] HTTP/1.1 200 OK Content-Length: 2 Content-type: application/json Server: WebSocket++/0.7.0
{}
5、POST /v1/wallet/sign_transaction HTTP/1.1 Host: 192.168.1.189:8900 Accept: / Content-Length: 889 Content-Type: application/x-www-form-urlencoded
[ { "actions" : [ { "account" : "currency", "authorization" : [ { "actor" : "currency", "permission" : "active" } ], "data" : "0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446", "name" : "transfer" } ], "context_free_actions" : [], "context_free_data" : [], "delay_sec" : 0, "expiration" : "2018-06-12T10:18:34", "max_cpu_usage_ms" : 0, "max_net_usage_words" : 0, "ref_block_num" : 399319, "ref_block_prefix" : 2010632237, "signatures" : [], "transaction_extensions" : [] }, [ "EOS5ZjHgJdcuHZHrYQoXVhQK3jhtJQW5hGiDfc49NL9akwMeRQ6JP" ], "706a7ddd808de9fc2b8879904f3b392256c83104c1d544b38302cc07d9fca477" ] HTTP/1.1 201 Created Content-Length: 570 Content-type: application/json Server: WebSocket++/0.7.0
{ "expiration": "2018-06-12T10:18:34", "ref_block_num": 6103, "ref_block_prefix": 2010632237, "max_net_usage_words": 0, "max_cpu_usage_ms": 0, "delay_sec": 0, "context_free_actions": [], "actions": [{ "account": "currency", "name": "transfer", "authorization": [{ "actor": "currency", "permission": "active" }], "data": "0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446" }], "transaction_extensions": [], "signatures": ["SIG_K1_KXjC1EKCQRUyr5VtXBpfq4nAiqFh6P5HvbmSXhDy4uSeYKyWZfjWfLeYruRAHsTCBEZiBgbRXdMTff4xpdV7jekH4m5SrV"], "context_free_data": [] }
6、POST /v1/chain/push_transaction HTTP/1.1 Host: 192.168.1.189:8888 Accept: / Content-Length: 328 Content-Type: application/x-www-form-urlencoded
{ "compression" : "none", "packed_context_free_data" : "", "packed_trx" : "0000001e4d75af46000000000010a6595cca12000000000004454f53000000001330784142415346444644464441465344464446", "signatures" : [ "SIG_K1_KXjC1EKCQRUyr5VtXBpfq4nAiqFh6P5HvbmSXhDy4uSeYKyWZfjWfLeYruRAHsTCBEZiBgbRXdMTff4xpdV7jekH4m5SrV" ] } HTTP/1.1 500 Internal Server Error Content-Length: 1241 Content-type: application/json Server: WebSocket++/0.7.0
{ "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 error is "packed_transaction_type_exception",Maybe where is wrong with the "packed_trx"? What rules do I generate "packed_trx"? Looking forword for you answer,thank you!
The "packed_trx" is different from the "abi_json_to_bin ". I have push the issues and BM has taged it support. https://github.com/EOSIO/eos/issues/3913#issuecomment-395636882
@yankunsam Thank you, my friend.
@moskvanaft what mechanism is used to serialise the transaction JSON into packed_trx?
@moskvanaft Thanks. I will have a try by your advice. BTW, what "ea7bdcc30c18444c85bcf945efc467fef59244303f9190ef07545b80c209d3e0" is?
chainId