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.