首页 > 解决方案 > “nonce”总是返回 0

问题描述

"web3.eth.getTransaction(address)"以前做交易。

之后,它无法正常工作

"节点错误:{"code":-32000,"message":"nonce too low"}"

在检查 nonce 值后,它总是返回 0。

我用

这是我的代码。

web3.eth.getTransactionCount(senderAddr, 'pending').then(function(count) {
      count += 1;
      var transactionObject = {
        nonce: web3.utils.toHex(count.toString(16)),
        from: sender,
        to: receiver,
        gasPrice: web3.utils.toHex(15000),
        value: web3.utils.toHex(web3.utils.toBN(web3.utils.toWei(amount.toString(), 'ether'))),
        data: '',
        chainId: 3
      }
    }

我该如何解决?

请帮助我...谢谢

标签: javascriptblockchainweb3

解决方案


如果在本地区块链中,你用来部署合约的地址之前没有被使用过,你会得到 nonce 0。


推荐阅读