DAO Framework: How to Code a DAO with Aragon Smart Contracts
A DAO is an organization that is distributed, self-governing, and blockchain-enabled. Think of it as an organization that uses a blockchain, such as Ethereum, as its coordination mechanism.
At its core, a DAO is a piece of software (a compilation of smart contracts) on the blockchain that manages permissions of contracts and people to be able to execute actions within the organization.
DAOs perform actions on-chain, such as voting with tokens, sending cryptocurrencies, staking assets, and more. To perform actions on-chain, they use smart contracts. They also perform actions off-chain, such as hold signaling votes and day-to-day coordination between teams.
Smart contracts underpin the entire web3 ecosystem. They are the backbone of the trustless, permissionless structures we build.
What is a smart contract?
Smart contracts are lines of code that interact with the blockchain. Think of them as “if, then” statements that are coded on-chain. They perform an action automatically and without human intervention as long as a certain parameter is met.
For example, a voting contract would execute the results of a proposal (such as a request to transfer funds) if the results of the vote met the parameters decided by the DAO, such as quorum and pass rate.
You can think of smart contracts as a vending machine. You click a button asking for a chocolate bar, and the vending machine automatically gives you the thing you requested without any human intervention.
You can also think of smart contracts as yellow cartoon minions that wait to be told what to do. They are programmed to execute an action, and then when it’s done, they wait for the next action. Just like these minions, smart contracts are reliable to get the job done when you need them to.
“A smart contract is a contract that enforces itself.”
—Vitalik Buterin, Self-Enforcing Contracts and Factum Law, Ethereum blog, 2014
Smart contracts are trustless—meaning you don't need to trust humans to behave in a certain way—because they automatically execute actions when certain parameters are met.
They’re also permissionless because anyone in the world can use them, no matter who you are, your country of residence, or any other factor that could be used to stop someone from using them.
Smart contracts make up the backend of a DAO, but the frontend looks like any other website you’re familiar with, no-code, allowing anyone to participate in a DAO. If this is what you think will work for your organization, sign-up for our app’s waitlist.
You need a crypto wallet to interact with smart contracts. To learn more about using decentralized crypto wallets in DAOs, read our guide.
What is a DAO framework?
A DAO framework is an open-source compilation of smart contracts that anyone can use to create an on-chain organization, meaning an organization that uses the blockchain as its base layer of coordination.
DAO frameworks focus on the most important function of DAOs: decision-making.
The smart contract for a DAO usually includes voting parameters such as:
Voting type: some DAOs permit only an allowlist of wallets to vote, restricting who is able to participate in an organization’s decision-making. Others use token voting, where a DAO’s native token is used as voting chips. This means the more tokens you hold, the more voting power you have. The on-chain token address would be included. There are tons of governance options being experimented on today.
- Quorum: the number of votes that need to be cast for a vote to be valid. If there isn’t high enough voter or token turnout, the vote should fail.
- Pass rate: the percentageamount of “yes” votes that need to be cast for the proposal to pass.
- Voting period: the amount of time a vote is live.
At Aragon, we make DAO frameworks for organizations to use to run on-chain. You can find them on our Github.
Read more our guides to dive deeper into governance, such as types of voting and parameters.
Benefits of having an on-chain organization
Some organizations are well-suited to operating on-chain, and find that being on-chain solves many of their problems. Here are a few benefits of having an on-chain organization:
Trustless, permissionless voting and execution of votes. A truly decentralized organization does not have a middleman executing the results of a vote. For example, say a team wants to be funded to build a product. They put up a proposal, and if enough wallets or tokens are cast for “yes,” then that team is automatically sent the funds from the DAO’s treasury. This means there are no middlemen or people to rely on in-between.
Store a treasury of assets rather than needing multiple bank accounts in different countries. If you have an organization that spans countries and continents, managing payments can be a huge hassle. In DAOs, you store your treasury on-chain, meaning it is in cryptocurrencies that can be sent anywhere in the world and to anyone, so it’s easier to pay contributors.
The blockchain as a single, transparent source of truth. No one can alter the history of the blockchain, so it acts as a single source of truth for everyone in the organization.
Challenges of having an on-chain organization
However, there can be some unique challenges to running an organization on-chain, such as:
Blockchain immutability makes it hard for DAOs to evolve: The blockchain is immutable, meaning everyone can add entries to it but no one can go back and change the previous entries of anyone else, including themselves. Think of the blockchain as a universal spreadsheet without an “edit” button. This makes the blockchain useful for a single source of truth, but a unique challenge when it comes to evolving organizations.
There’s no undo button: If you send a transaction to the wrong address, there’s no way to reverse it. Blockchains are irreversible in their nature.
Legal gray area: There is no clear meatspace jurisdiction that DAOs should reside in. This can make it difficult for contributors who need legal forms like tax forms or income statements. Many people use solutions like Opolis or WorkDAO. Or, consider learning more about legal wrappers.
How do you code a DAO?
At its core, a DAO is built by several smart contracts deployed on a blockchain. A smart contract is essentially an “if, then” statement that executes actions automatically when certain parameters are met.
Smart contracts on the Ethereum blockchain are coded in the programming language Solidity. If you peruse a web3 project or a DAO’s Github repository, you will stumble across some Solidity files. You can tell the code is written in Solidity because it starts with “pragma solidity ^” with the version of Solidity it was coded in (such as 0.8.4) at the top. The file will also be saved as “.sol”.
Solidity contracts deployed to the blockchain are entirely transparent and open-source, meaning anyone can read them and use them.
Additionally, smart contracts have parameters inside of it that the developer sets. These parameters include restrictions on voting such as vote quorum, vote duration, and pass rate.
The coded version of a DAO is really just a permission management system, meaning it’s a system that manages who can perform certain actions in the DAO and how. For example, one of the most important permissions to manage is access to the DAO treasury. The DAO regulates access by requiring votes of certain parameters to reach it.
Once the smart contract for a DAO is deployed on the blockchain, you cannot change that version. Instead, you need to upgrade to a new version of that contract by deploying a whole new instance of that contract.
Coding a DAO is simple when you use the existing templates, like Aragon contracts. Thanks to open source software, developers can build faster because they can build on top of progress already made by others. When approaching your DAO development project, start with an open-source contract and go from there!
We’ve created a permission management system to retain the good parts of being on-chain (trustless and permissionless management of organizations) while eliminating the bad (inflexible, don’t adapt as your organization does).
What is a permission management system?
A permission management system is a framework for on-chain DAO operations and decision-making. It’s a smart contract that manages permissions to other smart contracts, so it’s easy to grant and revoke permissions as your DAO evolves.
Let’s break down the details of a permission management system. All DAOs have three main components: community, treasury, and coordination.
Community: people working together to achieve a common goal.
On-chain action: make collective decisions via voting.
Treasury: on-chain assets governed by the community.
On-chain action: deposit and withdraw funds
Coordination: people coordinating to decide how to use those on-chain assets.
On-chain action: execute actions on addresses/contracts.
All of these actions—making decisions, depositing and withdrawing funds, and executing actions on addresses and contracts—are really just managing permissions. So, we built a flexible, modular permission management system that makes it easy to grow and evolve your organization.
Our contracts are little legos that fit together and support any type of organization that wants to build on top.
The protocol itself is very lean. Every other functionality is built through plugins.
You can envision our protocol containing three main sections:
The DAO and its factory: the contracts that create DAOs, store them in the DAORegistry, and where DAOs manage their assets. You can envision the DAO.sol contract as a vault, enabling addresses (with certain permissions, of course) to withdraw and deposit assets.
The permission management system: these are the contracts that determine which addresses (be them contracts or accounts) are able to execute which actions.
The plugins and their manager: this is where we publish plugins, store them, and manage their versions. It contains the logic and the installing instructions for each of the plugins published to the protocol.
Why plugins are the future of more adaptable DAOs
Let’s walk through building a DAO on Aragon.
Say you have a telegram group of friends who are passionate about investing in NFTs. You decide you want to create an investment DAO.
You’ll be able to enter into the App, then click the Create DAO button. This calls the DAO factory in our protocol and creates DAO.sol, the DAO instance on the blockchain.
Now, you and your friends add the plugins you want at first. Since it’s just a small group of you in a telegram chat, you just need a Uniswap plugin to swap tokens and a Lido plugin to stake assets. So, you use the plugin manager to grant permissions to those two plugins.
But your telegram group grows to include more than your small group of friends. You realize you need a better way to coordinate so the treasury is properly allocated. Instead of having to start over from scratch to add voting to your on-chain DAO, you simply grant access to a new plugin.
Maybe you want to test NFT voting in your DAO. Again, you won’t have to start over. You simply revoke permissions to the ERC20 voting plugin and grant permissions to the ERC721 plugin.
Even though the DAO itself (DAO.sol) is immutable, you can keep the protocol flexible over time because you’re managing permissions of outside contracts.
Inspired? Come build plugins and DAOs with us!
To get started building, join our developer group chat in Discord. You can also find us on Github and read our developer documentation.