Copy example .env
and fill up the needed environment variables
cp .env.example .env
In this workshop, we will go over smart contract code management. Topics we will cover:
- Remix tool
- Hardhat Ethereum development environment with VSCode
- Make smart contracts upgradeable with OpenZeppelin upgrades plugins
- Verifying smart contract implementation on the blockchain
- Use OpenZeppelin Defender to propose smart contract upgrades and approve them within a team
- Talk about multi-signatory wallets to avoid the single point of failure with crypto wallets
- Deploy smart contract to the blockchain and verify it
Deploy:
npx hardhat run scripts/deploy.ts --network mumbai
Verify the smart contract and pass the constructor parameters:
npx hardhat verify 0xa4d8fd29c3b3715e4Ade9F89fbd76D57e2839ea7 --network mumbai 'NFT Tallinn 2023' 'NFTTLL23'
- Deploy the proxy contract
npx hardhat run scripts/deploy_proxy.ts --network mumbai
-
Change
CONTRACT_ADDRESS
in.env
file to the proxy address -
Get the smart contract implementation
npx hardhat run scripts/current-implementation.ts --network mumbai
- Verify the implementation contract
npx hardhat verify --network mumbai 0x69350e1C6702ebb88a47A19f24AaA856A95e85D3
-
Comment out the
getMyTicket
function -
Upgrade the implementation
npx hardhat run scripts/upgrade.ts --network mumbai
- Get the current implementation
npx hardhat run scripts/current-implementation.ts --network mumbai
- Verify the current implementation
npx hardhat verify --network mumbai 0x6bfd02B1c1A8C62717Ba1826eaeb6d9F27ECceC2
- Upgrade contract to OpenZeppelin defender
- add contract in OpenZeppelin defender
- comment out the
getParticipantTicket
function - execute
npx hardhat run scripts/propose_upgrade.ts --network mumbai
- approve and execute proposal in OpenZeppelin Defender
- get the current implementation
npx hardhat run scripts/current-implementation.ts --network mumbai
- verify the implementation
npx hardhat verify 0x69350e1C6702ebb88a47A19f24AaA856A95e85D3 --network mumbai
- Use multi signatory wallet
Use a wallet like Safe to avoid the bus factor and avoid a single point of failure. It also allows to collect signatures when upgrading a contract. Let's say you want everyone to vote for mainnet deployment, and only then is an upgrade executed.