@@ -88,11 +88,11 @@ const signTransaction = async ({
88 const from = wallet.address;
88 const from = wallet.address;
89 const estimate = await estimateGasLimit({ ...txn, from }, web3);
89 const estimate = await estimateGasLimit({ ...txn, from }, web3);
91− let block = await web3.eth.getBlock('pending');
92+ (await web3.eth.getBlock('pending')) || (await web3.eth.getBlock('latest'));
93− // in case pending block doesn't return anything
94− if (!block || !block.baseFeePerGas) {
94+ if (!block?.baseFeePerGas) {
95− block = await web3.eth.getBlock('latest');
95+ throw new Error('Unable to fetch baseFeePerGas from the network');
98 const baseFeeWei = block.baseFeePerGas;
98 const baseFeeWei = block.baseFeePerGas;