Skip to content

Instantly share code, notes, and snippets.

@lukecurtis93
Created March 16, 2022 22:23
Show Gist options
  • Save lukecurtis93/ece251d6c9c7ca9a4608171a4f0c03aa to your computer and use it in GitHub Desktop.
Save lukecurtis93/ece251d6c9c7ca9a4608171a4f0c03aa to your computer and use it in GitHub Desktop.
Deploying an upgradable contract
const { ethers, upgrades } = require('hardhat');
async function main() {
// Hardhat always runs the compile task when running scripts with its command
// line interface.
//
// If this script is run directly using `node` you may want to call compile
// manually to make sure everything is compiled
// await hre.run('compile');
// We get the contract to deploy
const Contract = await ethers.getContractFactory("MyToken");
const contract = await upgrades.deployProxy(Contract);
await contract.deployed();
console.log("Contract deployed to:", contract.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment