我是Ethereum的初学者,需要指导,请帮助我运行一个私有的ethereum网络,使用迷雾钱包,这里是我的合同代码
pragma solidity ^0.4.0;
contract MyFirstContract {
uint256 counter =0;
function increase() public {
counter++;
}
function decrease() public{
counter--;
}
function getCounter() public constant returns (uint256) {
return counter;
}
}当我按execute increment或decrement函数时,计数器值没有变化,经过多次尝试,我得到了这些错误消息,我得到了错误消息“Error from sendSignedTransaction: Error: Returned error: replacement transaction underpriced”,经过一些研究发现,答案是错误:重置交易定价过低,我有一个待处理的事务。
web3.eth.pendingTransactions();
[{
blockHash: null,
blockNumber: null,
from: "0x4f7f384236f79a5e3322e33cc7bb2ccd5143a87c",
gas: 188189,
gasPrice: 18000000000,
hash: "0x193d30297d98ad9da5958e6295d61bf333050cec901601ccdbf83e9c0b1cb082",
input: "0x60806040526000805534801561001457600080fd5b5060ea806100236000396000f30060806040526004361060525763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313bdfacd81146057578063d732d95514607b578063e8927fbc14608f575b600080fd5b348015606257600080fd5b50606960a1565b60408051918252519081900360200190f35b348015608657600080fd5b50608d60a7565b005b348015609a57600080fd5b50608d60b3565b60005490565b60008054600019019055565b6000805460010190555600a165627a7a7230582094d5704152e41ee1cb7ab5b820a49845ec5652e2c9c442a8d55da756f6d5cda60029",
nonce: 10,
r: "0x34fa67311a0a29d31139a425c2ab120033d4ab34a6d1a860d6c806f95412f7af",
s: "0x7d831f773e541f73a2371be911ec29b36d803db414ab4712007c4b00d4f10be9",
to: null,
transactionIndex: 0,
v: "0x1b",
value: 0
}]所以我增加了web3.eth.getTransactionCount("0x4f7f384236f79a5e3322e33cc7bb2ccd5143a87c")+1;11
之后,我再次尝试超越事务,但是再次获得这些消息。

发布于 2018-07-07 08:59:57
非are是0索引的,事务是从1索引的。这里提到的这帖子:
很明显现在有个细微差别..。我的错误是,我将nonce设置为web3.eth.getTransactionCount() + 1,这在以前的事务名和下一个事务名之间留下了空白(nonces是0索引的,事务是从1索引的,这是错误的根源)。因此,似乎不允许您将当前值增加2,并留下空白。一定是顺序的。
请求说明:您需要找出第一个事务的当前值。
var firstNonce = web3.eth.getTransactionCount(yourSender);.我在上面链接的帖子和这里展示了如何手动设置当前值(还有一个常见的错误,即getTransactionCount已经返回一个比当前值高的值,这是我回答的原因)。
https://ethereum.stackexchange.com/questions/52861
复制相似问题