Skip to content

Deploy Powers using scripts

This guide explains how to deploy your own organisation using the Powers protocol. While there are no no-code solutions yet, we have simplified the process through a frontend interface and deployment scripts.

The fundamental deployment logic is the same whether you use the frontend or smart contract scripts. It follows a three-step process:

This is the core contract for your organisation, initialized with basic metadata like its name and URI.

Any dependency smart contracts (like a treasury) are deployed.

The initial set of mandates for your organisation are configured with the addresses of these dependencies.

The constitute function on your Powers.sol contract is called with the mandate configurations. This function initializes all the mandates, officially establishing the governance structure of your organisation.

This sequence ensures that the core contract is set up first, followed by its specific rules and extensions, and is finally activated in a single, atomic transaction.

The simplest way to deploy an organisation is through the Powers frontend. The entire logic for an organisation’s deployment is encapsulated in a single TypeScript file located in the frontend/organisations/ directory.

Good examples to study are Powers101.ts (a simple DAO) and PowerLabs.ts (a more complex organisation for protocol funding).

Each organisation file defines an Organization object with several key properties:

  • metadata: Contains information like the organisation’s id, title, description, and banner image URI.
  • fields: An array defining input fields that will be rendered on the deployment page. This allows for user-configurable parameters, such as a Chainlink Subscription ID in PowerLabs.ts.
  • dependencies: An array of other smart contracts that need to be deployed before the organisation can be constituted. For example, PowerLabs.ts depends on a Treasury contract.
  • allowedChains: An array of chain IDs where the organisation can be deployed.
  • createMandateInitData: This is the core function. It takes the addresses of the newly deployed Powers contract and its dependencies, along with any user input from the fields, and returns the structured data needed to call the constitute function.

Using the provided examples, you can create your own organisation file by defining its metadata, required fields, dependencies, and the logic for initializing its mandates.

Start by copying an existing organisation file like Powers101.ts or PowerLabs.ts into a new file in the frontend/organisations/ directory.

Update the metadata property with your organisation’s details. Define any input fields needed for configuration.

The powered folder contains json files for chains and the reusable Mandate.sol contracts that are deployed on them. Identify which mandates you want to include in your organisation.

The solidity/src/mandates/ folder contains the source code for these mandates.

If your organisation requires additional contracts (like a treasury), define them in the dependencies array.

Create your own custom createMandateInitData function

Section titled “Create your own custom createMandateInitData function”

This function should prepare and return the MandateInitData array, linking each mandate contract to its configuration based on the deployed addresses and any user input.

Finally, register your new organisation file in the frontend’s organisation list so it appears on the deploy a demo page. This is done by adding it to the ‘organizations’ array in frontend/organisations/index.ts.

Once your organisation file is set up and registered, you can deploy it through the Powers frontend interface.

For developers who prefer a programmatic approach, organisations can be deployed using smart contract scripts with a framework like Foundry. The solidity/script/DeployTestOrgs.s.sol script provides a clear example of this process.

The script follows the same fundamental logic as the frontend:

The script first deploys any necessary mock contracts or dependencies. In DeployTestOrgs.s.sol, this is handled by InitialiseHelpers.s.sol.

It deploys the individual Mandate contracts that will be used by the organisation. This is handled by DeployMandates.s.sol.

A new, unconfigured Powers.sol contract is deployed.

A helper contract or function (like TestConstitutions.sol in the example) is used to generate the MandateInitData array, linking the mandate contracts to their configurations.

The constitute function on the Powers contract is called with the prepared mandateInitData.

This method offers more control and is ideal for automated testing, complex setups, or integrating Powers deployment into a larger scripted workflow. By examining the test and script files in the solidity/ directory, you can build a robust deployment script for your own custom organisation.