5 用ethers给合约函数发送交易请求

sendTransaction函数怎么使用? image.png

这个里面的transactionRequest是我下面的这个overrides嘛?

// All overrides are optional
let overrides = {

    // The maximum units of gas for the transaction to use
    gasLimit: 23000,

    // The price (in wei) per unit of gas
    gasPrice: utils.parseUnits('9.0', 'gwei'),

    // The nonce to use in the transaction
    nonce: 123,

    // The amount to send with the transaction (i.e. msg.value)
    value: utils.parseEther('1.0'),

    // The chain ID (or network ID) to use
    chainId: 1

};

这里面的nonce是怎么拿到的? 主要业务是想用ethers给合约里面的函数发送请求并附带金额,有相关的DEMO嘛? 看了一圈找到类似 但是还是不懂怎么下手写

请先 登录 后评论

最佳答案 2022-03-16 15:34

nonce 你可以不用填写,会有默认值。

这个值是地址所发起的交易数量,可以使用 getTransactionCount 来获得。

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,2219 浏览
  • steel 提出于 2022-03-15 00:03