diff --git a/hooks/useEstimateGas.ts b/hooks/useEstimateGas.ts index afa64841a..ce356984d 100644 --- a/hooks/useEstimateGas.ts +++ b/hooks/useEstimateGas.ts @@ -13,20 +13,28 @@ export default function useEstimateGas() { async (request?: EstimateContractGasParameters) => { if (!publicClient) return; + const DEFAULT_L1_GAS = 555_555_555_555n; + let l1Gas = 0n; if (chain.id === optimism.id) { if (request) { const data = encodeFunctionData(request); - l1Gas = await publicClient.readContract({ - abi: l1GasPriceOracleABI, - address: '0x420000000000000000000000000000000000000F', - functionName: 'getL1Fee', - args: [data], - }); + + try { + l1Gas = await publicClient.readContract({ + abi: l1GasPriceOracleABI, + address: '0x420000000000000000000000000000000000000F', + functionName: 'getL1Fee', + args: [data], + }); + } catch (l1FeeError) { + l1Gas = DEFAULT_L1_GAS; + } } else { - l1Gas = 555_555_555_555n; + l1Gas = DEFAULT_L1_GAS; } } + const gasPrice = await publicClient.getGasPrice(); const gasUsed = request ? await publicClient.estimateContractGas(request) : 500_000n;