EstimateEnergy

估算合约调用 / 部署所需的能量——返回的 energy_required 需按当前能量单价换算为 fee_limit

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

估算合约调用 / 部署所需的能量。energy_required 的单位是 Energy,而交易中的 fee_limit 单位是 sun,不能直接赋值。基础换算关系为:

fee_limit(sun)= energy_required × getEnergyFee(sun/Energy)

getEnergyFee 是可由治理修改的链参数,应通过 wallet/getchainparameters 查询当前值。生产交易还应为估算与上链之间的状态变化、动态能量因子变化保留合理余量,并确保结果不超过链参数 getMaxFeeLimit

⚠️

节点默认关闭

本接口在节点上默认未启用——需要在节点配置文件中同时设置 vm.estimateEnergy = truevm.supportConstant = true 才能调用。公共 RPC(含 TronGrid)是否支持取决于运营方配置。

📘

能量估算接口选择

与 TriggerConstantContract 的选择。大多数主流合约(USDD、BTT、TUSD 等)用 TriggerConstantContract 估算能量已经足够;少数特殊合约(如分支逻辑依赖链上状态的合约)下,EstimateEnergy 的结果可能更接近实际消耗。估算基于调用时的链上状态,不保证交易上链时一定成功。


相关资源

Body Params
string
required

交易发起方地址。(格式:Base58 或 Hex)

string

合约地址。(格式:Base58 或 Hex)
示例:TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs

string

函数选择器。
示例:transfer(address,uint256)

string

ABI 编码的函数参数(Hex 字符串)。
示例:000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c

string

该字段传递智能合约交互所需的 data,包括被调用的函数及其参数。您可以选择使用包含完整 ABI 编码信息的 data 字段,也可以分别使用 function_selectorparameter 字段。请注意,若 datafunction_selector 同时存在,系统将优先使用 function_selectorparameter 字段进行合约交互。

int64

转入合约的 TRX 数量。(单位:sun)

int64

转入合约的 TRC-10 Token 数量。

int64

TRC-10 Token ID。

boolean
Defaults to true

可选。设为 true 时地址以 Base58 格式返回;设为 false 时以 Hex 格式返回。(默认值:false

Responses

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json