14

I've been running a local Rinkeby node (in order to use websocket events) which was working fine for a while, but suddenly I have been getting "Returned error: replacement transaction underpriced". I am sending 10x the average gas price and I'm still getting this error. Here are my calculations:

gwei = 1000000000
gas = 47000
gasPrice = gwei * 20

Only when I bump the gas price to (gwei * 2000) can I make a transaction (0.9 ether). This is causing me to run out of ether very quickly making development real hard.

Example tx:

{
  "nonce": "0x23",
  "chainId": 4,
  "to": "0xB92427792629A23E0b2deE37b3F92Ce4D4cB794c",
  "value": 0,
  "gas": "0xb798",
  "gasPrice": "0x4a817c800",
  "data": "0xce07c1787465737400000000000000000000000000000000000000000000000000000000"
}

Any help is much appriciated!

Geth Rinkeby Cmd:

geth --rpccorsdomain="*" --rinkeby --ws --wsport=8546 --wsorigins="*" --datadir=$HOME/.rinkeby --cache=512 --rpc --rpcapi="personal,eth,network,net,web3,db"  --rpcport=8545 --fast --bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303
M1Reeder
  • 692
  • 2
  • 7
  • 22
  • Are you trying to replace a pending transaction, or do you want to just issue a normal transaction? – carver Sep 21 '17 at 18:21

2 Answers2

23

Summary: Remove the nonce field

This answer assumes that you want to issue a new transaction, rather than replace a pending one.

What does the error mean?

"Returned error: replacement transaction underpriced"

The error means that:

  1. You have a pending transaction from your account in your Ethereum client
  2. The new transaction you are sending has the same nonce as that pending transaction
  3. The new transaction you sent has a gas price that is too small to replace the pending transaction

With geth, the replacement transaction must have a gas price greater than 10% of the gas price of the pending transaction.*

I'll assume that you want to issue a new transaction, rather than replace an existing, pending one. You can solve the problem by removing the nonce field. Your Ethereum client will automatically manage the nonce for you.

* This replacement price is not specified in the protocol. Different clients (and most importantly, miners), might apply different replacement rules.

I have another reason that I need to specify the nonce field

Then increment it by one every time you issue a new transaction. This will not play well with other processes connected to your Ethereum client, and try to replace them.

Ari Seyhun
  • 11,506
  • 16
  • 62
  • 109
carver
  • 2,229
  • 12
  • 28
  • 1
    Thank you! This error is a bit cryptic for its causes. Unfortunately, I am manually sending transactions using the `ethereumjs-tx` module which requires the `nonce`. Adding a timeout solved the problem. – M1Reeder Sep 22 '17 at 01:20
  • Also it could be that a pending transaction is stuck in the node – webjunkie Oct 02 '17 at 04:53
  • 1
    When I do this I get `Error: nonce too low`. @M1Reeder I am also using `ethereumjs-tx` where did you add the timeout? – mattgabor Jul 16 '18 at 18:15
  • 1
    greater than 10%,not 110% – Jim Green Aug 11 '18 at 06:33
  • @JimGreen the new price must be greater than 110% of the old price, or greater than 10% *more* than the old price – carver Aug 13 '18 at 17:16
  • 2
    @carver WRT "You can solve the problem by removing the nonce field. Your Ethereum client will automatically manage the nonce for you." — could you please point which line of code in Geth project that handle this? I wanted to learn more about it. Thanks. – Zulhilmi Zainudin Mar 19 '19 at 06:08
  • When I do this I get an error that says: `Transaction must include these fields: {'nonce'}`... Did I misunderstand? – dillon.harless Feb 17 '20 at 16:07
  • It depends on your client implementation @dillon.harless. According to the json-rpc spec, nonce is supposed to be optional https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction – carver Jun 01 '20 at 21:34
-2

try increase the 'gasPrice'. Ex:web3.toWei('25','gwei')

:)

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '22 at 15:56