Smart contract deployment and invocation via HTTP API
Deploy and invoke TRON smart contracts using raw HTTP API calls — the low-level path used when you need full control over transaction construction.
Prerequisites
This page documents the raw HTTP API path for deploying and invoking smart contracts. Most developers use a higher-level wrapper — TronWeb, TronBox, or TronIDE — which calls these endpoints under the hood. Use the HTTP API directly when you are building custom tooling, integrating from a non-JavaScript environment, or need full control over the transaction shape.
For the higher-level deployment walkthroughs, see Deploying and Quickstart.
Smart contract deployment
Deploying a smart contract is to create a CreateSmartContract transaction, which can be created through the Fullnode API wallet/deploycontract. After the transaction is created, it needs to be signed, and then broadcasted:
BASE_URL=https://api.shasta.trongrid.io # example — replace with any TRON node (TronGrid, third-party, or self-hosted)
curl --request POST \
--url ${BASE_URL}/wallet/deploycontract \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"owner_address": "41D1E7A6BC354106CB410E65FF8B181C600FF14292",
"abi": "[{\"constant\":false,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]",
"bytecode": "608060405234801561001057600080fd5b5060de8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ab06ee58114604d5780639507d39a146067575b600080fd5b348015605857600080fd5b506065600435602435608e565b005b348015607257600080fd5b50607c60043560a0565b60408051918252519081900360200190f35b60009182526020829052604090912055565b600090815260208190526040902054905600a165627a7a72305820fdfe832221d60dd582b4526afa20518b98c2e1cb0054653053a844cf265b25040029",
"fee_limit": 100000000,
"origin_energy_limit": 100000,
"name": "SomeContract",
"call_value": 0,
"consume_user_resource_percent": 100
}
'Abbreviated transaction-construction result:
{
"visible": false,
"txID": "<transaction-id>",
"contract_address": "<contract-address-hex>",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"owner_address": "41d1e7a6bc354106cb410e65ff8b181c600ff14292",
"new_contract": {
"bytecode": "608060405234801561001057600080fd5b5060de8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ab06ee58114604d5780639507d39a146067575b600080fd5b348015605857600080fd5b506065600435602435608e565b005b348015607257600080fd5b50607c60043560a0565b60408051918252519081900360200190f35b60009182526020829052604090912055565b600090815260208190526040902054905600a165627a7a72305820fdfe832221d60dd582b4526afa20518b98c2e1cb0054653053a844cf265b25040029",
"consume_user_resource_percent": 100,
"name": "SomeContract",
"origin_address": "41d1e7a6bc354106cb410e65ff8b181c600ff14292",
"abi": {
"entrys": [
{
"inputs": [
{
"name": "key",
"type": "uint256"
},
{
"name": "value",
"type": "uint256"
}
],
"name": "set",
"stateMutability": "Nonpayable",
"type": "Function"
},
{
"outputs": [
{
"name": "value",
"type": "uint256"
}
],
"constant": true,
"inputs": [
{
"name": "key",
"type": "uint256"
}
],
"name": "get",
"stateMutability": "View",
"type": "Function"
}
]
},
"origin_energy_limit": 100000
}
},
"type_url": "type.googleapis.com/protocol.CreateSmartContract"
},
"type": "CreateSmartContract"
}
],
"ref_block_bytes": "0a49",
"ref_block_hash": "975853d6629c8702",
"expiration": 1652153760000,
"fee_limit": 100000000,
"timestamp": 1652153701556
},
"raw_data_hex": "<abridged>"
}The 100,000,000 sun (100 TRX) fee_limit in this testnet example is a spending cap, not a fixed deployment cost. Estimate the required Energy before deployment, query the current getEnergyFee with wallet/getchainparameters, and ensure the resulting value does not exceed getMaxFeeLimit.
wallet/deploycontract only constructs an unsigned transaction. The returned txID, contract_address, and raw_data do not mean that the contract has been deployed. The client must still sign the transaction, call wallet/broadcasttransaction, and query wallet/gettransactioninfobyid. The precomputed contract_address becomes usable only after the receipt confirms successful execution.
The transaction structure of different transaction types are actually the same, but the content contained in raw_data is different, which is mainly reflected in the contract.parameter.value field of the transaction.
The contract.parameter.value in the contract deployment transaction contains the following content:
owner_address: the address of the contract owner, which is the contract deployer's addressnew_contract: details of the new smart contract- origin_address: the address of the smart contract owner
- contract_address: the address of the smart contract
- ABI: the ABI of the smart contract
- bytecode: bytecode of the smart contract
- call_value: the amount of TRX sending to the smart contract
- consume_user_resource_percent: user Energy payment percentage
- name: the name of the smart contract
- origin_energy_limit: the contract owner’s per-transaction Energy cap it passively covers — denominated in Energy (a unitless integer, unrelated to
fee_limit’s sun unit)
call_token_value: the amount of the TRC-10 token sending to the new smart contracttoken_id: the ID of the TRC-10 token
Smart contract invocation & query
triggersmartcontract
The contract call is to create a TriggerSmartContract transaction, which can be created through the Fullnode API wallet/triggersmartcontract. After the transaction is created, it needs to be signed, and then broadcasted to the entire network.
BASE_URL=https://api.shasta.trongrid.io # example — replace with any TRON node (TronGrid, third-party, or self-hosted)
curl -X POST ${BASE_URL}/wallet/triggersmartcontract -d '{
"contract_address":"419E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"transfer(address,uint256)",
"parameter":"00000000000000000000000015208EF33A926919ED270E2FA61367B2DA3753DA0000000000000000000000000000000000000000000000000000000000000032",
"fee_limit":100000000,
"call_value":0,
"owner_address":"41977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'Parameter description:
- contract_address: the contract address.
- owner_address: the caller address.
- function_selector: the contract function.
- parameter: the encoded parameter value of the contract method. In this example, there are two parameters that should be passed in, namely address and uint256 type. For more information about how to encode and decode the parameters, please refer to Parameter Encoding and Decoding.
- fee_limit: the caller-side Energy budget cap for this transaction, denominated in sun. For more information, please refer to FeeLimit & Energy cost.
- call_value: the amount of TRX sending to the smart contract.
The endpoint returns the following construction result containing an unsigned contract-call transaction:
{
"result": {
"result": true
},
"transaction": {
"visible": false,
"txID": "24df5ebd8c041a46ba2f5c4a8bfc10c6cfc7d0d4572cf7fd9c54b1456a0926d7",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "a9059cbb00000000000000000000000015208ef33a926919ed270e2fa61367b2da3753da0000000000000000000000000000000000000000000000000000000000000032",
"owner_address": "41977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb",
"contract_address": "419e62be7f4f103c36507cb2a753418791b1cdc182"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "1c51",
"ref_block_hash": "74912b480b7b887c",
"expiration": 1652169501000,
"fee_limit": 100000000,
"timestamp": 1652169442098
},
"raw_data_hex": "0a021c51220874912b480b7b887c40c8d2e7e78a305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb1215419e62be7f4f103c36507cb2a753418791b1cdc1822244a9059cbb00000000000000000000000015208ef33a926919ed270e2fa61367b2da3753da000000000000000000000000000000000000000000000000000000000000003270b286e4e78a30900180c2d72f"
}
}Here, result.result: true only means that transaction construction and node-side prevalidation succeeded. It does not mean that the contract call executed on-chain. Sign and broadcast the transaction, then inspect the receipt from wallet/gettransactioninfobyid to determine the execution outcome.
The contract.parameter.value in the contract calling transaction contains the following content:
- owner_address: the caller address.
- contract_address: the contract address.
- data: the contract function selector and its parameters - the first 4 bytes are the contract function selector, which is the first 4 bytes of the result obtained by performing the Keccak-256 operation on the contract function name and parameters, and is used by the virtual machine to discover the function. The remaining bytes of data are parameters of the function. For more information about encoding and decoding, please refer to Parameter Encoding and Decoding.
- call_value: the amount of TRX sending to the smart contract.
- token_id: the ID of the TRC-10 token sending to the contract.
- call_token_value: the amount of the TRC-10 token sending to the smart contract.
triggerconstantcontract
Invoke the constant function of the contract through the Fullnode API wallet/triggerconstantcontract. Since this is a query operation and does not need to be chained, no signature or broadcasting is required:
BASE_URL=https://api.shasta.trongrid.io # example — replace with any TRON node (TronGrid, third-party, or self-hosted)
curl -X POST ${BASE_URL}/wallet/triggerconstantcontract -d '{
"contract_address":"419E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"balanceOf(address)",
"parameter":"000000000000000000000000977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB",
"owner_address":"41977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
Parameter description:
- contract_address: the contract address.
- owner_address: the caller address.
- function_selector: the triggered contract method.
- parameter: the parameters to be passed in the contract method. For more information about encoding and decoding, please refer to the chapter on parameter encoding and decoding.
This local simulation does not require a transaction-level fee_limit. It consumes no actual account resources, but it remains subject to node configuration and protective TVM execution limits.
Result:
{
"result": {
"result": true
},
"constant_result": ["0000000000000000000000000000000000000000000000000000000430e1b700"],
"transaction": {
"ret": [{}],
"visible": false,
"txID": "80773092048ecfab58ed48d0162dd0dcd6e22c7f7d98c3d4df6011b2aaef2fd3",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "70a08231000000000000000000000000977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb",
"owner_address": "41977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb",
"contract_address": "419e62be7f4f103c36507cb2a753418791b1cdc182"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "5ab1",
"ref_block_hash": "f24f075df912f43e",
"expiration": 1590382815000,
"timestamp": 1590382762536
},
"raw_data_hex": "0a025ab12208f24f075df912f43e4098cecfd1a42e5a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a1541977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb1215419e62be7f4f103c36507cb2a753418791b1cdc182222470a08231000000000000000000000000977c20977f412c2a1aa4ef3d49fee5ec4c31cdfb70a8b4ccd1a42e"
}
}constant_result: the result of querying the contract. In this example, the return value is of type uint256. For more information about how to encode and decode the return value, please refer to Parameter Encoding and Decoding.
Calling with data
In addition to directly inputting the function selector and parameters, you can also encode them into hexadecimal data according to the ABI specification. This encoded data is then concatenated and submitted as the data field.
Let's look at calling the standard TRC-20 transfer function on a smart contract. Typically, the function signature is transfer(address,uint256).
We want to transfer 100 tokens to the address TJRabPrwbZy45sbavfcjinPJC18kjpRTv8.
- Function Signature:
transfer(address,uint256) - Function Selector: the first 4 bytes of the Keccak-256 hash of
transfer(address,uint256). For this specific function, it's typicallya9059cbb. - Parameter Encoding:
- The address
TJRabPrwbZy45sbavfcjinPJC18kjpRTv8first converts to the 21-byte hexadecimal form415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb(0x41prefix plus 20 address bytes), then gets left-padded with 11 zero bytes to fit a 32-byte ABI slot. - The
uint256value100needs to be encoded as a 32-byte hexadecimal value.
- The address
The final data field is simply the concatenation of the function selector and the encoded parameters.
A typical data value for calling transfer(address,uint256) to send 100 tokens to TJRabPrwbZy45sbavfcjinPJC18kjpRTv8 is:
a9059cbb0000000000000000000000005cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb0000000000000000000000000000000000000000000000000000000000000064
In this example:
a9059cbbis the function selector fortransfer(address,uint256).0000000000000000000000005cbdd86a2fa8dc4bddd8a8f69dba48572eec07fbis the encoded value of the recipient addressTJRabPrwbZy45sbavfcjinPJC18kjpRTv8(represented in hexadecimal and padded to 32 bytes).0000000000000000000000000000000000000000000000000000000000000064is the encoded value of100(64for hexadecimal, padded to 32 bytes).
Complete Call:
BASE_URL=https://api.shasta.trongrid.io # example — replace with any TRON node (TronGrid, third-party, or self-hosted)
curl --request POST \
--url ${BASE_URL}/wallet/triggersmartcontract \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"data": "a9059cbb0000000000000000000000005cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb0000000000000000000000000000000000000000000000000000000000000064",
"fee_limit": 1000000000,
"call_value": 0,
"visible": true
}
'Result:
{
"result": {
"result": true
},
"transaction": {
"visible": true,
"txID": "ece1ed6a4dfe1743afccd0f13df891e0cc62328c42c4d9c095b941cd51c585bf",
"raw_data": {
"contract": [{
"parameter": {
"value": {
"data": "a9059cbb0000000000000000000000005cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb0000000000000000000000000000000000000000000000000000000000000064",
"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"
},
"type_url": "type.googleapis.com/protocol.TriggerSmartContract"
},
"type": "TriggerSmartContract"
}],
"ref_block_bytes": "8e6a",
"ref_block_hash": "9858ac3fec3262ff",
"expiration": 1747130115000,
"fee_limit": 1000000000,
"timestamp": 1747130056923
},
"raw_data_hex": "0a028e6a22089858ac3fec3262ff40b8c7c7c8ec325aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541fd49eda0f23ff7ec1d03b52c3a45991c24cd440e12154142a1e39aefa49290f2b3f9ed688d7cecf86cd6e02244a9059cbb0000000000000000000000005cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb000000000000000000000000000000000000000000000000000000000000006470db81c4c8ec3290018094ebdc03"
}
}Related resources
- Deploying — high-level deployment walkthroughs (TronIDE, TronBox, TronWeb)
- Interacting with contracts — read state and call methods
- Parameter encoding and decoding — encode the
datafield for HTTP API calls - FeeLimit & Energy cost — cost management guide
- Quickstart — TronBox CLI walkthrough
Updated 11 minutes ago