Build a custom DAO with a few lines of code

ETHCC 6 · July 2023 · 32:52

Juliette Chevalier demonstrates how Aragon lets developers create, customize and manage onchain organizations with a small amount of code. The EthCC[6] presentation connects DAO building tools to the broader argument that changing how organizations operate can change what they accomplish.

Speakers

Topics

From ETHCC 6, hosted by Ethereum France.

Transcript

[Music] all right hello everyone hope you're having an amazing day beautiful summer in Paris my name is Julia I'm the developer advocate for Aragon and today we will be speaking about how we can customize the dial and honestly why does it even matter in the first place now I always like to go back to history when trying to map out you know why what we're building even matters and I think especially us today we're facing these Global challenges that seem unsolvable like climate change and Corruption and terrorism

um we really through as they're Biggers I always go back to this quote which is that if you want to go fast you go alone but really if we want to go far we have to go together and so we've been pondering this question of how do we organize in the world of the era of the blockchain and the hard thing is that when we're trying to end human behaviors the blockchain is immutable and yet recognizing and leadering these

organizations the world is continuously moving and so how do we build these mutable organizations on top of immutable infrastructure and this is when we reach um this stage of how to build a costume Dao we're defining a custom Dao as an organization that it runs with smart contracts on a public blockchain and when we think about how we're creating these doubts we're really looking at a variety of functionality at initial State we're just creating the organizations but what could these organizations do they can add members

they can do collective decision making they can manage Financial assets they can execute on-chain actions and the way we've thought and structured our our architecture meant that we also wanted to enable space for actions that we can't even conceive of today and so the way we've set it up is that our framework only enables you to create organizations and really everything else is enhanced through plugins so what the hell is a plugin let's take a look at what an arrogant dial looks like in a contracts so what in a core stage we have our Dow dot solve contract this is the contract that is our treasury the one that holds

all of the vaults it is the one that is able to execute actions on behalf of the Dao now like I said earlier everything else is enabled through plugins and these plugins enable you to vote to donate to end your favorite environmental organization every time you execute a transaction to bundle actions together whatever it is that you want your organization to do and these two contracts are connected through permissions each dial has its own permission database a permission library of sorts which is what are being granted or revoked to these external plugins so that they connect so that these two can connect to each other

and so the question arises right even then how are we customizing our dowels and these usually takes up two different methodologies on an initial level we can always customize them through plugins these plugins can be installed and uninstalled throughout the life cycle of the organization and to feed the needs of an evolving group however this is not the only way smart contracts are what powers Everything But ultimately we may be speaking to an audience that doesn't speak English that and understands things in a different way that needs a specific or expects a specific user behavior that may not be what we can offer at Aragon at our app or what

another other set of Builders are building currently on our stack and so when we're thinking of customizing dials we're usually looking at these two uh play spaces so what are Dow plugins in the technical landscape first let's dive into some examples I already mentioned through some before but we can again really start seeing the magnitude of what these plugins can enable and when we look at the contracts you can always think of plugins as containing at least these two key contracts firstly the plugin.sol contract this plug-in contract is your implementation

contract this is the one that has the actual logic that you would like your doubt to have it is the one that can add members vote create proposals um anything that you're thinking of the implementation logic that you want will be stored in your plugin contract now the plugin that setup the plug sorry the plugin setup contract is the one that contains the instructions this is how we're installing on installing updating plugins into dows it is the one that is containing the logic for granting revoking permissions to these to these organizations and so let's get to the Jews what we're going to do today is that

we're going to attempt to do two things um most importantly we're going to build deploy and publish a plugin and then if we have some time or go ahead and just show you how we can use the SDK to also customize your own UI otherwise at least I'll take you through how we can how we can see that in reality so to the plan all right so what I have here and let me widen my screen um is a basic hard hat project um in this hard hat project I don't have anything too crazy essentially what I have is a deploy script that would allow us to deploy our contracts

I don't have any contracts in it I have a hardhat config file which holds the configuration for the network to which we'll be deploying to and I have my package.json which has an Aragon OS X package installed and so I can store my environment variables so first thing that we'll do is that we're going to create our plugin contract now in our plugin example um we're going to do a plugin where we can add members to the dial in an ideal scenario we could go funkier and say uh adding some con some specific conditions or logic to enable adding the to adding the members we can set up additional

