@digix/dao-contracts
v0.1.4
Published
Smart contracts for DigixDAO
Downloads
84
Readme
DigixDAO
This repository contains the Ethereum Smart contracts for DigixDAO.
Setup
Installing Pre-requisites
The following are the key dependencies for setting-up/testing DigixDAO:
Install all dependencies (in the dao-contracts
directory):
npm install
Compiling
Compile using:
npm run compile
You may want to delete the build/
directory before re-compiling
Simulating DigixDAO
We have written a script to simulate basic functionality of DigixDAO. This script can be run by:
npm run test:simulate
This runs the test/simulateDao.js
code. Re-usable javascript functions can
be located in test/setup.js
and test/daoHelpers.js
.
Testing
We are in progress of improving the test coverage of DigixDAO contracts. All tests can be
located in the test
directory, segregated by the storage
, service
and
interactive
layer. You can refer to this for an overview of how the tests work.
Before running any tests, you need to run Ganache, a development Ethereum instance, in a separate terminal:
npm run ganache
To test the interactive/DaoFundingManager
contract:
node_modules/.bin/truffle test test/DaoFundingManager.js
To test the storage
layer:
node_modules/.bin/truffle test test/storage/*
Note: The truffle configuration can be found in the
truffle.js
file. Ganache running locally is the development
network.
Building documentation using doxity
Doxity is a really cool tool to generate a static page for contract documentations.
Install dependencies for the doxity project
cd scripts/doxity/
npm install
After making modifications to the contracts (or adding Natspec), to compile the documentation from contracts
npm run docs:compile
To publish the compiled documentation into HTML pages
npm run docs:publish
To start the Gatsby server
npm run docs:server
You can now view the documentation at http://localhost:8000
The latest documentation based on the master
branch is available here
Understanding DigixDAO
To understand how DigixDAO works, the best place to start is reading the Governance Model paper
Feel free to join our Discord channel, dgdao-governance
room, to talk about DigixDAO governance.
Auditing of DigixDAO contract codes
These are the absolutes/invariants of DigixDAO contracts. If you can make any of these absolutes false, you have found a bug in our contracts.
The contracts' functions have also been extensively commented on their purpose and expected behaviour. If those comments do not hold, it's highly likely that you have found a bug in our contracts.
Feel free to try to break our contracts and please contact us if you successfully find a bug.
Contributing
We welcome pull requests from developers. We highly recommend interested developers to go through the DigixDAO Governance Model.
Smart Contract Architecture
Most of our contracts have been documented extensively in their codes. This is an overview of what each contract does:
Contract Resolver
Most contracts implement the Resolver Client contract, whose addresses are securely fetched from one Contract Resolver.
Storage Layer
The Storage layer contracts interact with Ethereum's persistent storage. They can only be used publicly to read from public
functions. All the functions that can update the state variables can only be called from specific DigixDAO smart contracts, for example, this. We try to include as less as possible logic in contracts under this layer. The storage layer contracts are:
- DaoStorage (proposals)
- DaoSpecialStorage (Special proposals)
- DaoStakeStorage (participant stakes)
- DaoRewardsStorage (DGX rewards for participants)
- DaoPointsStorage (quarter and reputation points)
- DaoIdentityStorage (KYC information)
- DaoConfigsStorage (configuration for DigixDAO)
Interactive Layer
The Interactive layer contracts can be called publicly. They contain DigixDAO's logic. DigixDAO's logic is segregated into multiple parts, namely:
- DaoFundingManager
- Handles incoming and outgoing DAO funds
- DaoRewardsManager
- Handles DGX rewards and reputation between quarters
- Writes to the DaoRewardsStorage storage layer contract
- DaoStakeLocking
- Handles user stake in DigixDAO
- Writes to the DaoStakeStorage and DaoRewardsStorage storage layer contract
- Dao
- Handles DigixDAO proposals and migration to a newer version of DigixDAO
- Writes to DaoStorage and DaoSpecialStorage storage layer contracts
- DaoVoting
- Handles voting logic in DigixDAO
- Writes to DaoStorage, DaoSpecialStorage and DaoPointsStorage storage layer contracts
- DaoVotingClaims
- Handles the logic of settling/claiming a voting result
- Writes to DaoStorage, DaoSpecialStorage, DaoPointsStorage and DaoConfigsStorage storage layer contracts
- DaoIdentityStorage
- Handles the logic related to DigixDAO Directory (role and group management)
- Writes to DaoIdentityStorage storage layer contract
Modifiers
Conditional checks and authorizing msg.sender
is done in the DaoCommon.sol contract.