{"id":15924092,"url":"https://github.com/ericglau/workshop-oz-30w3","last_synced_at":"2025-04-03T12:45:49.743Z","repository":{"id":116635737,"uuid":"448675084","full_name":"ericglau/workshop-oz-30w3","owner":"ericglau","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-02T15:30:13.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T02:15:36.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericglau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-16T21:16:17.000Z","updated_at":"2022-01-16T21:34:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7ac0db7-10eb-49a1-b742-8c49ec678e62","html_url":"https://github.com/ericglau/workshop-oz-30w3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericglau%2Fworkshop-oz-30w3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericglau%2Fworkshop-oz-30w3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericglau%2Fworkshop-oz-30w3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericglau%2Fworkshop-oz-30w3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericglau","download_url":"https://codeload.github.com/ericglau/workshop-oz-30w3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247005397,"owners_count":20868019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T21:20:21.070Z","updated_at":"2025-04-03T12:45:49.716Z","avatar_url":"https://github.com/ericglau.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenZeppelin workshop - 30W3\n\n## tl;dr\n\n1. Setup\n```\ngit clone https://github.com/ericglau/workshop-oz-30w3\ncd workshop-oz-30w3\nnpm install --save-dev hardhat\nnpm install\n```\n\n2. Start a local Hardhat node\n```\nnpx hardhat node\n```\n\n3. Open a separate terminal in the project directory, then run the below to deploy and upgrade:\n```\nnpx hardhat run --network localhost scripts/deploy.js\nnpx hardhat run --network localhost scripts/upgrade.js\n```\n\n4. Run tests:\n```\nnpx hardhat test\n```\n\n## Step-by-step tutorial\n\n1. Go into an empty folder: `mkdir demo \u0026\u0026 cd demo`\n2. Install Hardhat: `npm init \u0026\u0026 npm install --save-dev hardhat`\n3. Install OpenZeppelin Upgradable Contracts: `npm install @openzeppelin/contracts-upgradeable`\n4. Install Hardhat Upgrades plugin: `npm install --save-dev @openzeppelin/hardhat-upgrades @nomiclabs/hardhat-ethers ethers`\n5. Go to https://wizard.openzeppelin.com/, check the Upgradability checkbox and leave the selection as Transparent.  We will be deploying a beacon proxy but the implementation contract can look the same as for a transparent proxy.\n6. Using the Wizard's contract as reference, add the missing parts to the default Greeter.sol contract and change the original constructor to an initializer, so that it looks like [this](./contracts/Greeter.sol)\n7. Make a copy of Greeter and change its name to GreeterV2.\n8. Add a new function in GreeterV2:\n```\nfunction resetGreeting() public {\n    greeting = \"Hello World\";\n}\n```\n9. Using the script examples [here](https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades#beacon-proxies), add a [deploy.js](./scripts/deploy.js) and [upgrade.js](./scripts/upgrade.js) in the `scripts` directory but for the Greeter contracts.\n10. Using the test example [here](https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades#beacon-proxies-tests), add a [upgrade-test.js](./test/upgrade-test.js) in the `test` directory but for the Greeter contracts.  The additional `const tx = await upgraded.resetGreeting();` section tests that the new function from the new version of the contract is working.\n11. Start a local Hardhat node\n```\nnpx hardhat node\n```\n12. Open a separate terminal in the project directory, then run the below to deploy a beacon and beacon proxy:\n```\nnpx hardhat run --network localhost scripts/deploy.js\n```\n13. Edit the `BEACON_ADDRESS` and `BOX_ADDRESS` in `scripts/upgrade.js` with the addresses displayed in the output after running the above.\n14. Run the below to upgrade the beacon:\n```\nnpx hardhat run --network localhost scripts/upgrade.js\n```\n15. Run tests:\n```\nnpx hardhat test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericglau%2Fworkshop-oz-30w3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericglau%2Fworkshop-oz-30w3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericglau%2Fworkshop-oz-30w3/lists"}