ethers-simple-storage-fcc icon indicating copy to clipboard operation
ethers-simple-storage-fcc copied to clipboard

Resolving Error : Update to ethers.js Retrieving Contract.Address

Open Maximesol opened this issue 2 years ago • 3 comments

I don't know if this can help anyone but I got stuck because contract.address is giving me an error in terminal. Can be an update of ethers? Anyway to solve this problem, we can use the contractAddress property on the deployed contract receipt like this:

    const contract = await contractFactory.deploy();
    const receipt = await contract.deploymentTransaction().wait(1);
    console.log("Contract Address : " + receipt.contractAddress);

Maximesol avatar Jun 27 '23 08:06 Maximesol

Nice work!

PatrickAlphaC avatar Jun 29 '23 21:06 PatrickAlphaC

You could also try this:

console.log(`Contract deployed to ${contract.target}`);

contract.address => contract.target

shanmukhipriya99 avatar Aug 30 '23 02:08 shanmukhipriya99

You can try this code, also work:

console.log(`Contract deployed to ${await contract.getAddress()}`)
contract.address => await contract.getAddress()

kangaroona avatar Aug 31 '23 06:08 kangaroona