permissions like voting or creating proposals but for today we're merely going to add members so that we can see really in depth one specific use case so first things first for all of you solidity engineers in the room of course we add in the version of our solidity compiler in my case um vs code will not remove the error so just bear that in I know you've probably struggled with it as well we carry on now next up we're gonna and let me know if we need to make this bigger by the way um up next we're gonna create our plug-in contract so I'm going to call my plugin and add members plugin and the

way I'm going to be tapping into the OS X functionality is that I'm going to inherit from the plugin based contract from Aragon OS so what is this plug-in based contract thank you guys for asking I'm gonna go into um Aragon OS X this is our Repository and in here you can see that we have a set of folders the best way to visualize it is with this beautiful graph that I've made so when we think of our architecture for the Aragon framework we're at an initial stage looking at our core contracts these score contracts are in many ways similarly to what I just showed you before right we have the dial contract

which is for Mission management permission manager and then we have the plugin um and we have a base template for these plugins these plugins can be upgradable non-upgradable cloneable Etc now how are they interacting with each other what does the framework do and this is when we arrive to the depth of the framework on tracks the framework contracts are the factories the Registries this is the the one that's actually installing that plugin into the Dow right so we have the framework contracts for both the dial and the plugin and then we have the processor which is the one actually enforcing the actions of granting and revoking permissions to the plugin for the Dow

and we see the same thing in our repository we have the core folder we have the framework folder plugins are just plugins that we've built uh in the past our tests some additional utility so if we want to tap into this plugin based template where do we go car so we're going to the course section we dive into the plugin folder and we'll see that we already have some base templates in here I'll go ahead and click plugin and as you can see it's quite lean nothing too complex not not much too much functionality but really the magic is happening at the dial at the Dao authorizable um inheritance because this is the one

that is providing us with the modifiers that will help the permissions and I'll double into that in a second so I'll go ahead and I'll import this plugin class from my Aragon uh folder that I have and remember that I've installed my Aragon package so I can merely do this and I already have access to the plugin base and now we're going to start playing with the actual functionality so I can Define my Constructor in which I will have the dial that this plugin will be installed to if I'm using this base this is also provided me for by the base template thank you very much and then I'm going to make sure that

this returns a plug-in with um the dial and I'm gonna deposit any any additional parameters that I want in this specific case I'm going to add in a specific oh a specific voting power for the members that I'm adding so I can say you and take 646 minimum voting power and I will Define a variable up here that will be a public constant um called minimum voting power which will be zero as we kick things off and of course we can give it a one whenever we install the plugin now you can visualize this as like the

key parameters right if you're having a governance plug-in what's the minimum participation threshold that you want what's the minimum voting power that you want people to have any parameters that will be added into how you're configuring your plugins will be passed through the Constructor at this time and so we can do something like this minimum voting power equals the minimum voting power that we've defined in the parameter beautiful now let's get into the actual function so we're going to have a function that adds members and if we're adding members it means that we probably need a mapping so we're going to have a mapping of address to voting power I'm going to call this members and we're going to make this public

and then we're going to actually add the members so the members will be an address this is my new member and it'll have also a voting power so we'll just pass it and you and unsigned integer as it's voting power and inside of it I will do something like members tap into the address and create me this new member now we're getting an error no visibility let's make this external all right nice so at this stage we have our plugin this is just a smart contract there's currently no connection yet to our Dao framework aside from how we're

connecting it um in the in the Constructor but the most important thing is that right now everyone cannot a member that's not often what we want right only the Dao is able to add its own members and so this is where the Dow authorizable component becomes key because what we can do is that we can pass the modifier that says only uh addresses with the ad members permission are able to um are able to come in and actually execute this function and so that means that we need to define the permission so we can do something like bytes 32 public ads

members classic typos product members permission this is going to be a caca cash and we're going to pass it ads member permission members permission now we're going to see how this is going to rub everything together in the public setup in the plugin.setup contract so just to do a little recap We inherited from the plug the plug-in based template from Aragon OS we we created a the ad members permission this is then the permission that we're using um here for our ad members function this means that only addresses who have been granted this permission will be able to

execute this function this function is essentially adding a new member with a voting power to a member's mapping our members mapping with defined it up here and within our Constructor we have access to our Dow instance as well as any parameter that we've set for this specific plugin now keep in mind keep in mind I could also now tap into the dial inside of any function and execute actions on behalf of the dial so this this gets tricky this is where permissions are super important so that we can Gateway who is able to call on the actions um yes sir thank you great ciao

