BroadcastTransaction - Tron
This method submits a signed transaction to the network. It accepts the full signed Transaction message and returns whether it was accepted.
Service
This method is served by the protocol.Wallet service.
Method
protobufrpc BroadcastTransaction (Transaction) returns (Return)Request Message
Transaction
| Field | Type | Description |
|---|---|---|
| raw_data | raw | The transaction body, including its contracts |
| signature | repeated bytes | Signatures over the transaction |
Request
bashgrpcurl -H 'x-api-key: <ACCESS-TOKEN>' \
-d '{"raw_data": {"contract": []}, "signature": ["<signature-bytes>"]}' \
shared.eu-central-1.getblock.io:443 protocol.Wallet/BroadcastTransactionexample.py
pythonimport grpc
# Stubs generated from java-tron's api.proto with grpcio-tools
from api import api_pb2_grpc
from core import Contract_pb2, Tron_pb2
creds = grpc.ssl_channel_credentials()
channel = grpc.secure_channel('shared.eu-central-1.getblock.io:443', creds)
metadata = [('x-api-key', '<ACCESS-TOKEN>')]
stub = api_pb2_grpc.WalletStub(channel)
response = stub.BroadcastTransaction(signed_transaction, metadata=metadata)
print(response)example.go
goconn, _ := grpc.Dial(
"shared.eu-central-1.getblock.io:443",
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
)
defer conn.Close()
client := api.NewWalletClient(conn)
ctx := metadata.AppendToOutgoingContext(
context.Background(), "x-api-key", "<ACCESS-TOKEN>")
resp, _ := client.BroadcastTransaction(ctx, signedTx)
fmt.Println(resp)Response Message
Return
| Field | Type | Description |
|---|---|---|
| result | bool | true when the transaction is accepted |
| code | response_code | Rejection code, when not accepted |
| message | bytes | Rejection reason, when not accepted |
Use Cases
- Payment Broadcast: Submit a signed TRX or token transfer
- Contract Calls: Broadcast a signed contract call
- dApp Backends: Relay transactions signed on the client
- Retry Flows: Resubmit a signed transaction from stored data
Error Handling
| Code | Status | Description |
|---|---|---|
| 3 | INVALID_ARGUMENT | A request field is missing or malformed |
| 5 | NOT_FOUND | The requested account, block, or transaction does not exist |
| 16 | UNAUTHENTICATED | The access token is missing or invalid |
| 13 | INTERNAL | The node failed to process the request |