Description
Dear MetaMask Team,
I noticed the function getGas:
async function getGas(
request: UpdateGasRequest,
): Promise<[string, TransactionMeta['simulationFails']?, string?]> {
const { isCustomNetwork, chainId, txMeta } = request;
if (txMeta.txParams.gas) {
log('Using value from request', txMeta.txParams.gas);
return [txMeta.txParams.gas, undefined, txMeta.txParams.gas];
}
if (await requiresFixedGas(request)) {
log('Using fixed value', FIXED_GAS);
return [FIXED_GAS, undefined, FIXED_GAS];
}
const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(
txMeta.txParams,
request.ethQuery,
);
if (isCustomNetwork || simulationFails) {
log(
isCustomNetwork
? 'Using original estimate as custom network'
: 'Using original fallback estimate as simulation failed',
);
return [estimatedGas, simulationFails, estimatedGas];
}
const bufferMultiplier =
GAS_BUFFER_CHAIN_OVERRIDES[
chainId as keyof typeof GAS_BUFFER_CHAIN_OVERRIDES
] ?? DEFAULT_GAS_MULTIPLIER;
const bufferedGas = addGasBuffer(
estimatedGas,
blockGasLimit,
bufferMultiplier,
);
return [bufferedGas, simulationFails, estimatedGas];
}
I appreciate the use of gas buffering in this function as it helps improve the chances of transaction acceptance. However, I noticed that when adding a custom network, there is currently no option to configure a gas buffer or even apply one to the gas limit. This creates challenges for platforms that integrate with MetaMask but don’t estimate gas or add a buffer before sending transactions to the extension. As a result, many integrations fail, leading to a suboptimal user experience.
I believe it would significantly enhance usability if MetaMask allowed users to configure gas buffering as part of the custom network setup. This could be either:
A toggle to enable gas buffering for a specific network in the network setup.
An option in the advanced network settings to apply a configurable buffer multiplier.
I understand that some networks already buffer gas during the estimateGas RPC call, and the behavior can vary between networks. However, enabling this feature at the user or network level would reduce the need for manual gas limit adjustments, saving users 2-3 extra clicks every time they edit the gas limit for transactions, also it can be disabled by default.
I hope you find this feedback constructive and consider introducing these options to further improve the user experience.
Thank you for your time and effort in building an amazing platform. I look forward to seeing how MetaMask continues to evolve!