Hello,
I have recently deployed a contract to the Ethereum Mainnet that I intended to be upgradeable using OpenZeppelin packages.
The deploy went flawlessly, users were interacting with my contract, and everyone was having fun in the telegram playing with it.
However, when I went to upgrade my contract, I noticed something very odd and disheartening:
There was no proxy address registered in my .openzeppelin > mainnet.json
file.
I reviewed my test network deployments, they all had proxy contracts registered for each test deployment, but not the mainnet.
I'm very confused on what could have caused this. Read on to review my functions and config settings.
I'm very much looking forward to your responses and puzzling on how this scenario came about - I was very surprised to learn I could not update my contract!
Code to reproduce
Here is the deploy script (Variables Changed)
async function main () {
const ExampleToken = await ethers.getContractFactory('ExampleContract');
console.log('Deploying ExampleToken...');
const exmpl = await upgrades.deployProxy(ExampleToken);
await exmpl.deployed();
console.log('exmpl deployed to:', exmpl.address);
}
main();
And then here is my hardhat.config.js
module.exports = {
solidity: "0.8.4",
optimizer: {
enabled: true,
runs: 1000,
},
networks: {
mainnet: {
url: `${url}`,
accounts: [`${privateKey}`],
live: true,
saveDeployments: true,
tags: ["production"],
gasPrice: 69000000000,
},
gnosis: {
url: `https://rpc.gnosischain.com/`,
accounts: [`${privateKey}`],
live: true,
saveDeployments: true,
tags: ["staging"],
}
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: etherScan
},
gasReporter: {
currency: "usd",
token: "eth",
gasPrice: 37
}
};
Environment
Here are my project dependencies:
"dependencies": {
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.3",
"@openzeppelin/contracts-upgradeable": "^4.5.2",
"@openzeppelin/hardhat-upgrades": "^1.17.0",
"@poanet/solidity-flattener": "^3.0.7",
"chai": "^4.3.6",
"dotenv": "^16.0.0",
"ethers": "^5.6.4",
"hardhat": "^2.9.3",
"hardhat-contract-sizer": "^2.5.1",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.7.20"
}
And finally, the deployment EOA implicated in the accounts: [
${privatekeys}]
declaration is a Metamask wallet that I exported the private keys from to store in dotenv.