any other box that people are spotting yeah classic thank you anything else anything else guys okay we move on anyway the compiler will tell us if things are anyway so all right so up next we'll create a plug-in setup contract now the plugin setup contract is not as free right here we did whatever implementation logic that we wanted instead in the plug-in setup contract we're expecting certain functions like prepare an installation prepare and on installation prepare an update if it's

an upgradable contract so we're going to go ahead again Define our pragma solidity version um create our contract which we're going to call plug-in setup admin member ads members plug-in setup contracts and just like we did with the plugin based template this next one we're going to inherit it from the plugin setup contract so it's again let's dive into our map plugin setup is up here right because it's the one that is actually connecting the installer to the plugin implementation logic so I'm going to go ahead into my folders oh what happened I'm going to go ahead

into my folders and I'm going to look for framework we have framework here then we have plugin then we have setup then we have plugin setup again plugin setup has not much functionality except that it's expecting us to have an implementation function at the bottom to return the address of the plugin now we'll go ahead we have this that we've inherited so we need to pass it to uh we need to import it so I'm going to go in plug-in setup from this um contract over here and I'll tap into the Aragon package that we have

installed now once we have this we're going to need two key functions so first the prepare installation function then we're going to need the prepare on installation function let's make this empty for now and then like I said earlier we're going to need an implementation function that we're also going to kind of leave empty so let's dive into the prepare installation function the prepare installation function takes in two parameters firstly it'll take in the dial that will be preparing the installation for so I'm going to pass in address Tau

and then it's going to take any additional attributes that you want to be using within within this function specifically so any mem any bytes data any call data any payload essentially now this function will make it external and it's going to return what we're going to call a prepared set of data now this prepared set of data is an interface that is already provided to you by the plugin setup template that you're inheriting but it's essentially preparing the data in a way that the installer will know how to digest to install your plugin into the Dell now we're going to keep this in memory and we're going to call this return

variable just prepared set of data now once we're inside this is where we're actually going to deploy the plugin so I'm going to go ahead and I'm going to create the plugin and I'm going to say new address sorry no address wrapped new and I'm going to call in my ads members plugin that I looked that I had before which means that I now have to import it here nice

um and if I'm using this um if I'm using this variable for plugin here it means that I also need to return it so that's why I had it before right so this is the plugin that the in the the plugin setup installator will know how to install into the Dow so I have my members plugin this takes in two parameters as we defined in our Constructor firstly the dial then the voting power so I can just go ahead and wrap in this dial address that I passed through my parameters into the dial interface as well as add in the minimum voting power which I will say it's zero

now the next part is where we connect with the permissions library that I was mentioning before so if recommend if we're connecting to the permissions Library it means we need to import it so let's go ahead let's take a look at a little map we know that the permissions Library lives within the Dao within contracts so I can go ahead go into contracts go into core go into permission and I'll find in my permission Library now the permission Library contract has a few um a few assets that we can use it has the operation NM which is how we'll be granting revoking or even

granting with a condition if we wanted to it has a single Target permission which is like a quick and Speedy way of adding and adding in a permission to your to your actions and then it has a multi-target permission which is a bit a bit more complex right a bit funkier it has a condition it has um the wear specific to the plug-in so we can do a bit more fun stuff with it so even though we're only going to do one permission we're going to be using the multi-target permission so that we can see how this could look in practice so I'm going to inherit the permission Library contract same as we've been doing before

I'm gonna import um permission library from this contract oh wait from OS X and now I'm gonna have access to it which means that I can call my multi-target permission array that we were seeing before now this will be stored in memory and we will call it permissions and we'll Define its its type which is essentially this so we're initializing it and saying that it'll contain one permission as we defined below I'm going to wrap all of

this so that you can see it within a similar screen now now that we've defined it we're going to go into it and we're going to add in the permission that we want to be uh adding so the first item will be a permit I can just copy this oh just copy this um a permission type and if I go into the contract I can see exactly the types that it's expecting so I can almost just even like copy this um have it here as a comment and we can start going through it so the first thing that it needs is the operation

because we're installing the plugin this operation will be granting then to where should where should this be granted it should be granted to the plugin which we have access to thanks to initializing it up here who is deserving this permission the Dao which we have access to because with pasta in the parameters then under which condition in this case we don't have any conditions so we can simply say permission Library no condition as you can see from the contract this is just an address here that we've settled for so that people can import and then we can go ahead and set up

