Hi i face error gas insufficient while try to approve usdc on Arbitrum my wallet have eth around 0.005 ETH why not enought for L2?

const { Web3 } = require('web3');

// Set up your Web3 provider and wallet information
const web3 = new Web3(process.env.RPC_URL_ARB); // Replace with your Ethereum node URL
const fromAddress = '0xe98bF5be1C897bF130bF077EeE64226d4bc604F8'; // Replace with your wallet address
const privateKey = process.env.privateKey; // Replace with your private key

// Define the ERC-20 token address and the amount you want to approve
const usdcTokenAddress = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'; // Replace with your USDC token address
const approvalAmount = '1'; // Replace with the amount you want to approve

// Create a Web3 contract instance for the ERC-20 token
const erc20ABI = require('./protocol/aave/usdce.json');

const usdcContract = new web3.eth.Contract(erc20ABI, usdcTokenAddress);

// Approve the spending by calling the 'approve' function on the ERC-20 token contract
const spenderAddress = process.env.AAVE_POOL_CONTRACT_ARB; // Replace with the address of the contract you want to approve

(async () => {
  // Convert the approval amount to the token's smallest unit (considering decimals)
  const decimals = await usdcContract.methods.decimals().call();
  const multiplier = BigInt(10) ** BigInt(decimals);
  const approvalAmountWei = BigInt(approvalAmount) * multiplier;
  // Build the transaction data
  const data = usdcContract.methods.approve(spenderAddress, approvalAmountWei.toString());

  try {
    // Send the transaction
    const gasLimit = 100000; // Adjust the gas limit if needed
    const gasPrice = '1000000000'; // Adjust the gas price if needed
    const gasPriceWei = web3.utils.toWei('10', 'gwei');
    const nonce = await web3.eth.getTransactionCount(fromAddress);
    const txObject = {
      to: usdcTokenAddress,
      data: data.encodeABI(),
      gas: web3.utils.toHex(gasLimit),
      gasPrice: web3.utils.toHex(gasPriceWei),
      nonce: web3.utils.toHex(nonce),

    const signedTx = await web3.eth.accounts.signTransaction(txObject, privateKey);
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);

    console.log('Approval successful. Transaction Hash:', receipt.transactionHash);
  } catch (error) {
    console.error('Error during approval:', error);

error here

Node.js v18.15.0
PS C:\Users\ASUS\Documents\liquidless-auto-repay-client> node .\approve.js
Error during approval: TransactionRevertInstructionError: Transaction has been reverted by the EVM
    at C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\utils\get_transaction_error.js:48:21
    at Generator.next (<anonymous>)
    at C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\utils\get_transaction_error.js:24:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\utils\get_transaction_error.js:20:12)
    at getTransactionError (C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\utils\get_transaction_error.js:33:12)
    at Object.<anonymous> (C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\rpc_method_wrappers.js:441:100)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\ASUS\Documents\liquidless-auto-repay-client\node_modules\web3-eth\lib\commonjs\rpc_method_wrappers.js:21:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  innerError: undefined,
  reason: 'err: insufficient funds for gas * price + value: address 0xe98bF5be1C897bF130bF077EeE64226d4bc604F8 have 5289780256737969 want 5946492766833840681701790400000 (supplied gas 100000)',
  signature: undefined,
  receipt: undefined,
  data: undefined,
  code: 402

2 Answers 2


Try to remove your toHex conversion an pass it the string directly. I suspect something wrong is happening there since it want way to much gas.

const gasLimit = '100000'; // <- string
const gasPrice = '1000000000'; // <-string
const nonce = await web3.eth.getTransactionCount(fromAddress);
const txObject = {
  to: usdcTokenAddress,
  data: data.encodeABI(),
  gas: gasLimit,
  gasPrice: gasPrice,
  nonce: web3.utils.toHex(nonce)

Inspect your values


instead made static use this function for estimate

 const estimatedGas = await usdcContract.methods.approve(SPENDER_ADDRESS, AMOUNT_TO_APPROVE).estimateGas({ from: account.address });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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