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.
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.
Just increase gasPrice and gasLimit. For example
gasPrice: 400000000000, gasLimit: 4000000,
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.