Support a 'gas multiplier' which can be used to increase gasLimit #2722
Replies: 3 comments 6 replies
-
I was just thinking the same thing. Here's a makeshift version I am using for my current project where the user sets 'speedyTx' true in local storage upon connecting their wallet to the dapp.
|
Beta Was this translation helpful? Give feedback.
-
I haven’t heard of this before in other libraries, but is definitely something I used to do manually before in some of my old projects. I changed this tactic to instead include the But can you link to the docs for the multiplier in the other projects that do this? One concern I have are using IEEE 754 decimal numbers, which would mean rounding, but since it’s an approximation, this is likely fine, but I’d like to see how and when other projects are using this. :) |
Beta Was this translation helpful? Give feedback.
-
@JasperTimm You can simply extend the provider class to add a gas multiplier. Then you can just use this provider wherever in you code and it should have the multiplier. class JsonRpcProviderWithIncreasedGasLimit extends JsonRpcProvider {
async estimateGas(transaction) {
const actualResult = await super.estimateGas(transaction);
return actualResult * 2;
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
Other libraries like Truffle and Web3 support a 'gas multiplier', so that the default gasLimit sent to the provider is:
gasLimit = gasEstimate * GAS_MULTIPLIER
(1.25 for Truffle and 1.5 for Web3 by default I believe, but they can be set)
Are there plans for ethers to support something like this? I have a few transactions which use a few proxy calls to other contracts and the estimate is sometimes not enough, hence the reason for being able to uniformly increase the suggested gas across all transactions.
Beta Was this translation helpful? Give feedback.
All reactions