tip-544.md
April 3, 2025 ยท View on GitHub
tip: 544
title: Add `data` to the http interfaces interacting with smart contract
author: yanghang8612@163.com
status: Final
type: Standards Track
category: Interface
created: 2023-05-15
Simple Summary
This TIP is designed to optimize the http interfaces interacting with smart contract in order to make them more user-friendly.
Abstract
The http interfaces interacting with smart contract must pass the function_selector and parameters fields, the user cannot interact with smart contracts by passing data directly.
Meanwhile it is not possible to estimate the energy consumption for creating smart contract transactions through the http interfaces.
Specifications
wallet/triggersmartcontract
User can call this API to read/write the smart contract.
Params:
owner_address- Required. Account address.contract_address- Required. Contract address.call_value- Optional. The amount of TRX transferred into the contract.call_token_value- Optional. The amount of TRC-10 transferred into the contract.token_id- Optional. The token id of TRC-10 transferred into the contract.function_selector- Optional (Used to be required). The signature of the function (liketransfer(address,uint256)).parameter- Optional. Parameter encoding needs to be in accordance with the ABI rules.- New!
data: Optional. The data passed along with a transaction that allows us to interact with smart contracts. fee_limit- Required. Maximum TRX consumption, measured in SUN.permission_id- Optional. For multi-signature transactions.visible- Optional. Whehter the address is inBASE58format.
Returns: unsigned transaction, data type is JSON string.
Example:
curl --request POST \
--url https://api.shasta.trongrid.io/wallet/triggersmartcontract \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"function_selector": "balanceOf(address)",
"parameter": "000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
"visible": true
}
'
or
curl --request POST \
--url https://api.shasta.trongrid.io/wallet/triggersmartcontract \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"data": "70a08231000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
"visible": true
}
'
wallet/triggerconstantcontract
User can call this API to read or simulate writing the smart contract.
Params:
owner_address- Same aswallet/triggersmartcontract.contract_address- Optional (Used to be required). If this parameter is not empty, then it means that the user wants to interact with the smart contract. Otherwise, it means that the user is trying to deploy a smart contract usingdata.call_value- Same aswallet/triggersmartcontract.call_token_value- Same aswallet/triggersmartcontract.token_id- Same aswallet/triggersmartcontract.function_selector- Optional (Used to be required). Same aswallet/triggersmartcontract.parameter- Same aswallet/triggersmartcontract.- New!
data: Optional. The data passed along with a transaction that allows us to interact with smart contracts. visible- Same aswallet/triggersmartcontract.
Returns:
result- Run result.energy_used- Energy consumed during execution.constant_result- Result list of tiggered functions.transaction- Transaction information.
wallet/estimateenergy
User can call this API to estimate the energy consumption of smart contract transactions.
Params:
Same as wallet/triggerconstantcontract
Returns:
- result - Run result.
- energy_required - Energy consumption.
Backwards Compatibility
None.
Security Considerations
None.
Copyright
Copyright and related rights waived via CC0.