I've deployed a contract(MyContract) on both ethereum sepolia and arbitrum sepolia testnets.
async function getContractAddress() {
const { deployer } = await getNamedAccounts();
const myContract = await ethers.getContract(
"MyContract",
deployer
);
console.log("Getting address of Contract...");
const contractAddress = await myContract.getAddress();
console.log(
`My contract is deployed at ${contractAddress}`
);
};
In case of above function it looks for the contract on local hardhat node and fails to find any contract. How can I make it look for the contract on a specific network? Is there a way to get Contract address deployed on a particular chain via hardhat ethers? I'm looking for a way to do this via code, instead of CLI.
Please help me out. Thanks is advance.