1

We have been developing a dapp which submits a very basic transaction (placing a short hash and some Eth into a contract). We set the gas relatively high (250000). Often the transaction is mined in good time, within a minute, which is just about tolerable to a waiting user. Sometimes, however, it is very long, occasionally threatening to take hours according to Etherscan.

We have considered e.g. Gas price strategy, but we can't quite see how that would deal with these strange delays.

What can we do to overcome this?

Is there a good description for how to do this?

2

Miners choose to include transaction by being financially motivated to do so. This means that they will create the blocks which are most valuable for them, and this simply means that they will pick the transactions that pay the highest gas price.

The gas price required to have a transaction included in a block depends on how busy the network is. To see how expensive it is to have a transaction included in a block, you can check out Eth Gas Station and set the gas price to the Gas Price SafeLow (Gwei) value rounded up to the nearest gwei. If you want faster confirmation than five minutes, you may have to set the value to what you can find under Recommended Gas PricesFast (<2m). This latter value is often significantly higher than the SafeLow value.

You can also get an estimate for the gas price by making an API call to an Ethereum node. You can use public Ethereum nodes that accept calls from anywhere, or you can run your own node. According to the documentation the call web3.eth.gasPrice returns the median gas price for the latest x blocks. Rounding this number up or multiplying it with a number above 1 will ensure that your transactions are mined faster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.