I have an upgradable contract that inherits from ERC20BurnableUpgradeable like this:
// Original Contract
contract Token is ERC20BurnableUpgradeable {
string private constant NAME = "Token Name";
string private constant SYMBOL = "TOKEN";
uint8 private constant DECIMAL = 18;
function initialize() public override initializer {
super.initialize(NAME, SYMBOL, DECIMAL);
}
}
And I want to upgrade to a new implementation like this:
// New version Contract
contract Token is ERC20BurnableUpgradeable {
string private constant NAME = "NEW Token Name";
string private constant SYMBOL = "TOKEN";
uint8 private constant DECIMAL = 18;
function initialize() public override initializer {
super.initialize(NAME, SYMBOL, DECIMAL);
}
function name() override public view returns(string memory){
return NAME;
}
function getOnes() public pure returns(uint256){
return 111;
}
}
I created the unit test to verify the new constant value, the new function and the state of the others constants and it worked well. Furthermore, I made a further upgrade as a test by adding one function more and it worked well as well.
However when I try to deploy to Rinkeby, nothing happens, it look likes the upgrade was made correctly but when I call the getOnes function I get and error:
cannot estimate gas; transaction may fail or may require manual gas limit
Even when I get the value of the name constant, I get the original value,“Token Name” , so it looks like the upgrade was not done.
This is the script to upgrade:
const tokenv2Deployer = await hre.ethers.getContractFactory(Token_V2);
const tokenv2= await upgrades.upgradeProxy(
proxyAddress,
tokenv2Deployer ,
);
etherscan.printAddress(`Contract URL: `, tokenv2.address);
So I used the prepareUpgrade function to get the new implementation address and call upgradeTo function with it, but in this case I got and error.
Warning! Error encountered during contract execution [execution reverted]
If the new implementation is not safe to upgrade I should receive an error when I running the script but that is my doubt because I am not getting nothing from the .upgradeProxy call:
Thank you, I would really appreciate your opinion.