Lesson 13: Cannot get lendingPool address #6065
-
I am using Ethers v6 (6.7.1) and I am coding along lesson 13. I am at the const { getNamedAccounts, ethers } = require('hardhat');
const { getWeth } = require('./getWeth');
async function main() {
// the protocol treats everything as an ERC-20 token
await getWeth();
const { deployer } = await getNamedAccounts();
const signer = await ethers.provider.getSigner();
// Lending Pool Address Provider: 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5
// Lending Pool: ^
const lendingPool = await getLendingPool(deployer);
const lendingPoolContractAddress = await lendingPool.getAddress();
console.log(`Lending Pool address ${lendingPoolContractAddress}`);
}
async function getLendingPool(account) {
const lendingPoolAddressesProvider = await ethers.getContractAt(
'ILendingPoolAddressesProvider',
'0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
account
);
const lendingPoolAddress =
await lendingPoolAddressesProvider.getLendingPool();
const lendingPool = await ethers.getContractAt(
'ILendingPool',
lendingPoolAddress,
account
);
return lendingPool;
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); As you can see, I have modified the code a bit to do
I would like to do this without reverting back to Ethers v5 so help on how I can go about solving this would be greatly appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found the solution. I was passing |
Beta Was this translation helpful? Give feedback.
I found the solution. I was passing
deployer
but once I passedsigner
intoconst lendingPool = await getLendingPool(signer);
, everything works now.