I am trying to deploy my contract and get the address of deployed contract but is shows
"undefined".
Here is the code of deploy.js:
//deploy.js
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
console.log(
"Account balance:",
await deployer.provider.getBalance(deployer.address)
);
const chai = await ethers.getContractFactory("chai");
const chaiContract = await chai.deploy();
await chaiContract.waitForDeployment();
console.log("Deployed address:" + chaiContract.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
The version of ether.js i am using is 5.7.1
.json screenshot of dependency
The output i am getting after deployment is :
Deploying contracts with the account: 0x5A5171B2353f0A6Fd735e1564a96790d26465860
Account balance: 606092519791070461n
Deployed address:undefined
I was expecting the ouput to display the address to which my contract is deployed but whatever i am trying it still says "undefined". and the soldiity file name of my project is chai.sol . i even tried to replace chaiContract.address to chai.address but the result is same.
Can anyone please help me fix this problem.
Try using chaiContract.target instead of chaiContract.address