3

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?

5

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.

2

is the node keeping track of the nonce here?

Yes

do I have to keep track of the nonce myself?

Yes


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.

1
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 '18 at 1:32
  • 1
    yes but this doesn't take pending transactions into account. thus I have a risk of overwriting transactions – Daniel Gretzke Mar 29 '18 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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