/wallet/broadcasthex¶
Broadcast a signed transaction whose payload is the protobuf-hex encoding of Transaction. Smaller body than /wallet/broadcasttransaction.
- Source:
framework/src/main/java/org/tron/core/services/http/BroadcastHexServlet.java - Method:
POST
Request parameters¶
| Field | Type | Required | Description |
|---|---|---|---|
transaction |
string | Yes | Hex of the protobuf serialization of a complete protocol.Transaction |
Example:
curl --request POST \
--url https://nile.trongrid.io/wallet/broadcasthex \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{ "transaction": "0a8a010a02..." }
'
The
transactionfield must be the hex of the entire signed Transaction protobuf — produced by signing theraw_data_hexreturned by/wallet/createtransactionand re-serializing the full Transaction; the0a8a010a02...above is just a placeholder.
Response¶
| Field | Type | Description |
|---|---|---|
result |
bool | Whether it entered the transaction pool |
code |
string | Same as broadcasttransaction, but emitted directly as the enum name |
message |
string | Failure reason (UTF-8) |
transaction |
string | The parsed Transaction JSON in string form (the servlet forces visible=true and calls JsonFormat.printToString, then puts the string into the response; clients need to JSON-parse this field again) |
txid |
string | Transaction hash |
Response example:
{
"result": true,
"code": "SUCCESS",
"message": "",
"transaction": "{...}",
"txid": "d5ec749ecc2a615399d8a6c864ea4c74ff9f8453eaa44d6b1e2f0b7b3e2f3b6a"
}
Error responses¶
Business-level errors (SIGERROR / DUP_TRANSACTION_ERROR / TAPOS_ERROR, etc.) are returned in the result/code/message shape; code values match /wallet/broadcasttransaction.
When transaction is missing, not valid hex, or Transaction.parseFrom deserialization fails, Util.processError kicks in (the servlet does not call Util.checkBodySize, so there is no body-size branch):
| Trigger | Response |
|---|---|
| Request body is not valid JSON | {"Error": "class com.alibaba.fastjson.JSONException : <parser info>"} |
transaction field missing |
Business-level response {"result": false, "code": "CONTRACT_VALIDATE_ERROR", "message": "Contract validate error : No contract!", "transaction": "{}", "txid": "<SHA256 of empty Transaction>"} (getString returns null → ByteArray.fromHexString(null) returns empty array → Transaction.parseFrom returns empty Transaction → enters broadcast) |
transaction is not a string (array/object/number) |
{"Error": "class org.bouncycastle.util.encoders.DecoderException : <message>"} (fastjson getString calls toString on non-strings and hands it to ByteArray.fromHexString) |
transaction is not valid hex |
{"Error": "class org.bouncycastle.util.encoders.DecoderException : <message>"} |
transaction is not valid protobuf |
{"Error": "class com.google.protobuf.InvalidProtocolBufferException : <message>"} |
| Other exceptions | {"Error": "<exceptionClass> : <message>"} |