openzeppelin-upgrades
openzeppelin-upgrades copied to clipboard
How to get previously deployed contract details?
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!
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.
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 Do you have a preferred way of handling this for non-upgradeable contracts?
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.
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
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);