EstimateEnergy

在已固化状态下,预估智能合约交易执行成功需要提供的能量

注意

  • 该接口默认为关闭状态,打开该接口需要节点配置文件中同时开启vm.estimateEnergyvm.supportConstant这两个配置项。
  • 虽然 triggerconstantcontract 接口可以预估链上绝大多数智能合约调用交易的能量消耗量,例如USDD、USDT、USDC、TUSD等。但 estimateEnery 接口, 相对于 triggerconstantcontract 接口,在给少数特殊合约预估能量消耗时会更准确,根据该接口返回的能量预估值设置的feelimit保证是足够的。但 estimateEnergy 是可选接口, 有些 FullNode 节点可能没有开启该接口,因此,如若调用 estimateEnergy 接口时捕获到节点不支持此功能的错误信息 (this node does not support estimate energy),建议继续使用 triggerconstantcontract 接口预估能量消耗。
  • estimateenergy不会产生上链交易,也不会改变当前节点的状态。
  • estimateenergy返回结果中的energy_required字段就是能量预估量,因此,交易的fee_limit可以设置为energy_required x 能量单价
  • parameter编解码参考示例:参数编码和解码
Language
Click Try It! to start a request and see the response here!