This is a Upgradeable Smart Contract workshop from Patrick Alpha's fcc. Another implementation of Upgradeable Smart Contracts from Chainlink Spring Hackathon 2022 was created here.
The workshop followed to complete this repo is this one.
The repo that we are going to implement is like this one.
- Proxies by Openzeppeling are going to be used.
- Delegate by call example.
We are doing:
- Upgrade Box -> BoxV2
- Proxy Box ->BoxV2
To do so there are different ways:
- Deploy a Proxy manually (done in contracts/sublesson).
- Deploy a Proxy using Hardhat built-in proxies (implemented here)✅.
- Deploy a Proxy using Openzeppelin upgrades plugin(done in scripts).
- Install yarn and start hardhat project:
yarn
yarn add --dev hardhat
yarn hardhat
- Install ALL the dependencies:
yarn add --dev @nomiclabs/hardhat-waffle@^2.0.0 ethereum-waffle@^3.0.0 chai@^4.2.0 @nomiclabs/hardhat-ethers@^2.0.0 ethers@^5.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 dotenv@^16.0.0 eslint@^7.29.0 eslint-config-prettier@^8.3.0 eslint-config-standard@^16.0.3 eslint-plugin-import@^2.23.4 eslint-plugin-node@^11.1.0 eslint-plugin-prettier@^3.4.0 eslint-plugin-promise@^5.1.0 hardhat-gas-reporter@^1.0.4 prettier@^2.3.2 prettier-plugin-solidity@^1.0.0-beta.13 solhint@^3.3.6 solidity-coverage@^0.7.16 @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @chainlink/contracts hardhat-deploy hardhat-shorthand @aave/protocol-v2
- Install OpenZeppelin dependencies (contracts):
yarn add --dev @openzeppelin/contracts
yarn hardhat compile
or
npx hardhat compile
If you want to use Hardhat shorthand:
yarn global add hardhat-shorthand
- Deploy to local network (Harhat by default):
hh compile
hh deploy
- Deploy to a TESTNET (Rinkeby): You can not deploy all scripts at the same time because you can deploy mint.js script without firtly add randomNFT to ConsumerBase.
To deploy every script expect mint.js:
yarn hardhat deploy --network rinkeby --tags main
Two types of tests are created for this project:
- "Unit tests" inside unit: used to test functions separately
To execute tests unit tests (on development chain):
yarn hardhat test
and to see test coverage:
yarn hardhat coverage
- Proxies by Openzeppeling are going to be used.
- Delegate by call example