javascript - “nonce”总是返回 0
问题描述
我"web3.eth.getTransaction(address)"
以前做交易。
之后,它无法正常工作
"节点错误:{"code":-32000,"message":"nonce too low"}"
在检查 nonce 值后,它总是返回 0。
我用
- 操作系统
- 节点 v8.10.1
- web3 3.5.2
- 网络罗普斯滕
- ropsten/ether 中的地址 0xDff27954C1Cf3C5b2081ac45505d3c9205a410d1
这是我的代码。
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
}
}
我该如何解决?
请帮助我...谢谢
解决方案
如果在本地区块链中,你用来部署合约的地址之前没有被使用过,你会得到 nonce 0。
推荐阅读
- node.js - 使用节点 js 将文件写入远程服务器
- c# - Angular / ASP.NET Core 2.1 CORS 问题
- c++ - 为什么在 CMake 配置和生成完成后使用 CLion 构建 OpenCV 时会出现错误?
- elixir - 在 Ecto 中自定义主键自动生成功能?
- amazon-web-services - ECS 集群在使用 EC2 时无法在私有子网中运行任务
- javascript - 如何在不知道键父名称的情况下从 JSON 接收值?
- python - 如何在 Maya 中创建列表颜色集、访问它们并删除它们?
- node.js - NodeJS 在编译时似乎运行了一个导出的函数——为什么?
- typescript - Ionic3 cordova 模拟 android
- javascript - 如何使用 node.js 创建要在 Angular 应用程序和服务器上使用的 javascript 库