Skip to main content

buildTransaction

POST

Creates an unsigned TRON transaction.The combination of fields you provide determines the transaction type, and each type requires different parameters.
  • TransferContract: Transfers TRX. (from, to, value)
  • TransferAssetContract: Transfers a TRC-10 token. (from, to, tokenId, tokenValue)
  • CreateSmartContract: Deploys a smart contract. (from, name, gas, abi, data)
  • TriggerSmartContract: Calls a smart contract function. (from, to, data, gas)

🚧 The created transaction is unsigned!

You must sign the returned raw_data_hex and then broadcast it with /wallet/broadcasttransaction

of the FullNode HTTP API. This method alone does not submit the transaction.

📘 On GreatVoyage-v4.8.2 and later, contract creation and call parameters accept both data and input.

When both are given, they must decode to identical bytes; otherwise an invalid-parameters error is returned.

param[0]
transfercontractobjectrequired
Creates a transaction that transfers TRX.
fromstringrequired
The address of the account sending the transaction.
tostringrequired
The address of the account that will receive the TRX.
valuestringrequired
The amount of TRX to transfer, in sun, passed in hexadecimal.
param[1]
transferassetcontractobjectrequired
Creates a transaction that transfers a TRC-10 token.
fromstringrequired
The address of the account sending the transaction.
tostringrequired
The address of the account that will receive the token.
tokenIdintegerrequired
The ID of the TRC-10 token to transfer.
tokenValueintegerrequired
The amount of the TRC-10 token to transfer.
param[2]
createsmartcontractobjectrequired
Creates a transaction that deploys a smart contract.
fromstringrequired
The address of the account that will deploy the contract.
namestringrequired
The name of the contract to deploy.
gasstringrequired
The fee limit. Pass it in hexadecimal.
abistringrequired
The ABI of the contract, passed as a JSON string.
datastring
The contract bytecode.
inputstring
An alias for data. When both are given, they must decode to identical bytes;otherwise an invalid-parameters error is returned. When a value is given, a 0x prefix is required.
consumeUserResourcePercentinteger
The percentage of resources the user bears.
originEnergyLimitinteger
The maximum energy the contract deployer bears.
valuestring
The amount of TRX to send via call_value, in sun.
tokenIdinteger
The ID of the TRC-10 token to send along.
tokenValueinteger
The amount of the TRC-10 token to send along.
param[3]
triggersmartcontractobjectrequired
Creates a transaction that calls a smart contract function.
fromstringrequired
The address of the account sending the transaction.
tostringrequired
The address of the contract to call.
datastring
The function selector to call and the ABI-encoded parameters.
inputstring
An alias for data. When both are given, they must decode to identical bytes;otherwise an invalid-parameters error is returned.
gasstringrequired
The fee limit. Pass it in hexadecimal.
valuestring
The amount of TRX to send via call_value, in sun.
tokenIdinteger
The ID of the TRC-10 token to send along.
tokenValueinteger
The amount of the TRC-10 token to send along.
Responses
The created transaction object.
visibleboolean
Whether addresses are shown in Base58 form.
txIDstring
The transaction ID.
contract_addressstring
The address of the contract to be created when the transaction creates one.
The raw data of the transaction.
The list of contracts included in the transaction.
typestring
The contract type. (e.g.) TransferContract, TriggerSmartContract
The parameters specific to the contract type.
type_urlstring
The URL that identifies the contract type.
valueobject
The parameter value, whose layout depends on the contract type.
ref_block_bytesstring
The lower 2 bytes of the reference block number.
ref_block_hashstring
Part of the reference block hash.
expirationinteger
The transaction expiration time, in milliseconds.
timestampinteger
The transaction creation time, in milliseconds.
fee_limitinteger
The maximum fee allowed for contract execution, in sun.
raw_data_hexstring
The raw data hex-encoded. This is the data that gets signed.
codestringrequired
Code identifying the cause of the failed request.
messagestringrequired
Detailed message including the name and value of the invalid parameter.
{
"code": "ERROR_CODE",
"message": "Unauthorized"
}
cURL
curl -X POST 'https://tron-mainnet.nodit.io' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: nodit-demo' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "buildTransaction",
"params": [
{
"from": "0xc4db2c9dfbcb6aa344793f1dda7bd656598a06d8",
"to": "0x95fd23d3d2221cfef64167938de5e62074719e54",
"value": "0x1f4"
},
{
"from": "0xc4db2c9dfbcb6aa344793f1dda7bd656598a06d8",
"to": "0x95fd23d3d2221cfef64167938de5e62074719e54",
"tokenId": 1000016,
"tokenValue": 20
},
{
"from": "0xc4db2c9dfbcb6aa344793f1dda7bd656598a06d8",
"name": "transferTokenContract",
"gas": "0x245498",
"consumeUserResourcePercent": 100
},
{
"from": "0x977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb",
"to": "0x9e62be7f4f103c36507cb2a753418791b1cdc182",
"data": "0xa9059cbb0000000000000000000000415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb0000000000000000000000000000000000000000000000000000000000000064",
"gas": "0x245498",
"value": "0x0"
}
]
}'