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

Hi,

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()
undefined
truffle(development)> (await box.retrieve()).toString()
'42'
truffle(development)> proxyAdmin = await ProxyAdmin.at("0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B")
undefined
truffle(development)> proxy = await AdminUpgradeabilityProxy.at(box.address)
undefined

We can then interact with the ProxyAdmin

truffle(development)> await proxyAdmin.owner()
'0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'

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 https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/173

2 Likes