Hello. I am trying to understand if my deployment was done properly. After following both Step-by-step tutorial for upgrades and UUPS Proxies tutorial but Im not sure how to check if it it actually upgraded the implementation.
Code to reproduce
After running the prepare_upgrade.ts script:
// scripts/prepare_upgrade.ts
import { ethers, upgrades } from "hardhat";
import { BaseContract } from "ethers";
let proxyAddress: BaseContract["address"];
async function main() {
proxyAddress = "0xA11C14BdF7bEf0174E54d1c5287a7B163f2323A0";
const ContractV2 = await ethers.getContractFactory("ContractV2");
console.log("Preparing upgrade...");
const contractV2Address = await upgrades.prepareUpgrade(
proxyAddress,
ContractV2
);
console.log("ContractV2 at:", contractV2Address);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
And then the following upgradeProxy.ts script:
// scripts/prepare_upgrade.ts
import { ethers, upgrades } from "hardhat";
import { BaseContract } from "ethers";
let proxyAddress: BaseContract["address"];
async function main() {
proxyAddress = "MYPROXYADDRESS";
const signers = await ethers.getSigners();
const upgraderRole =
"0x189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3";
const instance = await ethers.getContractAt(
"ContractV1",
"MYPROXYADDRESS",
signers[0]
);
await instance.grantRole(upgraderRole, signers[0].address);
console.log("Role for upgrades granted to MYWALLET");
const ContractV2 = await ethers.getContractFactory("ContractV2");
console.log("Preparing upgrade...");
const contractV2 = await upgrades.upgradeProxy(proxyAddress, ContractV2);
console.log("ContractV2 at:", contractV2.Address);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
The last console.log throws undefined. Etherscan shows that the UpgradeTo function was indeed called and the implementation o the contract seems to be actually what the prepare_upgrade deployed, but I'm not able to verify that contract in order to check the new implementation code (apparently hardhat is not able to verify it as it does not seem to be recorded on my artifacts).
Environment
Hardhat