Hey @ericglau , I am trying to implement TransparentUpgradeableProxy ( Openzeppelin v5 ) . I am following Patrick's video tutorial , in that tutorial , when he deployed using the deployProxy() method , 3 contracts got deployed ( i.e. Implementation , Proxy and Proxy Admin ) , but when I am trying to deploy using the same method , only 2 contracts got deployed . What am I doing wrong ?
This is the file that is getting generated when I call my deploy script .
I deployed on PolygonMumbai .
check these 2 transactions , when I ran deploy.js file , these 2 contracts got created . In Patrick's video , I also saw that the 2 of the deployed contracts was automatically named TransparentUpgradeableProxy and ProxyAdmin , but in my case I didn't see anything like that .
When calling your implementation's functions, you should submit the function calls to your proxy address, not your implementation address. To help with this, you may want to verify your source code -- see the verify task. Then from the block explorer, you will be able to interact with your contract from the proxy address using your implementation contract's ABI.
When I run this , Proxy's implementation is getting upgraded , but I don't know if there are limitations to what can be upgraded ?
I started with a basic ERC721Upgradeable contract that we get from Openzeppelin wizard , called it NonFungibleTokenV1 ( name is NonFungibleTokenV1 , symbol is NFTV1 , and safeMint() function can only be called by owner of the NonFungibleTokenV1 contract that is passed in initializer function as parameter ) .
Then , I modified this NFT contract , called it NonFungibleTokenV2 ( name is NonFungibleTokenV2 , symbol is NFTV2 , and safeMint() function can now be called by any address i.e. I've removed the onlyOwner modifier from safeMint() ) . What I see now is the contract name is still returning NonFungibleTokenV1 but safeMint() is upgraded as expected i.e. anyone can call safeMint() now . Why didn't the contract name get updated to NonFungibleTokenV2 but safeMint() got updated as expected ?
the way I've written v2 of implementation contract is okay or do I need to modify NonFungibleTokenV2 like MyTokenV2 ?
what may go wrong in my implementation ?
Is the article way recommend way to write different versions for implementation contracts using transparent upgradeable proxy ?
I am having one problem currently , I started with deploying a proxy for NonFungibleTokenV1 , then upgraded proxy's implementation to NonFungibleTokenV2 . But in polygon mumbai explorer it is still showing proxy contract's name as NonFungibleTokenV1 and contract's symbol as NFTV1 . It should rather show name as NonFungibleTokenV2 and symbol as NFTV2 .
Note that your initialize function in V2 is not protected so anyone can call it. That means you need to call it during upgrade, in the same transaction. Otherwise someone can overtake your proxy if they frontrun you in calling it.
From your contract, it doesn't look like it was upgraded though.