Deploy your own Powers

Interested in creating your own Powers?

🚧 This page is a work in progress. 🚧

Deployment sequence

At the moment, a no-code solution to deploying Powers does not exist. It is scheduled for inclusion in v0.4 of the protocol.

Currently, deploying Powers is done in three steps.

  1. Deploy Powers.sol.

  2. Create a constitution adopting existing Law.sol contracts.

  3. Adopt the constitution in your Powers.sol deployment.

Let us expand on these steps. All examples are build in Foundry. If you are not familiar with Foundry, please see the documentation herearrow-up-right.

circle-info

You can check out your Powers by navigating to https://powers-protocol.vercel.app[chain id here][address of your Powers here].

For example, a Powers implementation ('Powers 101') that is deployed on the optimism sepolia testnet can be viewed at: https://powers-protocol.vercel.app/11155420/0x1978d642224e047487DFFAb77FAD3B17f068eB79arrow-up-right

Step 1: Deploy Powers.sol

Deploying the Powers contracts is straightforward. The constructor function takes two variables: a name and a uri to metadata.

vm.startBroadcast();
Powers powers = new Powers(
    // Name of the DAO
    "My First Powers", 
    // IPFS link to metadata. See the link for an example layout of this json file. 
    "https://aqua-famous-sailfish-288.mypinata.cloud/ipfs/bafkreicwiqgcvzqub6xv7ha37ohgkc3vprvh6ihqtgs7bk235apaadnqha" 
);
vm.stopBroadcast();

At this stage, the Powers contract cannot do anything because it does not have any laws. We need to call the 'constitute' function to implement a constitution.

Before we can do that, we need to create the constitution of our Powers implementation.

Step 2: Create a constitution

A constitution is an array of LawInitData structs, that is used as input for the constitute function.

circle-info

IMPORTANT!

As Powers adopts laws, each law is given an index. The index starts at 1, not zero. The first law to be adopted gets index 1, the second 2, and so on.

When referring to laws that need to be completed (conditions.needCompleted), can veto (conditions.needNotCompleted) or record state (conditions.readStateFrom) we need to refer to the index the law will have in your Powers deployment - not in your LawInitData array!

To avoid confusion, it is easiest to start populating the LawInitData array at position 1 as well, keeping the locations and law indices the same.

This is the LawInitData struct:

A typical (but in this case very short) constitution will look something like this:

Step 3: Adopt a constitution

Call the constitute function in your Powers instance, using the array of LawInitData structs we just created.

Et voila! You deployed an on-chain Powers 👏

Example deploy scripts

The deploy scripts for several example Powers implementations can be found at:

Last updated