Add an example script on how to upgrade a contract implementation
This commit is contained in:
parent
fa4583158f
commit
e21fb40661
@ -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.
|
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`
|
Similar to cli.js but only provides a REPL with an initialized `kredits`
|
||||||
instance.
|
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`
|
Refer to the OpenZeppelin README and `scripts/create-proxy.js`
|
||||||
|
|
||||||
|
For an upgrade example checkout `scripts/upgrade-example.js`
|
||||||
|
|
||||||
|
|
||||||
## Known Issues
|
## Known Issues
|
||||||
|
|
||||||
When resetting ganache Metamask might have an invalid transaction nonce and
|
When resetting ganache Metamask might have an invalid transaction nonce and
|
||||||
|
16
scripts/upgrade-example.js
Normal file
16
scripts/upgrade-example.js
Normal 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();
|
Loading…
x
Reference in New Issue
Block a user