Closed yanghang8612 closed 1 year ago
Finally, funciont_selector
can be skipped. So if implemented, only call_data
is needed to call the contract through HTTP interface?
The energy consumption of deploying a smart contract on shasta testnet equals that on mainnet right? Previously, I use this method to estimate.
Yes, the Shasta testnet and the Mainnet currently consume exactly the same amount of energy when deploying contracts with the same code.
Finally,
funciont_selector
can be skipped. So if implemented, onlycall_data
is needed to call the contract through HTTP interface?
Yes, if the contract is called by passing call_data
, then the parameter
will also not need to be passed.
Finally, we can estimate the energy consumption by calling smart contracts. Is the estimate accurate?
Is there any update, looking forward to this.
If I'm not mistaken, we can pass the call data
only and emit the function_selector
when calling a smart contract. In this way, somehow we can estimate the energy to be consumed based on that call data
?
So once call data
is passed, function selector
and other params would be ignored? It is a decent way to resolve the issue in HTTP.
Finally, we can estimate the energy consumption by calling smart contracts. Is the estimate accurate?
After GreatVoyage-v4.7.0.1(Aristotle), you can use /wallet/estimateenergy
to estimate the more accurate energy consumption.
Is there any update, looking forward to this.
If I'm not mistaken, we can pass the
call data
only and emit thefunction_selector
when calling a smart contract. In this way, somehow we can estimate the energy to be consumed based on thatcall data
?
Yes, passing call_data
or function_selector¶meter
is fine.
If you want to estimate energy consumption, you can use /wallet/estimateenergy
instead of /wallet/triggerconstantcontract
.
So once
call data
is passed,function selector
and other params would be ignored? It is a decent way to resolve the issue in HTTP.
Yes, that would be more user-friendly, especially for Ethereum-based developers.
Close this issue as it is implemented by GreatVoyage-v4.7.2. Check TIP detail at TIP-544 Check implementation PR at https://github.com/tronprotocol/java-tron/pull/5079
Note: We use data
instead of call_data
in implementation.
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
andparameters
fields, the user cannot interact with smart contracts by passingdata
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.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 inBASE58
format.Returns: unsigned transaction, data type is JSON string.
Example:
or
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
.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:
Backwards Compatibility
None.
Security Considerations
None.