I want to send raw transactions but I don't want to accidentally overwrite any transactions.

Afaik when using eth.sendTransaction it automatically increments the nonce and doesn't overwrite any transactions (is the node keeping track of the nonce here?). Now I have a script that sends raw transactions to a node (no account listed there for security reasons, obviously).

Is there a way to automatically append transactions without knowing the nonce or accidentally overwriting transactions? Or do I have to keep track of the nonce myself?

4 Answers 4


The nonce is part of the transaction data, so it contributes to the transaction hash, which is what you sign with the private key.

So you need to know the nonce you want to use before signing the transaction.


is the node keeping track of the nonce here?


do I have to keep track of the nonce myself?


All transactions must include an explicit nonce. (for now... See account abstraction discussions for the possibility of removing the nonce)

So for now, you must manually track the nonce and include it with the transaction.

const transactionCount = await web3.eth.getTransactionCount(<your-address>, 'pending');
const nonce = web3.toHex(transactionCount);
  • This is much more pratical than tracking manually the nonce!
    – btc4cash
    Mar 29, 2018 at 1:32
  • 1
    yes but this doesn't take pending transactions into account. thus I have a risk of overwriting transactions Mar 29, 2018 at 1:50

You MUST set the correct nonce parameter when sending raw transactions, otherwise your transaction would never be broadcasted.

visit this url to get latest nonce:



curl https://mainnet.infura.io/v3/YOUR-PROJECT-ID
    -X POST     
    -H "Content-Type: application/json"     
    -d '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params": ["0x7CCfaF74ADBA37b2eF11B4caa3ce37597074c45c","latest"],"id":1}'


{"jsonrpc":"2.0","id":1,"result":"0x396"}       # => 918 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.