Ethereum 一些交易通过联系人同时进行
我同时通过联系人发送一些交易。但block执行其中一个事务,因为两个事务具有相同的nonce(我从getTransactionCount获得)。我怎样才能修好它 每次创建事务时,我都使用此代码:Ethereum 一些交易通过联系人同时进行,ethereum,web3js,Ethereum,Web3js,我同时通过联系人发送一些交易。但block执行其中一个事务,因为两个事务具有相同的nonce(我从getTransactionCount获得)。我怎样才能修好它 每次创建事务时,我都使用此代码: var token = web3.eth.contract(config.contract.abi).at(config.contract.address); var payloadData = token.transfer.getData(address, amount); gasPrice = w
var token = web3.eth.contract(config.contract.abi).at(config.contract.address);
var payloadData = token.transfer.getData(address, amount);
gasPrice = web3.eth.gasPrice;
gasPriceHex = web3.toHex(gasPrice);
gasLimitHex = web3.toHex(gaslimit);
console.log('Current gasPrice: ' + gasPrice + ' OR ' + gasPriceHex);
nonce = web3.eth.getTransactionCount(config.account.address);
nonceHex = web3.toHex(nonce);
console.log('nonce (transaction count on fromAccount): ' + nonce + '(' + nonceHex + ')');
var rawTx = {
nonce: nonceHex,
gasPrice: gasPriceHex,
gasLimit: gasLimitHex,
to: config.contract.address,
from: config.account.address,
value: '0x00',
data: payloadData
};
var tx = new Tx(rawTx);
tx.sign(Buffer.from(config.account.privateKey, 'hex'));
var serializedTx = tx.serialize();
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function (err, hash) {
if (err) {
console.log(err);
console.log(hash);
}
});
欢迎来到Stackoverflow。请告诉我们,到目前为止你已经尝试了什么。我已经在我的帖子中添加了代码。