This has been updated to work with Goerli over Rinkeby
You can also see the python/brownie version of this here.
This repo represents a decentralized bar as a DAO in which all the transactions (buy drinks, play games, etc.) are registered in the blockchain. The bar uses its own ERC20 token to manage all the operations. As a DAO, proposals will be allowed.
Feature | On-Chain Governance | Hybrid Governance |
---|---|---|
Gas Costs | More Expensive | Cheaper |
Components | Just the blockchain | An oracle or trusted multisig |
Work with this repo in the browser (optional)
It's recommended that you've gone through the hardhat getting started documentation before proceeding here.
- git
- You'll know you did it right if you can run
git --version
and you see a response likegit version x.x.x
- You'll know you did it right if you can run
- Nodejs
- You'll know you've installed nodejs right if you can run:
node --version
and get an ouput like:vx.x.x
- You'll know you've installed nodejs right if you can run:
- Yarn instead of
npm
- You'll know you've installed yarn right if you can run:
yarn --version
And get an output like:x.x.x
- You might need to install it with npm
- You'll know you've installed yarn right if you can run:
- Clone this repo:
git clone https://github.com/eLSeR17/blacktown-bar
cd blacktown-bar
- Install dependencies
yarn
or
npm i
- Run the test suite (which also has all the functionality)
yarn hardhat test
or
npx hardhat test
If you want to deploy to a testnet:
4. Add a .env
file with the same contents of .env.example
, but replaced with your variables.
WARNING
DO NOT PUSH YOUR PRIVATE_KEY TO GITHUB
Here is the rundown of what the test suite does.
- We will deploy the ERC20 token "BlacktownToken" which we will use to control the bar.
- We will deploy a Timelock contract that we will use to give a buffer between executing proposals.
- Note: The timelock is the contract that will handle all the money, ownerships, etc
- We will deploy our Governence contract
- Note: The Governance contract is in charge of proposals and such, but the Timelock executes!
- We will deploy the bar's main contract, which will be owned by our governance process! (aka, our timelock contract).
- We will propose a price to be changed in our bar contract.
- We will then vote on that proposal.
- We will then queue the proposal to be executed.
- Then, we will execute it!
Additionally, you can do it all manually on your own local network like so:
- Setup local blockchain
yarn hardhat node
- Propose a new value to be added to our Box contract
In a second terminal (leave your blockchain running)
yarn hardhat run scripts/propose.ts --network localhost
- Vote on that proposal
yarn hardhat run scripts/vote.ts --network localhost
- Queue & Execute proposal!
yarn hardhat run scripts/queue-and-execute.ts --network localhost
You can also use the Openzeppelin contract wizard to get other contracts to work with variations of this governance contract.
This sectoin is still being developed.
Deploy your ERC20 and make proposals in snapshot.
- [] Add Upgradeability examples with the UUPS proxy pattern
- [] Add Chainlink Oracle Integration with Snapsafe example
See the open issues for a full list of proposed features (and known issues).
Distributed under the MIT License. See LICENSE.txt
for more information.
Hardhat - @HardhatHQ Sergio López - @sergiolopez1771
- Openzeppelin Governance Walkthrough
- Openzeppelin Governance Github
- Vitalik on DAOs
- Vitalik on On-Chain Governance
- Vitalik on Governance in General
You can check out the openzeppelin javascript tests for a full suite of an example of what is possible.