A decentralized governance system for Kaly Chain, enabling on-chain governance using native KLC token for voting power.
- Native Token Governance: Use the KLC native token for voting by wrapping it
- Secure Treasury Management: Store and manage funds controlled by governance
- Transparent Governance Process: Propose, vote, queue, and execute changes on-chain
- Timelock Security: Every governance action requires a time delay for security
- Clone this repo:
git clone https://github.com/KalyCoinProject/dao-contracts
cd dao-contracts- Install dependencies:
yarn
# or
npm i - Run the test suite:
yarn hardhat test
# or
npx hardhat test- View test coverage:
yarn hardhat coverage
# or
npx hardhat coverageOur test suite verifies all aspects of the DAO functionality:
- Deposit/Withdraw: Verifies users can wrap native KLC to get gKLC tokens and unwrap them back
- Voting Power: Confirms governance tokens provide voting power after delegation
- Token Transfers: Tests that token balances update correctly after transfers
- Ownership Control: Only governance can access treasury functions
- Fund Management: Tests sending and receiving both native tokens and ERC20 tokens
- Proposal Execution: Verifies treasury operations can be executed through governance
- Full Governance Flow: Tests the entire proposal → vote → queue → execute pipeline
- Financial Transactions: Validates governance can manage treasury assets
- Timelock Protection: Ensures proper delays between approval and execution
- Add a
.envfile with the same contents of.env.example, but replaced with your variables.
DO NOT PUSH YOUR PRIVATE_KEY TO GITHUB
- Deploy to a testnet:
npx hardhat deploy --network [NETWORK_NAME]Here's what happens in our DAO system:
-
Token Setup: We deploy a Governance Token (gKLC) that wraps the native KLC token to enable voting
- Users deposit native KLC to receive gKLC with voting power
- Users can withdraw their KLC at any time by burning gKLC
-
Timelock Deployment: We deploy a Timelock contract that adds security by enforcing delays
- The timelock is the contract that will handle all the money, ownerships, etc
- Provides a buffer period for users to review proposed changes
-
Governance Contract: We deploy our Governance contract to handle proposals and voting
- The Governance contract manages proposals and voting, but the Timelock executes!
- Uses the popular OpenZeppelin Governor framework
-
Treasury Management: We deploy a Treasury Vault, owned by the governance process
- Can receive and send both native KLC and any ERC20 tokens
- All operations require passing a governance proposal
-
Proposal Lifecycle:
- Propose: Anyone with enough voting power can propose actions
- Vote: Token holders vote during the voting period
- Queue: Approved proposals are queued in the timelock
- Execute: After the timelock delay, the proposal can be executed
You can manually test the governance flow:
- Setup local blockchain:
yarn hardhat node- Propose a new value to be added to our Treasury contract:
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 localhostKalyChain Mainnet:
Governance Token: 0x4BA2369743c4249ea3f6777CaF433c76dBBa657a
Governor Contract: 0xF6C1af62e59D3085f10ac6F782cFDaE23E6352dE
Timelock Contract: 0xA11572e9724dfeD2BCf8ecc9bfEd18CC609C4c6D
Treasury Contract: 0x92564ec0d22BBd5e3FF978B977CA968e6c7d1c44KalyChain Testnet:
Governance Token: 0xF917BdbeFc80EC42A091F9E466C794684a95327E
Governor Contract: 0x3ce8eDA4c48635983F15af7D3Dae96C8D9Ae593d
Timelock Contract: 0x34AcBA229Aeaf7F1c0f442633F35E26Bc94b4e2A
Treasury Contract: 0x5E65BEC7D118751c3b92BBccD1bEE8165e663b4bDistributed under the MIT License. See LICENSE for more information.
Kaly Chain Team - https://kalychain.io
Project Link: https://github.com/KalyCoinProject/dao-contracts