Skip to content
This repository was archived by the owner on May 8, 2023. It is now read-only.

Commit ffa2523

Browse files
committed
Add colony creation guide text
1 parent b963acb commit ffa2523

File tree

2 files changed

+93
-3
lines changed

2 files changed

+93
-3
lines changed

docs/guides/colony-creation.md

+92-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,97 @@
11
---
2-
description: A guide on how to create a colony. The deployment of a colony require a few transactions for it to be up and running and fully usable. This guide explains how to go through the whole process in Colony SDK.
2+
description: A guide on how to create a colony programmatically. The deployment of a colony requires a handful of transactions for it to be up and running and fully usable. This guide explains how to go through the whole process using Colony SDK
33

4-
sidebar_position: 0
4+
sidebar_position: 1
55
---
66

77
# Creating a colony
8+
9+
Even though deploying a Colony is technically just a matter of issuing one transaction, for the colony to be properly set up and usable in the dApp, some extra steps are necessary. In this guide we'll walk you through the whole process of creating the right transactions and explain what happens on the way.
10+
11+
**Keep in mind that some of these transactions are optional and depend on your specific situation.**
12+
13+
14+
For a full example see [here](https://github.com/JoinColony/colonySDK/blob/main/examples/node/create.ts).
15+
16+
:::info
17+
These examples assume that the user executing the transactions has funds in their wallet to pay for gas. If you'd like to use gasless transactions instead, use `forceMeta()` instead of `force()`.
18+
:::
19+
20+
## Step 1 (optional) - Creating a token
21+
22+
If you don't have a token contract deployed yet that you wish to use as the native token in your colony, deploying it using the Colony Network is highly recommended. That will give you a better integration and control over your token from your colony (e.g. using the `mintTokens` function on the colony).
23+
24+
To deploy a token, call the `deployToken` method on `ColonyNetwork`:
25+
26+
```typescript
27+
// Create token to be used with Colony
28+
const [{ tokenAddress }] = await colonyNetwork
29+
.deployToken('Test token', 'TOT')
30+
.force();
31+
console.info('Token address', tokenAddress);
32+
```
33+
34+
One can specify the token name, its symbol and even its decimals (even though it's recommended to leave that at the default value). This will deploy a special ERC20 token that integrates well with Colony (e.g. it supports permissions, minting and gasless transactions out of the box). For its contract code see [here](https://github.com/JoinColony/colonyNetwork/blob/develop/contracts/metaTxToken/MetaTxToken.sol).
35+
36+
## Step 2 - Deploying the colony contract
37+
38+
The most important step. Here the actualy colony contract will be deployed. This happens by executing a contract method on the `ColonyNetwork` (as opposed to a deploy-transaction):
39+
40+
```typescript
41+
// Create actual colony (deploys Colony contract)
42+
const [{ colonyAddress }] = await colonyNetwork
43+
.createColony(tokenAddress, 'colonytestname')
44+
.force();
45+
```
46+
47+
Here a label for the colony can be assigned. These are unique, so pick one that's not already taken. The `createColony` method will check that. Alternatively, the `colonyNetwork.getColonyAddress(label)` function can be used.
48+
49+
**If the own token was used and no extension installation is desired we would be done here. This is not recommended though, as one will at least need the `OneTxPayment` extension to properly use Colony at this stage.
50+
51+
## Step 3 - Instantiate the Colony for the first time
52+
53+
Let's instantiate the colony (this is the code used to instantiate an existing colony) and the token:
54+
55+
```typescript
56+
const colony = await colonyNetwork.getColony(colonyAddress);
57+
const token = await colony.getToken();
58+
```
59+
60+
## Step 4 (optional) - Deploy the token authority
61+
62+
The token authority is a contract that glues the token and the colony together and makes it possible for the colony to manage and move the token. The token authority can be deployed using the `deployAuthority` method on the `Token`. After that, another transaction is needed to set the token's `authority` to the one that was just deployed. If the token does not support the `setAuthority` method, this step should be skipped.
63+
64+
```typescript
65+
// Deploy TokenAuthority
66+
const [{ tokenAuthorityAddress }] = await token
67+
.deployAuthority([colonyAddress])
68+
.force();
69+
// Set the token's authority to the freshly deployed one
70+
await token.setAuthority(tokenAuthorityAddress).force();
71+
```
72+
73+
74+
## Step 5 - Install the `OneTxPayment` extension
75+
76+
As mentioned earlier, this step is technically optional as well but if the colony is supposed to be used productively, a form of payment extension is needed. Currently only the `OneTxPayment` extension is supported. Install it like so:
77+
78+
```typescript
79+
const [{ extensionId, version }] = await colony
80+
.installExtension(SupportedExtension.oneTx)
81+
.force();
82+
await colony.updateExtensions();
83+
const [{ user, setTo, role }] = await colony
84+
.setRoles(colony.ext.oneTx.address, [
85+
ColonyRole.Administration,
86+
ColonyRole.Funding,
87+
])
88+
.force();
89+
```
90+
91+
Here we install the extension using the `installExtension` method. This extension is an own contract that was deployed in this transaction. To get its address, we re-initialize the extensions on the colony using `updateExtensions`. After that, `oneTx` will be available on `colony.ext`.
92+
Finally, we assign the **Administration** and **Funding** roles of the colony's `Root` team to the extension that we just deployed. The OneTxPayment extension needs these permissions to function properly.
93+
94+
95+
## That's it!
96+
97+
We have successfully deployed a colony that can be used from the dApp as well. Explore what's possible within a colony using Colony SDK [here](../api/classes/Colony.md).

examples/node/create.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const start = async () => {
2929
// Instantiate colony and token
3030
const colony = await colonyNetwork.getColony(colonyAddress);
3131
const token = await colony.getToken();
32-
// Deploy TokanAuthority
32+
// Deploy TokenAuthority
3333
const [{ tokenAuthorityAddress }] = await token
3434
.deployAuthority([colonyAddress])
3535
.force();

0 commit comments

Comments
 (0)