0

I have written a program to send raw transactions via JSON-RPC. It seems to work for existing wallets, but I get this error when I try to send the very first transaction of a new wallet (nonce is zero). The wallet does have ether in it. If I try and set the nonce to 1, I get a different error: "already known". This answer seems to indicate that the transaction is already in the pool and I guess must be waiting for the transaction with nonce zero before executing the transaction with nonce one? But how do I send the transaction with nonce zero if the RLP encoding will always start with the nonce, which for a new wallet is zero?

Here is the encoded transaction:

0xF86B008501A13B8600825DC094354522A260DA80A8962A7588E0136E08AFD8762B87038D7EA4C68000001BA04995BC4DCD0EE35E50E69A261225E635DFD91D30CE074A6F77E4A293BB59A955A00B38EE600B63263A5C257968F2C1BC44A378621D58119DE70E6D4FDB71DF2862

If you use this site to decode the transaction you will see that the nonce is zero. Oddly though, the "from" address is NOT the actual address that it is being sent from. What relationship is there between the zero nonce and the "from" address? If I set the nonce to 1, it sends from the real address.

2
  • You are signing the nonce, so if you adjust the nonce you also need to recalculate the signature. Are you doing this? Could you say what is the expected from?
    – Richard
    Dec 23, 2021 at 9:28
  • @Richard The expected from is "0x41881b5397d3fec9c0f870a8af67308fb2bf1003". And this is how I'm encoding the RLP stuff (see RLP.cpp and main.cpp). I wonder if there is a bug in that code because sometimes it works but sometimes it doesn't. I have tried signing with that uECC library OR the libsecp256k1 library and both produce this error. I'm not sure what you mean by recalcuate the signature; but I do calculate the transaction twice (once without RSV, once with).
    – Kinjo
    Dec 23, 2021 at 17:03

1 Answer 1

0

I am not sure what is going on here but I am intrigued!

However, you can get past the 'Nonce is already known' error by adding MORE gas to the new transaction.

If you send 2 x TX with the same Nonce, the 1 with the highest gas fee will take over.

Add 10% gas and it should go through.

2
  • It's possible this is correct but in my code when I send a higher gas price the "from" field changes and so it thinks the sender doesn't have enough gas to send. There must be something wrong in my code. If I can get this to work I will let you know.
    – Kinjo
    Dec 23, 2021 at 17:14
  • That does sound bizarre. You need the private key of the wallet to sign and send the transaction so maybe a little extra scrutiny of the code will help! I wish you the best in getting to the bottom of it./. Let me know:)
    – johnashu
    Dec 23, 2021 at 22:09

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.