Hey there, I am facing an issue with getting address of deployed contract, it's always undefined, mb someone knows where I am doing mistake:
const { ethers } = require("hardhat");
describe("TestContract Deployment", function () {
let ponzi;
before(async function() {
const TestContract = await ethers.getContractFactory("TestContract");
ponzi = await TestContract.deploy();
await ponzi.deployed(); // Ensure the contract is deployed before proceeding
});
it("Should log the deployed address of TestContract", async function() {
console.log("TestContract deployed at:", ponzi.address);
});
});
Output from terminal:
TestContract Deployment
TestContract deployed at: undefined
✔️ Should log the deployed address of TestContract
Sep 18, 2023, 4:30 AM
bruh
stop deploying ponzi, learn the tech
Sep 18, 2023, 4:32 AM
it's test task, I want to find bug on it, LOL
Sep 18, 2023, 4:33 AM
strange anyway, it seems fine
Sep 18, 2023, 4:34 AM
saw there is reentrancy function, and wanna write test for it, but this silly undefined error annoying
Sep 18, 2023, 4:34 AM
Probably using ethers v6. Its something like contract.getAddress() for retrieving address
Sep 18, 2023, 8:33 AM
https://ethereum.stackexchange.com/questions/151501/hardhat-ethereum-contract-is-missing-address
Sep 18, 2023, 11:46 AM
Isn't it beforeEach
Sep 19, 2023, 3:35 AM