How to interact with a contract which has already been deployed by using ethers.js?

How to interact with a contract which has already been deployed by using ethers.js?

You may try ethers.getContractAt(name: string, address: string, signer?: ethers.Signer).
for example:

const [owner] = await hre.ethers.getSigners();
const contract = await hre.ethers.getContractAt("contractName", contract address, owner);

This is a Hardhat plugin for integrating with ethers.js, allowing users to interact more easily with the blockchain. It's not part of the original ethers.js library source, so you won't find it in the ethers.js documentation.

1 Like

Yes, I have tried this, and it works, thanks.

1 Like