I’ve successfully deployed an upgradeable ERC-20 contract to the Rinkeby testnet. I’m now trying to document how to interact with it and perform upgrades internally.
Q: How can one read the actual ERC-20 contract (integration contract)? I would like to see the burn and transferFrom functions etc in the contract itself on etherscan for instance. But when viewing the contract I can only see the proxy functions:
Q2: When applying an upgrade to an ERC-20 contract, another set of tokens will be minted assuming that the _mint initializer method is included with the v2 contract. Are there any best practices to apply upgrades to ERC-20 contracts?
Etherscan supports interacting with proxy contracts. We need to have verified both the proxy (this should already be verified, let me know if not) and our implementation contract. We can then mark the contract as a proxy.
When we deploy our upgradeable contracts we initialize them (rather than using a constructor).
Initializers should only be called once (just like a constructor) and we can use the initializer modifier.
When upgrading the contract, we don't call initialize again. Instead, if we need to initialize any state variables, we can create a function to set the state, though we need to ensure that this can only be called once, such as by checking if the state variables have been initialized.
It is best to avoid changing the name, symbol or amount of decimals for an ERC20 token, as this may not be supported by wallets and applications, and any change would have to be updated on each wallet/application/service.