You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
web3.eth.getTransactionCount(myAddress).then(function(lastCountOfTransaction){
console.log(lastCountOfTransaction);
var rawTransaction = {
"from": myAddress,
"nonce": '0x' + lastCountOfTransaction.toString(16),
"gasPrice": web3.utils.toHex(15 * 1e9), //1 can be changed to n gwei
"gasLimit": web3.utils.toHex(250000), // 1000000 can be to set to any n number
"to": ContractAddress,
"value": "0x0",
"data": ContractObject.methods.transfer(userAddress,noOfTokens).encodeABI(),
"chainId": chainId
};
var tx = new Tx(rawTransaction);
tx.sign(privKey);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'),function(err,hash){
but I am getting error as nonce too low.
When I console few things it gives me the following.
transfer token value 50
lastCountOfTransaction : 52
{ from: '0x1f0CDd8764443c66A9C8064297.........',
nonce: '0x34',
gasPrice: '0x37e11d600',
gasLimit: '0x3d090',
to: '0x3475B73b0b8c638BB5f8A405e5..........',
value: '0x0',
data: '0xa9059cbb00000000000000000000000045559a79195b5e16eb92694abd7eee2eb4b6507b0000000000000000000000000000000000000000000000000000000000000032',
chainId: 1 }
I am using web3js 1.0.0.^34 beta version of web3js and provider as infura main net.