Add an example script on how to upgrade a contract implementation

This commit is contained in:
bumi 2022-07-04 20:00:53 +02:00
parent fa4583158f
commit e21fb40661
2 changed files with 20 additions and 1 deletions

View File

@ -71,7 +71,7 @@ To run these scripts use `hardhat run`. For example: `hardhat run scripts/list-c
Some scripts are also defined as npm script, see package.json.
### repl.js
### repl/console
Similar to cli.js but only provides a REPL with an initialized `kredits`
instance.
@ -108,6 +108,9 @@ We use OpenZeppelin for an upgradeable contracts: [https://www.npmjs.com/package
Refer to the OpenZeppelin README and `scripts/create-proxy.js`
For an upgrade example checkout `scripts/upgrade-example.js`
## Known Issues
When resetting ganache Metamask might have an invalid transaction nonce and

View File

@ -0,0 +1,16 @@
const { ethers, upgrades } = require("hardhat");
const Kredits = require('../lib/kredits');
async function main() {
const network = await hre.ethers.provider.getNetwork();
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner());
await kredits.init();
const ContributorV2 = await ethers.getContractFactory("Contributor");
const contributor = await upgrades.upgradeProxy(kredits.Contributor.address, ContributorV2);
console.log("Contributor upgraded");
console.log("DONE!");
}
main();