Hi everyone,
I'm trying to upgrade my contract but getting the error below:
The error:
"TypeError: Cannot read properties of undefined (reading 'upgradeProxy')"
My deploy script for version 1:
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
//let wei = ethers.utils.parseEther('300000000')
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer} = await getNamedAccounts();
await deploy('NVMToken', {
contract: 'NVMToken',
from: deployer,
proxy: {
owner: deployer,
proxyContract: 'OpenZeppelinTransparentProxy',
execute: {
init: {
methodName: '__initializeNVM',
args: ['300000000000000000000000000'],
},
},
},
log: true,
});
};
export default func;
func.tags = ['NVMToken'];
Here is my upgrade script:
const { ethers, upgrades } = require("hardhat");
const UPGRADEABLE_PROXY = "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"; //NVMToken_Proxy
async function main() {
const V2Contract = await ethers.getContractFactory("NVMTokenV2");
console.log("Upgrading V1Contract...");
let upgrade = await upgrades.upgradeProxy(UPGRADEABLE_PROXY, V2Contract);
console.log("V1 Upgraded to V2");
console.log("V2 Contract Deployed To:", upgrade.address)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
The steps that I followed;
1- I executed npx hardhat node --show-accounts
2- I executed npx hardhat run scripts/upgrade.js --network localhost
with the address of Proxy contract. (Getting the error here)
The codes are here: https://github.com/selimerunkut/bep20_NVM/tree/dev