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;
constructor(){
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";
MyContract
, and it needs to approve the pool as spender.MyContract
?token
. Aave pulls it frommsg.sender
, which is your contract. So the tokens must be owned by your contract, notpayerAddress
. payerAddress is only the recipient of the aTokens (afaik)