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:
1
function deploy(bytes calldata deployData) external payable override(Factory, IFactory) virtual returns(address productAddress, bytes memory productInitResponse)
Copied!
The deployData is the encoded value of the OrganizationDeployData struct composed as follows:
1
struct OrganizationDeployData {
2
string uri;
3
bytes[] mandatoryComponentsDeployData;
4
uint256[] additionalComponents;
5
bytes[] additionalComponentsDeployData;
6
bytes[] specialComponentsData;
7
bytes specificOrganizationData;
8
}
Copied!
  • 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.
1
function proposeToAttachOrDetach(address delegationAddress, address delegationsManagerAddress) public returns(bytes32 proposalId)
Copied!
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:
1
// Proposal Manager init data
2
mandatoryComponentsDeployData[0] = abi.encode(['tuple(address[],uint256[],uint256[],address,address,address[],address[])'], [
3
[
4
[], //address[] collections
5
[], //uint256[] objectIds
6
[], //uint256[] weights
7
utilities.voidEthereumAddress, //address creationRules
8
utilities.voidEthereumAddress, //triggeringRules
9
[], //address[] canTerminateAddresses
10
[] //address[] validatorsAddresses
11
]
12
]);
13
//Treasury Manager init data
14
mandatoryComponentsDeployData[1] = abi.encode(['addresss'], [
15
[
16
utilities.voidEthereumAddress
17
]
18
]);
19
//Delegation Tokens Manager init data
20
mandatoryComponentsDeployData[2] = abi.encode(["tuple(address,string,string,string)"], [
21
[
22
utilities.voidEthereumAddress, //host address
23
"yourName", //name
24
"yourSymbol", //symbol
25
"yourUri", //uri
26
]
27
]);
28
29
30
31
var organizationDeployData = {
32
uri: "",
33
mandatoryComponentsDeployData,
34
additionalComponents: [],
35
additionalComponentsDeployData: "0x",
36
specialComponentsData: '0x';
37
specificOrganizationData: '0x'
38
}
39
40
data = abi.encode(["tuple(string,bytes,bytes[],uint256[],bytes[],bytes)"], [Object.values(organizationDeployData)]);
41
organizationFactory.methods.deploy(data).send({from : myAddress})
Copied!
Use this example pattern to create your own deployData.