How to interact with proxy contract, after deploying a TransparentProxy?

I'm writing tests for my proxy contract using OpenZeppelin's truffle-upgrades, TransparentProxy.

I wrote this test:

 it("can transfer ownership", async () => {
      const admin = await proxy.admin();
      const newAdmin = await proxy.changeAdmin(accounts[1]);

      assert.ok(newAdmin !== admin)

And this is the beforeEach hook:

 beforeEach(async () => {
proxy = await deployProxy(
    web3.utils.toWei("0.1", "ether"),
  { kind: "transparent" }


But I kept getting an error saying the admin function doesn't exist. It made me realize that even calls to admin functions are delegated directly to the implementation contract. So, how can I access the admin functions on a proxy contract? I'm assuming I need some way to get the ProxyAdmin and Proxy addresses, but I couldn't find a way to do that either.

Any help is much appreciated - thank you in advance!

You can use the admin module from the Truffle Upgrades plugin, then use getInstance().getProxyAdmin(...) and changeProxyAdmin(...). See for examples.

1 Like