Error: the tx doesn't have the correct nonce.TestRPC/Ganache无法获取nonce

简介: 做一个truffle相关的项目,每次尝试创建交易时,总会有以下的一个错误提示:the tx doesn’t have the correct nonce 完整的一般是这样:Error: the tx doesn't have the correct nonce.

做一个truffle相关的项目,每次尝试创建交易时,总会有以下的一个错误提示:

the tx doesn’t have the correct nonce

完整的一般是这样:

Error: the tx doesn't have the correct nonce. account has nonce of: 14 tx has nonce of: 0

开发环境:

  • Truffle v3.4.7
  • Solidity v0.4.13
  • Npm v5.3.0
  • TestRPC v4.0.1 (Ganache)
  • Metamask v3.9.5

网上查阅并阅读了许多与nonce获取相关的文章,似乎导致这个获得nonce问题的原因,是找不到先前交易的nonce来hash生成新交易的nonce

解决办法:

可以尝试通过你的MetaMask重新连接的Test-RPC:
- 1.选择Main Ethereum Network或者是Localhost 8545以太坊的其他任何网络。
- 2.然后再次选择Localhost 8545

在停止和启动一个新的TestRPC节点之后,大部分情况下可以解决这个问题。

如果还不行那就用MetaMask中的Reset Account按钮,这个按钮擦除当前帐户的交易历史记录,用于计算常用账户的nonce。

注意:正常用户不适用这个特性。

这个只对于重置测试网络并希望继续使用同一帐户的开发人员来说是有用的,这样能使MetaMask相信这个网络ID是新状态下的干净网络。

对于用truffle 4+做truffle开发的用户来说,可能要重新装一下MetaMask。

原文:http://cw.hubwiz.com/card/c/ethereum-FAQ/1/2/1/

另外推荐一些之前的教程:

  • python以太坊,主要是针对python围绕web3.py进行区块链以太坊应用开发的讲解。
  • web3j,主要是针对java和android程序员围绕web3j库进行区块链以太坊开发的讲解。
  • php以太坊,主要是介绍使用php进行智能合约开发交互,进行账号创建、交易、转账、代币开发以及过滤器和事件等内容。
  • 以太坊开发,主要是介绍使用node.js、mongodb、区块链、ipfs实现去中心化电商DApp实战,适合进阶。
  • 以太坊教程,主要介绍智能合约与dapp应用开发,适合入门。
相关文章
GenImageInterleaved Wrong type of control parameter 1
GenImageInterleaved Wrong type of control parameter 1
|
10月前
|
程序员 Go API
译|Don’t just check errors, handle them gracefully(一)
译|Don’t just check errors, handle them gracefully
52 0
|
10月前
|
Java Go API
译|Don’t just check errors, handle them gracefully(二)
译|Don’t just check errors, handle them gracefully(二)
63 0
|
11月前
|
Java Maven
An attempt was made to call a method that does not exist. The attempt was made from the following
An attempt was made to call a method that does not exist. The attempt was made from the following
256 0
abort: error: Temporary failure in name resolution
abort: error: Temporary failure in name resolution
150 0
成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]
成功解决ValueError: Found input variables with inconsistent numbers of samples: [86, 891]
如何处理错误消息Unable to install breakpoint due to missing line number attributes
如何处理错误消息Unable to install breakpoint due to missing line number attributes
160 0
如何处理错误消息Unable to install breakpoint due to missing line number attributes
is transfer = C ( only read dynamically) not supported in one order scenario
is transfer = C ( only read dynamically) not supported in one order scenario
102 0
is transfer = C ( only read dynamically) not supported in one order scenario
Error saving your changes: Description control characters are not allowed
在修改 GitHub 上的仓库描述时出现此提示信息:Error saving your changes: Description control characters are not allowed 开始以为是 Fork 来的没有修改权限,但之前没有遇到这样的情况,提示信息说的也不是这个意思。
2345 0