Deploy a Delegation Using the Delegation Factory

An entire Delegation can be deployed using the Delegation Factory in a single transaction. You can use the Delegation Factory on the EthereansOS platform here (link coming soon).

The Delegation Factory, which is a custom Factory, allows you to clone (via the deploy function) your Delegation, link Components and initialize everything at once.

A Delegation is cloned with the following Components:

  • Proposal Manager

  • Treasury Manager

  • Delegation Token Manager

Deploy the Delegation

The deploy method of the Factory takes as input the deployData parameter:

function deploy(bytes calldata deployData) external payable override(Factory, IFactory) virtual returns(address productAddress, bytes memory productInitResponse)

The deployData is the encoded value of the OrganizationDeployData struct composed as follows:

struct OrganizationDeployData {
    string uri;
    bytes[] mandatoryComponentsDeployData;
    uint256[] additionalComponents;
    bytes[] additionalComponentsDeployData;
    bytes[] specialComponentsData;
    bytes specificOrganizationData;
  • string uri -> this uri parameter contains the Delegation's metadata. The Delegation contract implements the DynamicMetadataCapableElement, so that you can set a traditional or a dynamic uri (see here to learn more).

  • bytes[] mandatoryComponentsDeployData -> this init data is used to initialize the Proposal Manager, Treasury Manager, and Delegation Tokens Manager that are mandatory Components of the Delegation.

  • uint256[] additionalComponents -> this is an index of the additional Components that you want to link to the Delegation. Look below to find the Component indices.

  • bytes[] additionalComponentsDeployData -> this init data is used to initialize the additional chosen Components. Each position in the bytes array corresponds to the sequentially equivalent position in the additionalComponents array.

  • bytes[] specialComponentsData -> pass empty.

  • bytes specificOrganizationData -> pass empty.

Propose to Attach

The proposeToAttach function can be used, after the Delegation deployment, to attach it to a Delegations Manager.

This function can be called only by the address that called the deploy function to deploy the Delegation.

function proposeToAttachOrDetach(address delegationAddress, address delegationsManagerAddress) public returns(bytes32 proposalId) 

The function takes as input:

  • address delegationAddress -> address of the Delegation to attach.

  • address delegationsManagerAddres -> address of the Delegations Manager to which the Delegation is going to be attached.

How to Pass the deployData

The deployData to pass is composed as follows:

// Proposal Manager init data
mandatoryComponentsDeployData[0] = abi.encode(['tuple(address[],uint256[],uint256[],address,address,address[],address[])'], [
        [], //address[] collections           
        [], //uint256[] objectIds
        [], //uint256[] weights
        utilities.voidEthereumAddress, //address creationRules
        utilities.voidEthereumAddress, //triggeringRules
        [], //address[] canTerminateAddresses
        [] //address[] validatorsAddresses
//Treasury Manager init data
mandatoryComponentsDeployData[1] = abi.encode(['addresss'], [
//Delegation Tokens Manager init data
mandatoryComponentsDeployData[2] = abi.encode(["tuple(address,string,string,string)"], [
        utilities.voidEthereumAddress, //host address           
        "yourName", //name
        "yourSymbol", //symbol
        "yourUri", //uri

var organizationDeployData = {
    uri: "",
    additionalComponents: [], 
    additionalComponentsDeployData: "0x",
    specialComponentsData: '0x';
    specificOrganizationData: '0x'

data = abi.encode(["tuple(string,bytes,bytes[],uint256[],bytes[],bytes)"], [Object.values(organizationDeployData)]);
organizationFactory.methods.deploy(data).send({from : myAddress})

Use this example pattern to create your own deployData.

Last updated