create account

波场上如何计算矿工费 / 学习智能合约#40 by lemooljiang

View this thread on: hive.blogpeakd.comecency.com
· @lemooljiang ·
$7.14
波场上如何计算矿工费 / 学习智能合约#40
在以太坊上有个专门的函数来计算矿工费`web3.eth.estimateGas`,这样在调用合约前可以有效地设置gas的上限,矿工费等于 gas * gasPrice。那么, 波场上如何计算矿工费呢?

查了波场的手册半天,没有查到`estimateGas`这个类似的函数,也就是说,在调用合约前是没办法计算出要消耗多少能量的。只有调用后在tronscan上查交易记录才能得出!这多少有点事后诸葛亮的意思。

![trongas.jpg](https://steemjiang.com:8081/ipfs/QmRvFMCFUV4Ge7NsaRbFCs16ia4Gf61nyEWmZmCjCFX5xL)

以nutbox中的withdrawPeanuts()为例,这步调用消耗了88236个能量。

![trongas2.jpg](https://steemjiang.com:8081/ipfs/QmUxRN2auV9oMFWg2C3zx37Agx2BWNEUxisFGW8HoE5Xis)

https://tronscan.org/#/proposals

在超级节点的提案中`1 ENERGY的费用为 0.00014 TRX`。计算下:矿工费等于 能量 * 能量价格 = 88236*0.00014 = 12.35304 trx, 和tronscan中的一致!

在波场中计算矿工费只能调用后才能知道,不知这算不算是个坑点呢!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorlemooljiang
permlink5ovmxr-40
categoryhive-105017
json_metadata{"tags":["smartcontract","cn","gas","energy","tron"],"image":["https://steemjiang.com:8081/ipfs/QmRvFMCFUV4Ge7NsaRbFCs16ia4Gf61nyEWmZmCjCFX5xL","https://steemjiang.com:8081/ipfs/QmUxRN2auV9oMFWg2C3zx37Agx2BWNEUxisFGW8HoE5Xis"],"links":["https://tronscan.org/#/proposals"],"app":"hiveblog/0.1","format":"markdown","description":"在波场中计算矿工费只能调用后才能知道,不知这算不算是个坑点呢!","author":"lemooljiang"}
created2021-03-01 12:33:27
last_update2021-03-01 12:33:27
depth0
children0
last_payout2021-03-08 12:33:27
cashout_time1969-12-31 23:59:59
total_payout_value3.710 HBD
curator_payout_value3.431 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length616
author_reputation438,608,506,193,732
root_title"波场上如何计算矿工费 / 学习智能合约#40"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id102,126,015
net_rshares16,763,092,436,657
author_curate_reward""
vote details (36)