0

I created a simple button in my dapp to make a deposit in aave. I am in Kovan testnet, and I am depositing 50 DAI. The amount of estimated gas fee is 0.000805ETH. This is the code:

const aaveDepositHandler = () => {
    lendingPoolInstance.methods.deposit('0xff795577d9ac8bd7d90ee22b6c1703490b6512fd', '50000000000000000000', account, 0).send({from: account})
    .on('transactionHash', (hash) => {
      console.log(hash);
    });
  };

Now, when I make a deposit directly in Aave interface, the amount of estimated gas fee is 0.000279ETH.

I don't really understand why my dapp is consuming more gas than the Aave interface, if I am only calling the deposit function, same as Aave interface does. I even compared the "data" and it is exactly the same in both cases:

0xe8eda9df000000000000000000000000ff795577d9ac8bd7d90ee22b6c1703490b6512fd000000000000000000000000000000000000000000000002b5e3af16b188000000000000000000000000000084550e6023be1a35babbeadbfaa0fe586aaff5b10000000000000000000000000000000000000000000000000000000000000000

I would like to understand why this happens, and how I can reduce the amount of gas fee to the same level as Aave interface when I deposit.

0

The gas setting can be adjusted in the front end. this is probably what Aave does. On your end if you don't provide these settings, metamask will just fetch what ever it's using to get gas price.

Look up the estimateGas method. This is how the gas price is returned to metamask.

Or your transaction option also accept these argumnets.

const options = {from:account, gasPrice:'100000000000', gasLimit:'..."}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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