Hi,
After deploying contracts using upgrades.deployProxy, it shows proxy contract address. But how can I find the actual address of implementation contract? Do I need to know it or not?
There is a file in .openzeppelin/unknown-XXXXX.json and it contains the field impls.address. Is this the implementation contract address?
I think I have a hack/solution that @abcoathup and @Skyge might be interested in.
When doing the hardhat tutorial I was also frustrated that I could not figure out what my implemented address was. I then learned it was storing it into the .json
For this example I will be using rinkeby.json
In my deploy.js I have this
const proxyAddr = await upgrades.deployProxy(Token, { initializer: 'initialize' });
console.log("Deployed Proxy Address:", proxyAddr);
// now lets get the address of the imp deployed contract, not just the proxy
const jsonRinkebyData = require('../.openzeppelin/rinkeby.json'); // TODO - you will need to change this for real deployment
const jsonRinkebyDataArray = Object.keys(jsonRinkebyData.impls).map((key) => [key, jsonRinkebyData.impls[key]]);
const impDeployedAddress = jsonRinkebyDataArray[jsonRinkebyDataArray.length-1][1].address;
console.log("Implemented Deployed Address:", impDeployedAddress);
What this simple code does is, it reads the last line of the implemented addresses from the json and then outputs it via console.log.
Then I copy this address and use the hardhat verify function on it.
You still need to verify that your Proxy is really a Proxy in etherscan in order for it to get the Write/Read functionality in etherscan, but this is a shortcut to figure out what your implemented address is.
Maybe there is a better way, but this is what I’m doing.