I followed OpenZeppelin's HardHat process for writing upgradeable contracts.

  1. Write an implementation contract (example.sol) with upgradeable Initializers
  2. Write a script to deploy it within Hardhat that deploys proxy
  3. Write exampleV2.sol and deploy new proxy

I have a few questions regarding this

  1. What is TransparentUpgradeableProxy contract that was deployed from deployer address?
  2. What is the ProxyAdmin and how is it different to #1?
  3. How do I make function calls to example.sol from ProxyAdmin?


1 Answer 1

  1. It is an "owned" contract that blindly forwards requests to an implementation at another address.
  2. Proxy admin is allowed to change the address of the implementation. This is how an upgrade occurs.
  3. Use the ABI for Example.sol at the address of the TransparentUpgradeableProxy. It uses delegateCall and basically forwards inputs to the implementation, Example.sol, then it returns whatever came back, so the proxy is a work-alike for the implementation. It's simply a matter of instantiating Example.at(<proxyAddress).

There are subtle things to be wary of when using this pattern, so be sure to do your homework. In particular, do not set any state variable values in your constructor in Example.sol. Use function initialize() instead, with initializer modifier from OpenZeppelin's Initializable.sol.

Hope it helps.

  • Thanks Rob, A few further questions if I may 1 – My transparentupgradeableproxy has no instance Example.sol if that's what you meant, am I looking at the wrong place? When I load this address in Remix, I get "No compiled contracts" error. // 2 – Could you point me to an example of #3? // 3 – ExampleV2.at(proxy) should also work once I upgrade right?
    – abhinavmir
    Apr 25, 2023 at 0:03
  • Maybe post the contract and deployment script as a new question. I'd be guessing. Apr 25, 2023 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.