Was wondering if anyone has come across this before. I am using Ropsten through Infura and no matter what I set the gas to it will always return either transaction underpriced or exceeds block gas limit.

  • 1
    It sounds like the function you're calling uses too much gas. What are you trying to call? Sep 12, 2017 at 19:28
  • When you say "no matter what I set the gas to", that's vague because there's gas price and gas limit. Which one are you changing? What are the current values? What are you calling? There isn't enough information here to diagnose anything. Nov 14, 2017 at 15:52

4 Answers 4


Check the gas limit of the most recently mined block( you can find this from etherscan home page for Ropsten in your case). Set the gas limit closer to that. Then decrease the gas price. For me it worked when gas price was set to 10 Gwei but it could vary.


Just increase gasPrice and gasLimit. For example

gasPrice: 400000000000,
gasLimit: 4000000,

I had this problem recently but it was my own error. Here's how to debug it.

First let's deal with the "transaction underpriced" error. Call web3.eth.getBalance(address,console.log).

Does the address you are sending from have the balance you expect? If not, you may be connected to a mainnet node, or you may have sent Ether to this address on the wrong network. You may just need to visit the Ropsten faucet to get coins.

Now you have the upper bound for your gas*gasPrice + value that will throw the transaction underPriced error.

Second, Web3 has some helper functions like estimateGas (returns Wei) and getGasPrice (returns Gwei) that will help you determine the best gas settings for your contract. Multiply the returned gas price by 1.5. Use the function web3.utils.toWei to convert your address balance, gasPrice, and value to Wei. Remember to set "Gwei" as the second argument for the gasPrice in toWei

Now you have all your details in Wei. Is gas*gasPrice + value < addressBalance? Do you still get the exceeds block gas limit? The 1.5 multiplier was necessary for this to work for me.


JSONRPC doesn't require gasLimit or gasPrice by default. But if these fields are not set correctly, transaction underpriced error is occured. Because default gasPrice and gasLimit is too low. In my case, I encoded params twice. The signed result was valid JSONRPC format, but there's no field about gasLimit or gasPrice. Check your signed result using ethereum-tx-decoder. It will give you some insight.

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.