Proxy address for upgradeable contract

Hi,

I have implemented a base contract with the upgradeable capability and a V2 contract. The setup script to deploy both contracts is working fine and I have tests to make sure that both V1 and V2 contract has been deployed to a local network and kovan. I want to make sure that both contracts are deployed with the same proxy address. Is there a way to get the information of proxy address? Or I have to manually set the address using npx oz set-admin [MYCONTRACT_ADDRESS] [NEW_ADMIN_ADDRESS]

:computer: Environment
harhat - 2.1.1
Solidity v0.5.16 (solc-js)
Node v14.16.0
Web3.js v1.2.9

1 Like

Hi @dappCoder,

Please note: We’ve decided it’s best to focus our upgradeability efforts on the Upgrades Plugins exclusively, and have halted development on the OpenZeppelin CLI. See: Building for interoperability: why we’re focusing on Upgrades Plugins

I wasn’t sure what you meant in your question, but I would encourage you to use Upgrades Plugins: https://docs.openzeppelin.com/upgrades-plugins/1.x/

Hi, I used upgrade-plugins for my contract and the tests against both of my based contract and the upgraded contract are also passed. However, I need to write a test to make sure that the proxy address is the same for both of the contracts. I wonder if I can get the proxyAdmin address so that I can write my own custom tests.

1 Like

Hi @dappCoder,

For higher level tests interacting with the upgradeable contract you can use the following:
https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades#test-usage

A complete example is shown in:
OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat

Thank you for your answer. I have test cases for my upgradable contracts and they were all passed. What I need is to get the proxy address so that I can write custom tests. My question is that is there any function that I can use to get the proxy address or I have to set the proxy address manually when deploy the upgradable contracts.

1 Like

@dappCoder deployProxy and upgradeProxy return a contract instance that corresponds to the proxy. This object has an address property, it will be the address of the proxy.

1 Like