Skip to content

Commit ae1f016

Browse files
committed
docs: add safesnap + kleros tutorial
1 parent 6aedb53 commit ae1f016

File tree

7 files changed

+89
-0
lines changed

7 files changed

+89
-0
lines changed
216 KB
Loading

.gitbook/assets/Safe-new-tx.png

101 KB
Loading
235 KB
Loading
164 KB
Loading
259 KB
Loading

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* [Archon: Ethereum Arbitration Standard Interaction Library](developer/archon-ethereum-arbitration-standard-api.md)
5858
* [Curate Classic: Integration for Devs](developer/curate/classic.md)
5959
* [Light Curate: Integration for Devs](developer/curate/light-curate.md)
60+
* [DAO Governance: Kleros + SafeSnap](developer/dao-governance/safesnap-kleros.md)
6061

6162
## Contribution Guidelines
6263

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# How to Create Truly Decentralized Governance
2+
3+
This is a tutorial following a previous governance [blogpost](https://blog.kleros.io/kleros-x-safesnap/) and inspired by the [separation of powers in DAOs](https://www.youtube.com/watch?v=HDSZsl1Zk4c) talk given by Jimmy Ragosa at the ETHCC4. Here, you will learn how to make your DAO fully decentralized using:
4+
5+
- [Gnosis Safe](https://gnosis-safe.io/): one of the leading multi-signature wallets used by companies to manage their crypto assets.
6+
- [Snapshot](https://snapshot.org/#/): a platform widely used for off-chain vote signaling.
7+
- [Gnosis SafeSnap](https://blog.gnosis.pm/introducing-safesnap-the-first-in-a-decentralized-governance-tool-suite-for-the-gnosis-safe-ea67eb95c34f): a Gnosis Safe module that allows trustless on-chain execution of off-chain votes using [Realitio](https://reality.eth.link/) (an escalation-game-based oracle).
8+
- [Kleros](https://kleros.io/): the decentralized dispute resolution platform and the final piece of this governance system puzzle, as it secures the Realitio outcome.
9+
10+
![](../../.gitbook/assets/Separation-of-powers.png)
11+
12+
We will dive into integrating the Gnosis SafeSnap module and Kleros with an existing DAO. For this, you will need a Gnosis Safe (learn more about it [here](https://gnosis-safe.io/#getting-started)). For testing purposes, we are going to use the [Safe App in rinkeby](https://rinkeby.gnosis-safe.io/). We are also going to be using the tools available in the Kleros' [dao-module repository](https://github.com/kleros/dao-module), so clone it and create an .env file with your parameters as shown in the [sample file](https://github.com/kleros/dao-module/blob/main/.env.sample).
13+
14+
This guide will use the Rinkeby ETH Realitio v2.1 contract at [`0xa09ce5e7943f281a782a0dc021c4029f9088bec4`](https://rinkeby.etherscan.io/address/0xa09ce5e7943f281a782a0dc021c4029f9088bec4#code).
15+
16+
## Motivation
17+
18+
You might be wondering why do we need so many blocks to achieve decentralized governance. Let's imagine that your project's treasury and smart contracts are managed by a multisig owned by team members. Furthermore, its token holders can use the project's Snapshot space to vote proposals, which should be carried out if successful, technically feasible and aligned with the project's mission. The big question is how do token holders make sure that the multisig owners will act accordingly.
19+
20+
We can interpret this as a power play between an executive team performing actions and a legislative branch voting about what actions should be taken. The missing piece is a process secured by the equivalent to the judiciary power, which enforces the token holders decisions on-chain. Here is where SafeSnap and Kleros come in.
21+
22+
## Adding the SafeSnap Module
23+
24+
SafeSnap allows anyone to propose on-chain transactions that will be executed by the DAO. Whether each batch of transactions gets executed or not depends on the Realitio's outcome, based on the DAO's proposal rules. Everyone can participate in Realitio by providing an answer with a bond in ETH or in the DAO's token and request arbitration for disputed proposals.
25+
26+
Let's start by deploying the SafeSnap module.
27+
1. Create a sample question template running `yarn hardhat --network rinkeby createDaoTemplate --oracle 0xa09ce5e7943f281a782a0dc021c4029f9088bec4`. This should provide you with a template id. For this guide we will assume that the returned template id is `0x0000000000000000000000000000000000000000000000000000000000000dad`.
28+
1. Deploy the module: `yarn hardhat --network rinkeby setup --dao <safe_address> --oracle 0xa09ce5e7943f281a782a0dc021c4029f9088bec4 --template 0x0000000000000000000000000000000000000000000000000000000000000dad --cooldown 30`. We use a low cooldown value for testing purposes.
29+
1. Verify the contract: `yarn hardhat --network rinkeby verifyEtherscan --module <deployed_module_address> --dao <safe_address> --oracle 0xa09ce5e7943f281a782a0dc021c4029f9088bec4 --template 0x0000000000000000000000000000000000000000000000000000000000000dad --cooldown 30`
30+
1. [Add the module to your Safe](https://help.gnosis-safe.io/en/articles/4934427-add-a-module).
31+
32+
33+
## The Judiciary Branch
34+
35+
If someone thinks that the current answer submitted to Realitio is incorrect, instead of submitting the correct answer with a higher bond, it's possible to relay the final resolution to an arbitrator. So, who is the arbitrator?
36+
37+
When the SafeSnap's DAO module is deployed, the Gnosis Safe multisig is set as the default arbitrator. This means that, ultimately, the signers of the Gnosis Safe have full control of what gets executed and what not, because they can approve or reject a list of transactions no matter what was voted on Snapshot. Eventually, the ruling power should be given to an impartial third party that safeguards the DAOs written guidelines.
38+
39+
40+
![](../../.gitbook/assets/Social-contract.png)
41+
42+
43+
44+
## Just use Kleros
45+
46+
In order to set Kleros as the judiciary power, i.e. the arbitrator, first go to "New transaction" and select "<> Contract interaction".
47+
48+
49+
![](../../.gitbook/assets/Safe-new-tx.png)
50+
51+
Complete with the address of the SafeSnap module you deployed earlier, select the setArbitrator function from the dropdown and, in the arbitrator field, paste the address of the Realitio Arbitration Proxy contract. This proxy supports the Realitio interface and adds some features to the arbitration process, for example, allowing appeals to be crowdfunded.
52+
53+
<img src="../../.gitbook/assets/Set-safesnap-arbitrator.png" width="400">
54+
55+
Review the transaction, submit it and voila! Now, Kleros is integrated into your DAO governance. However, there is a final thing we need to do to make the DAO truly decentralized.
56+
57+
## Removing Gnosis Safe signers
58+
59+
The Safe signers still have control over the multisig and some privileges over the SafeSnap module (like changing the arbitrator, question timeout, etc.). Let's remove those. Go to "Settings" --> "Owners" and remove all signers of the multisig except for yourself. It's not possible to have an ownerless Safe. For this reason, the remaining owner (you) has to be replaced by the SafeSnap module address.
60+
61+
![](../../.gitbook/assets/Remove-safe-owners.png)
62+
63+
Now we can say that the decentralization is completed. Your DAO has a trustless governance system. Let's go ahead and try create, dispute and execute a dummy proposal.
64+
65+
## Take'em to court!
66+
67+
We can add a proposal to the module directly using hardhat tasks. If you want to set up a Snapshot space and integrate the SafeSnap plugin, check the [Snapshot integration](https://github.com/kleros/dao-module/blob/main/docs/setup_guide.md#snapshot-integration) section.
68+
69+
1. Add a dummy proposal with `yarn hardhat --network rinkeby addProposal --module <deployed_module_address>`. If you'd like to customize the proposal, modify the `sample_proposal.json` file as you wish.
70+
1. Go to [reality.eth.link](https://reality.eth.link/app/) and look for the proposal. First, "Post" an answer and then "Apply for arbitration".
71+
1. Go to [the centralized arbitrator UI](https://centralizedarbitrator.netlify.app/), expand the "Select" dropdown and paste the arbitration proxy address in the "Enter Custom Address" field. You should see one pending dispute.
72+
1. Expand the dispute item, unselect "Give an appealable ruling" and choose the ruling to give (Yes, No or Refuse to Arbitrate).
73+
1. The arbitration doesn't automatically report the ruling to Realitio. To do so, run: `yarn hardhat --network rinkeby reportAnswer --module <deployed_module_address> --proxy <arbitration_proxy_address> --oracle 0xa09ce5e7943f281a782a0dc021c4029f9088bec4 --template 0x0000000000000000000000000000000000000000000000000000000000000dad`.
74+
1. If the Kleros resolution is "No" or "Refuse to arbitrate", the proposal won't be executed. Otherwise, anyone can execute the transactions. In this latter case, run `yarn hardhat --network rinkeby executeProposal --module <deployed_module_address>`.
75+
76+
## More About Kleros
77+
78+
There are some important reasons why your governance system should be using Kleros as arbitrator.
79+
80+
First off, a good arbitrator should be hard to attack. At the time of writing, Kleros courts have 152M PNK (~26M USD) of stakes and over 800 active jurors. A substantial input of money over a sustained period of time would have to be invested to bend a court decision and, even if someone achieves to do so, it would probably be at a huge loss. For an in depth read go to [Why Kleros Need a Native Token](https://medium.com/kleros/why-kleros-needs-a-native-token-5c6c6e39cdfe).
81+
82+
In addition, since conception, Kleros courts have resolved over 900 cases of wide variety. Check the [Famous Kleros Cases](https://kleros.gitbook.io/docs/products/court/famous-kleros-cases) to see some examples. Kleros courts are active and have built a strong reputation.
83+
84+
A good arbitrator should also be consistent over time, building jurisprudence as disputes get resolved while paying close attention to evidence and policy. This has especially been seen in the [Tokens registry](https://tokens.kleros.io/tokens) and [Proof of Humanity](https://app.proofofhumanity.id/).
85+
86+
The Kleros Court is currently used as the Judiciary branch of [the Kleros DAO, the Proof of Humanity DAO and the UBI DAO](https://governor.kleros.io/). Even though these DAO's use a different infrastructure that depends on the Kleros Governor, this is a good precedent of a well functioning decentralized governance system.
87+
88+

0 commit comments

Comments
 (0)