How to interact with proxy and ProxyAdmin contracts using Truffle console?

Oleg K asked on Telegram

I want to interact with instances of deployed ProxyAdmin and AdminUpgradeability proxy, try to trigger some methods on them and just play around. The guide which you linked does not show how to do it. Ideally it should be something like: let instance = await ProxyAdmin.deployed(), but it does not work like this because those are not loaded into truffle console by default.


Using the following tutorial as a base: OpenZeppelin Truffle Upgrades: Step by Step Tutorial

Once the upgradeable contract has been deployed to the network e.g. to development network

$ npx truffle migrate --network development

Copy the artifacts from node_modules for the ProxyAdmin and the AdminUpgradeabilityProxy

$ cp node_modules/@openzeppelin/upgrades-core/artifacts/* build/contracts

Using the console and the addresses specified in .openzeppelin/\<network>.json

$ npx truffle console --network development
truffle(development)> box = await Box.deployed()
truffle(development)> (await box.retrieve()).toString()
truffle(development)> proxyAdmin = await"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B")
truffle(development)> proxy = await

We can then interact with the ProxyAdmin

truffle(development)> await proxyAdmin.owner()

Whilst the admin for our proxy is the ProxyAdmin we can only interact with the proxy as a non-admin (via box).

There is an open issue to provide an instance of ProxyAdmin in the admin module

From Telegram

Big thanks, @abcoathup, this is exactly what I’ve needed!