This project implements a decentralized governance system using Solidity and OpenZeppelin contracts. It includes a governance token, a governance contract, a timelock controller, and a simple storage contract.
A governance token implemented using OpenZeppelin's ERC20
, ERC20Permit
, and ERC20Votes
. This token is used for voting in the governance system.
A governance contract that allows token holders to create and vote on proposals. It extends various OpenZeppelin governance contracts such as Governor
, GovernorSettings
, and GovernorVotes
.
A timelock controller that enforces a delay between when proposals are made and when they can be executed, enhancing the security of the governance process.
A simple contract that allows storing and retrieving a value. It is used to demonstrate how a governed contract might function.
- Install Dependencies: Ensure you have foundry installed. Then run:
forge install
- Compile Contracts: Compile the Solidity contracts using Foundry:
forge build
This project uses OpenZeppelin contracts which are industry standard and audited. However, always ensure to audit and test your specific implementation thoroughly before deploying to a production environment.
This project is licensed under the MIT License.
# Solidity Governance Project
This project implements a decentralized governance system using Solidity and OpenZeppelin contracts. It includes a governance token, a governance contract, a timelock controller, and a simple storage contract.
## Components
### 1. GovToken (`src/GovToken.sol`)
A governance token implemented using OpenZeppelin's `ERC20`, `ERC20Permit`, and `ERC20Votes`. This token is used for voting in the governance system.
### 2. MyGovernor (`src/MyGovernor.sol`)
A governance contract that allows token holders to create and vote on proposals. It extends various OpenZeppelin governance contracts such as `Governor`, `GovernorSettings`, and `GovernorVotes`.
### 3. TimeLock (`src/TimeLock.sol`)
A timelock controller that enforces a delay between when proposals are made and when they can be executed, enhancing the security of the governance process.
### 4. Box (`src/Box.sol`)
A simple contract that allows storing and retrieving a value. It is used to demonstrate how a governed contract might function.
## Setup and Deployment
1. **Install Dependencies:**
Ensure you have Node.js and npm installed. Then run:
```bash
npm install
```
-
Compile Contracts: Compile the Solidity contracts using Hardhat:
npx hardhat compile
-
Deploy Contracts: Deploy the contracts to a local or test Ethereum network:
npx hardhat run scripts/deploy.js --network <network-name>
-
Verify Contracts: After deployment, verify the contracts on Etherscan by running:
npx hardhat verify --network <network-name> DEPLOYED_CONTRACT_ADDRESS
-
Mint GovTokens: Mint governance tokens to allow users to participate in the governance process.
govToken.mint(userAddress, amount);
-
Create Proposals: Propose changes or actions by specifying the target contract, values, and calldata.
myGovernor.propose(targets, values, calldatas, description);
-
Vote on Proposals: Vote on active proposals using the governance tokens.
myGovernor.castVote(proposalId, support);
-
Execute Proposals: Once a proposal has passed and the timelock delay has elapsed, execute the proposal.
myGovernor.execute(targets, values, calldatas, descriptionHash);
This project uses OpenZeppelin contracts which are industry standard and audited. However, always ensure to audit and test your specific implementation thoroughly before deploying to a production environment.
This project is licensed under the MIT License.
This README provides a comprehensive overview of the project, including setup, usage, and security considerations. Adjust paths and commands as necessary based on your specific environment and deployment details.