This repository has been deprecated.
Please use this repository for the currently supported Fractal smart contracts:
https://github.com/decent-dao/fractal-contracts
The DAO factory contract enables deploying new Fractal MVDs, which at their core consist of two contracts: DAO.sol and AccessControl.sol
The DAO contract contains the minimum viable core functionality required for a DAO. Primarily, this consists of the execute function, which can be passed any arbitrary function call to be made from the DAO's behalf, assuming the caller has the correct permissions.
The Access Control contract contains functionality for handling all access permissions within the DAO contract, and any associated modules. Roles and admins of the roles can be assigned to addresses. These roles can then be given permissions to execute actions, which are defined by function signatures within the DAO contract, and any modules assocaited with the DAO.
Clone the repository:
git clone ...
Lookup the recommended Node version to use in the .nvmrc file and install and use the correct version:
nvm install
nvm use
Install necessary dependencies:
npm install
Add .env
values replacing the private key and provider values for desired networks
cp .env.example .env
Compile contracts to create typechain files:
npm run compile
Run the tests
npm run test
npx hardhat deploy --network <network>
To deploy the base Fractal contracts open a terminal and run:
npx hardhat node
This will deploy the following contracts and log the addresses they were deployed to:
- DAOFactory
- DAO Implementation
- AccessControl Implementation
A hardhat task has been created for deploying a DAO which accepts all the necessary arguments. The DAOFactory address and DAOImplementation address deployed in the previous step should be passed as parameters when using this task. An example DAO deployment using this task is shown below.
npx hardhat createDAO \
--creator "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" \
--dao-factory "0x5FbDB2315678afecb367f032d93F642f64180aa3" \
--dao-implementation "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" \
--access-control-implementation "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" \
--dao-name "Decent DAO" \
--roles "['EXECUTE_ROLE','UPGRADE_ROLE']" \
--roles-admins "['DAO_ROLE','DAO_ROLE']" \
--members "[['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266','0x70997970c51812dc3a010c7d01b50e0d17dc79c8'],['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266']]" \
--dao-function-descs "['execute(address[],uint256[],bytes[])','upgradeTo(address)']" \
--dao-action-roles "[['EXECUTE_ROLE'],['EXECUTE_ROLE','UPGRADE_ROLE']]" \
--module-targets "[]" \
--module-function-descs "[]" \
--module-action-roles "[]" \
--network localhost
If the transaction succeeds, the task console logs the address of the deployed DAO and Access Control contracts.
Each module implementation contract should inherit from the abstract contract ModuleBase.sol. This gives modules functionality for:
- Access control for function calls
- Upgradeability using the UUPS proxy standard
- ERC165 support
Modules should be deployed on chain from a module factory contract which should inherit from the abstract contract ModuleFactoryBase.sol. This gives module factories funcionality for:
- A standardized create function for deploying a new module instance, that can be utilized by a higher level factory contract
- Module implementations version control and tracking
- ERC165 support
The core contracts in this repository are published in an NPM package for easy use within other repositories.
To install the npm package, run:
npm i @fractal-framework/core-contracts
Including un-compiled contracts within typechain-types. Follow theses steps hardhat plug-in https://www.npmjs.com/package/hardhat-dependency-compiler
- Update the version in
package.json
npm install
to get those version updates intopackage-lock.json
npm run publish:prepare
to fully clean the project, compile contracts, create typechain directory, and compile the typechain directorynpm publish
to publish the compiled typechain files and solidity contracts to NPM- git commit and push