Adding Domains

The technical docs mention that to add a domain, the following code should be added:

// Add a domain
await colonyClient.addDomain.send({
parentDomainId: 1,
});

In which file exactly should this code be added? And once added to the code, what code needs to be added to the terminal to update the contracts?

Assuming the domain i want to add is called “Human Resources”, where exactly do i specify “Human Resources” in the above code?

1 Like

In which file exactly should this code be added?

Hmmm… This will vary per project. I might be able to recommend a location if your project is open source or there is another way for me to view it but I’m not sure how much help I can be without knowing how your project is organized and, if you are using a framework, what framework you are using.

For example, if you are using React, this could be added directly to a component in a simple application or it could be added to an action in a more complex application.

And once added to the code, what code needs to be added to the terminal to update the contracts?

Once again, this will vary per project. If you are writing a script, you will need to add a script command to your package.json file so that you can run it with yarn or you can call the script directly with node. For example, if you created a script file called addDomain.js in a scripts directory, you would call node scripts/addDomain from the root directory.

Assuming the domain i want to add is called “Human Resources”, where exactly do i specify “Human Resources” in the above code?

A name is not saved on-chain. You will need to link the name to the id and save that data off-chain or hard code this into your application. We use IPFS in our dApp but you could also use a centralized database to achieve the same results. In the future, we plan to provide an “extended protocol” that will make it easier to use the same storage methods we are using in the dApp.

1 Like

Hi!
I have a question which is the part of parent question, after adding domain where we can see that the domain which have been added by the script?

1 Like

Hey @mjamilbashir99!

where we can see that the domain which have been added by the script?

Once you add a domain, you can use the getDomain method, which will give you the information about that domain (the potId and the skillId).

When you create a new colony, you will automatically have one domain within your colony, which is the root domain with an id of 1. Domain ids will increment, so the first time you add a domain to you colony, the id of your new domain will be 2.

The only information for a domain that is saved on chain is the associated skillId and potId. We are using IPFS in our dApp to store additional information such as a domain name.

We will be extracting this from our dApp and providing a standalone library in the future to make it easier for developers building with Colony.

In the meantime you will have to either hardcode any additional information you want to associate with your domain (such as a name) into your project or you will have to store such information yourself using IPFS or another database solution that will essentially link the id with such information.

So it means, we need to link the domains, skills and tasks manually or virutally. Here only IDs will be generated.

So it means, we need to link the domains, skills and tasks manually or virutally. Here only IDs will be generated.

Just additional information not saved on chain needs to be linked. For example, a domain name or some other property you wanted to add.

Within the colonyNetwork contracts, a skill is assigned to a domain (allowing you to look up reputation earned within a domain), tasks and payments are assigned skills and domains (allowing you to earn reputation within those skills and domains), all of which is saved on chain.

Please check this screenshot. I have created a domain and added a skill


but why it is showing its skillID to 528. I think it should be starting from 1 as it is my first skill in this domain

1 Like

Great question! That’s a feature, not a bug.

The skillId is on the network level whereas the domainId is on the colony level, which is why your first domain will have a domainId of 2 and a skillId that is much larger.

Your colony itself is a domain, also known as the “root domain”, which is why the first domain you create has a domainId of 2 rather than 1.

Each domain created has an associated skillId on the network level so that you can look up the reputation of an address within a domain (including the root domain, ie reputation within a colony).

Also, you can check out this thread for more information about getting reputation using the skillId.