Skip to main content

TriggerConstantContract

POST

Invoke the readonly function (modified by the view or pure modifier) of a contract for contract data query; or Invoke the non-readonly function of a contract for predicting whether the transaction can be successfully executed and estimating the energy consumption; or estimate the energy consumption of contract deployment
Path Parameters
chainstringrequired
Parameter specifying the target chain to query.
networkstringrequired
Parameter specifying the network of the target chain.
Request Body
owner_addressstringrequired
Transaction initiator address. (Format: Base58 or Hex)
contract_addressstring
Contract address. (Format: Base58 or Hex).Example: TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs
function_selectorstring
Function selector.Example: transfer(address,uint256)
parameterstring
ABI-encoded function parameters (Hex String).Example: 000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c
datastring
This field transmits the necessary data for smart contract interaction, including the function being called and its parameters. You may choose to use the data field, which contains the complete ABI-encoded information, or use the function_selector and parameter fields separately. Note that if both data and function_selector are present, the system will prioritize using the function_selector and parameter fields for the contract interaction.
call_valueinteger
Amount of TRX transferred into the contract. (Unit: sun)
call_token_valueinteger
Amount of TRC-10 token transferred into the contract.
token_idinteger
TRC-10 token id
visibleboolean
Optional. Set to true to format addresses in Base58; set to false for hex format. (Default: false)
Responses
resultobject
Run result, for detailed parameter definition, refer to EstimateEnergy
energy_usedinteger
Total energy consumption, including basic and penalty energy consumption.
energy_penaltyinteger
Penalty Energy consumption.
constant_resultarray
List of results from a constant contract call.
transactionobject
Transaction object, see GetTransactionByID for structure.
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": "400"
}
cURL
curl -X POST 'https://tron-mainnet.nodit.io/wallet/triggerconstantcontract' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: nodit-demo' \
-d '{
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"function_selector": "transfer(address,uint256)",
"parameter": "000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c"
}'