【问题标题】:How to get the minimum gas price on RSK with web3.js?如何使用 web3.js 获得 RSK 的最低 gas 价格?
【发布时间】:2021-04-08 06:56:23
【问题描述】:

我正在使用 web3.js 来获得最低 gas 价格,但以下方法不起作用:

web3.eth.getBlock('latest').minimumGasPrice

我该怎么做?

【问题讨论】:

    标签: rpc web3 rsk


    【解决方案1】:

    您可以像这样使用 web3.js 做到这一点:

    const block = await web3.eth.getBlock('latest');
    const minimumGasPrice = block.minimumGasPrice;
    

    注意getBlock()涉及网络请求, 因此需要await

    您的问题只询问了一种在 Javascript 中执行此操作的方法, 但是如果你想使用 终端命令 来做同样的事情, 如果您还没有这样做, 查看这个类似问题的答案: How to calculate what gas price to use for transactions on RSK?

    注意:如果您来自以太坊开发, 此 RPC 响应中的 minimumGasPrice 字段仅限 RSK - 不要对以太坊抱有同样的期望。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-11
      • 2015-09-16
      • 2022-08-04
      • 2021-11-04
      • 2019-01-16
      • 2014-03-06
      • 1970-01-01
      • 2017-03-16
      相关资源
      最近更新 更多