I am tring to use AAVE contract in my own contract. but I have a question on this mysterious error. Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="Error: Transaction reverted without a reason string", method="estimateGas" Anyone knows what is the issue?

My sol contract is

pragma solidity ^0.8.0;

import {IPool} from "@aave/core-v3/contracts/interfaces/IPool.sol";

contract MyContract{
    address private owner;
        owner = msg.sender;
    function submitOrder(address pool, address token, uint256 amount, address user) public payable{
        IPool(pool).supply(token, amount, user, 0);

In my deployment file (ts file), I use

let contractFactory = await ethers.getContractFactory("MyContract");
let contract = await contractFactory.deploy();

In my script file, I use

let depositAmount = ethers.utils.parseEther("1");
let contractSigner = await contract.connect((await ethers.getSigners())[0]);
let (await contractSigner.submitOrder(poolAddress, tokenAddress, depositAmount, payerAddress)).wait();

I tested in my local network (Polygon) and I confirmed that I have enough token in my payerAddress.

payerAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
tokenAddress = "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
poolAddress = "0x794a61358D6845594F94dc1DB02A252b5b4814aD";
  • I don't remember how Aave works, but I feel like the tokens need to be in MyContract, and it needs to approve the pool as spender.
    – 0xSanson
    Sep 21, 2022 at 20:38
  • May I ask what it mean tokens need to be in MyContract?
    – Ethanabc
    Sep 21, 2022 at 22:19
  • 1
    The underlying token. Aave pulls it from msg.sender, which is your contract. So the tokens must be owned by your contract, not payerAddress. payerAddress is only the recipient of the aTokens (afaik)
    – 0xSanson
    Sep 21, 2022 at 23:13


Your Answer

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