Andrey Developer
Andrey Developer

Reputation: 65

TRON blockchain: create, sign and broadcast transaction via API of public node

Im php developer and trying to broadcast tron transaction. pls do not advice to me java libs. i think this operation can be made by API calls.

im understand 3 steps: create, sign and broadcast

step 1: use https://api.trongrid.io/wallet/createtransaction and get raw_data_hex result: 0a02df8d22080ffa79d7279ecb2a40a88bc8d9ba2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541e3b634e89a3edd652651b5c775870fc364cf2a061215413131e7dd9fe0ce528f9d86036fcfef56967d8807180170ecc8c4d9ba2e

step 2: create sign by steps from https://developers.tron.network/docs/account#signature result: 6bca53954ac706ddf59745e0e9d09e7c3709e58d1bdf35a06d0b974c1eaa0eca695d7b2aecd7200988f415a447e70064939ba56a6dd3c71725c547f3452ffaef00

and "Add this signature back into the transaction": 0a02df8d22080ffa79d7279ecb2a40a88bc8d9ba2e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541e3b634e89a3edd652651b5c775870fc364cf2a061215413131e7dd9fe0ce528f9d86036fcfef56967d8807180170ecc8c4d9ba2e6bca53954ac706ddf59745e0e9d09e7c3709e58d1bdf35a06d0b974c1eaa0eca695d7b2aecd7200988f415a447e70064939ba56a6dd3c71725c547f3452ffaef00

step 3: broadcast this by https://api.trongrid.io/wallet/broadcasthex result: {"Error":"class com.google.protobuf.InvalidProtocolBufferException : While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either that the input has been truncated or that an embedded message misreported its own length."}

that i did wrong?

also i tryed to use https://api.trongrid.io/wallet/gettransactionsign with only two parameters raw_data_hex and privateKey (i think this enought to sign) but got error: {"Error":"class java.lang.NullPointerException : null"}

im confused...

P.S. MAIN question is: how to prepare/build data to pass to API /wallet/broadcasthex ?

Upvotes: 4

Views: 2579

Answers (1)

Andelf
Andelf

Reputation: 622

Protobuf must be handled by protobuf libs. Use field getting/setting method. Not Binary Concat.

Upvotes: 0

Related Questions