https://github.com/ericglau/custom-beacon
Hardhat Upgrades with Custom Beacon
https://github.com/ericglau/custom-beacon
Last synced: over 1 year ago
JSON representation
Hardhat Upgrades with Custom Beacon
- Host: GitHub
- URL: https://github.com/ericglau/custom-beacon
- Owner: ericglau
- Created: 2022-12-06T15:30:25.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T19:17:43.000Z (over 3 years ago)
- Last Synced: 2025-02-09T02:15:39.048Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 159 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hardhat Upgrades with Custom Beacon
This project demonstrates how to use a custom beacon with [OpenZeppelin Hardhat Upgrades](https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades). It comes with some example contracts, a test case, and a deployment script.
The custom beacon used in this example is an upgradeable beacon with role-based access control.
## Overview
In this scenario, OpenZeppelin Hardhat Upgrades handles validations and deployment of implementation contracts, beacon proxies, and upgrades, with a custom beacon that is deployed directly.
The steps are:
1. Use [`deployImplementation`](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#deploy-implementation) to validate and deploy the implementation.
2. Deploy the custom beacon contract directly using the `deploy` function from the ethers contract factory.
3. Use [`deployBeaconProxy`](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#deploy-beacon-proxy) to deploy a beacon proxy, and/or use [`upgradeBeacon`](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#upgrade-beacon) to validate and upgrade the implementation to a new version.
## Installing dependencies
```
npm install
```
## Testing
See [test/test.ts](test/test.ts) for an example test case.
Run tests with:
```
npm test
```
## Deploying
See [scripts/deploy.ts](scripts/deploy.ts) for an example deployment script.
Set the `DEFAULT_ADMIN_ADDRESS` and `UPGRADER_ADDRESS` constants in the script.
Run the script to target any network from your Hardhat config using:
```
npx hardhat run --network scripts/deploy.ts
```