Rinkeby: "replacement transaction underpriced"
Asked Answered
H

2

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
Hafer answered 21/9, 2017 at 16:47 Comment(1)
Are you trying to replace a pending transaction, or do you want to just issue a normal transaction?Luganda
L
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.

Luganda answered 21/9, 2017 at 18:38 Comment(8)
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.Hafer
Also it could be that a pending transaction is stuck in the nodeGnaw
When I do this I get Error: nonce too low. @Hafer I am also using ethereumjs-tx where did you add the timeout?Skip
greater than 10%,not 110%Newsreel
@JimGreen the new price must be greater than 110% of the old price, or greater than 10% more than the old priceLuganda
@Luganda 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.Equinoctial
When I do this I get an error that says: Transaction must include these fields: {'nonce'}... Did I misunderstand?Zeus
It depends on your client implementation @dillon.harless. According to the json-rpc spec, nonce is supposed to be optional github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransactionLuganda
S
-2

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

:)

Sonnier answered 8/1, 2022 at 12:36 Comment(1)
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.Simar

© 2022 - 2024 — McMap. All rights reserved.