which oh Define which permission are we granting and this is where we pass in that kekak that we just that we set up before and this is where if you do a typo everything gets messed up so do not now lastly what we want to do is add in that permissions library to the prepared set of data objects that we're returning so we can do prepared setup data permissions equal to the permissions that we both defined above and that's it with that we're able to install this plugin into the dial that this plugin into the dial that we've set up

and the prepare on installation function is relatively similar except you can guess it rather than granting it's going to be revoking so I'll go ahead and I'm going to take a few parameters as well firstly the address of the dial that I'll be preparing the on installation for uh then I'm gonna take I'm going to take a setup payload um this would be a bit different because rather than it being distorted in memory it's actually a call data and this is the payload that we'll be using to grab in the actual plugin that will be uninstalling from the Dow and then we can set up that this is an external function and that this returns

a similar object as to what we had before so it's a permission Library multi-target permission and we're going to call this um permissions and just pass it the exact permissions uh variable that we defined earlier now once we're inside we're going to start playing with a similar structure as what we did before firstly we're going to initialize this permissions variable so we say new and I have it copied here nice permission multi permission Library multi-target permission and this is only one permission and we're going to go ahead and do a similar thing so we have

permissions 0 in this case um we're gonna go in with the same structure as we've defined above except for a few changes and the changes are the following rather than granting we are revoking right we're revoking the permission so that the Dow no longer has access to that plugin sorry the plugin no longer has access to the Dow now where we no longer have access to this plug-in variable and so this we're going to actually get from the payload where in the Dow permission no condition and this is the permission that we're revoking and with this now we just add in this some access to the plugins that I can

see this it should actually return the address of the Dow sorry of the plugin and with that we are done that's our plugin so if we recap we have the implementation logic stored in the plugin contract and then we have the installation and the uninstallation functions that will enable the plugin installer to install that dial that plugin into your dial now keep in mind that this function is always the same you are setting the amount of permissions that you want to be performing some action on some operation on you define the operations here and if I wanted to add in more permissions I

could just keep adding them in here and it'll be added into my set of data that's the information that the installer will use and then the only installation is exactly the same so with that we'll go ahead and try to compile things will fail and we'll do a call Boards of effort of getting them right so at members plugin the naming I spotted earlier that was off all right so let's try it out um like I said before we have a script a deploy script here that will deploy our plugin so which plugin are we deploying the odd members plugin this is an s yes

s right um and the other thing to note is that check out that we're only deploying the plugin setup contract why because the plug-in contract is being deployed inside the initializer of the installation okay off we go uh npx do we need this bigger probably yes npx hard hat run scripts deploy TS let's see what happens cool um right Mr semicolon where from this is plug-in setup line four

oh here nice easy one let's see what else comes up uh initialize probably constant August I just set it up to zero why do I need to define it uh I guess it's a constant so if we just do that that should work then what else relevance versus start here and starts oh sorry about your girlfriend with missing implementation prepare on installation [Music] ah an N after the U

wait it's not moving oh there we go oh nice nice catch Spencer concert yes then here gonna assign to a constant variable yeah we already fixed that one um type struct let's do another run so that we can get a cleaner look into the errors overridden function here prepared on installation mm-hmm not explicitly converge I have some

notes one minute left oh all right well we have one minute left uh essentially we would huh essentially we would debug it and deploy it um the easier thing about this is that once you have it deployed you can just go into etherscan um we have the active contracts within the repository itself and so you'll be able to get in the plugin repo Factory if this moves here so we're able to get the plug-in repo Factory [Music] oh this mouse is not helping

here we go nice nice um so we can get the plug-in repo Factory go into address and immediately just within even etherscan of course there's fancier ways to do it but we should be able to write and just publish our contract here think of maybe missing a number and then after that you can use it just through the SDK and set up a custom dial I've added a bit of a repository here where you would just get to call into your into your Dao call in the pass in some parameters to deposit and then you just call them the SDK and say hey deposit with these parameters into this dial that I've set up and we can do the same thing to get the members we can do

the same thing to get proposals and so essentially we're using this underlying infrastructure powered through the SDK to create both our custom uis as well as the contracts for our Dow thanks very much guys okay as we are over time maybe if you want to ask any question to us Juliet you can do it outside and otherwise um there is the closing on the main stage so yeah feel free to go it's in uh Amazon de la mutuality which is the other venue thank you so much [Music]

[Music]