openzeppelin-upgrades icon indicating copy to clipboard operation
openzeppelin-upgrades copied to clipboard

How to get previously deployed contract details?

Open joemckie opened this issue 3 years ago • 6 comments

In hardhat-deploy, it's possible to do this:

const deployment = await hre.deployments.get('...');

Is there a similar way to get contract details using @openzeppelin/hardhat-upgrades? I have a contract that depends on the address of another contract and would like to make the deployment as automated as possible.

Thanks!

joemckie avatar Nov 02 '21 19:11 joemckie

We don't offer an out of the box way to get this information. A relatively easy option is to write the addresses manually in a JSON file and then retrieve them.

frangio avatar Nov 18 '21 14:11 frangio

While hunting down for a similar solution, I crawled across https://ethereum.stackexchange.com/questions/103530/how-to-get-implementation-address-after-deployproxy-open-zepplin-hardhat-up and https://forum.openzeppelin.com/t/integrating-hardhat-deploy-and-openzeppelin-hardhat-upgrades/5585/4

So I guess a general effort towards the possibilities to ease the user-pain of copy/pasting the address of a newly deployed contract is underway.

Could saving the newly deployed proxy contract information as part of .openzeppelin files be an easy solution to help here? Meanwhile, it's a plain pain to save every deployed contract information for each network :(

Magicking avatar Dec 09 '21 19:12 Magicking

@Magicking Do you have a preferred way of handling this for non-upgradeable contracts?

frangio avatar Dec 10 '21 17:12 frangio

Not sure to understand the question, my issue is related to upgradeable contracts and the possibility to get the full information of a deployed instance and particularly the possibility to obtain the address of a proxy from other scripts.

It seems that the proxy addresses are present but I'm not certain of the best way to fetch them.

Magicking avatar Dec 13 '21 12:12 Magicking

https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/680

Hi, guys, I think it's related but in my issue, I propose a preferred way to save the data fr hardhat at least

Na3aga avatar Oct 25 '22 23:10 Na3aga

If you are using hh deploy you can save previously deployed contracts with pattern like this

  // Token code
  const Token = await ethers.getContractFactory('TestToken');
  const token = await Token.deploy();
  await token.deployed();

  const artifactToken = await deployments.getExtendedArtifact('TestToken');
  let tokenDeployments = {
    address: token.address,
    ...artifactToken
  }

  await deployments.save('TestToken', tokenDeployments);

0xCardinalError avatar Feb 13 '23 17:02 0xCardinalError