Last modified: Fri Sep 20 2019 11:21:30 GMT+0000 (Coordinated Universal Time)

Segment Directory Registration

Now your company has its own unique ID. But how other companies on the platform can find it? Well, they can't until you register it with one or more Segment Directories. A Segment Directory is a smart contract that contains a list of companies claiming to belong to that directory. As of now, we have three segments: hotels, airlines, and otas. So, if your company is in hotel business, you will have to register it with the appropriate smart contract for it to be discoverable.

1. Find the Proper Segment Directory

Let's say you want to add your ORG.ID to the hotels directory. You can get its address by calling the getSegment method on the Entrypoint.

truffle(ropsten)> entrypoint.getSegment('hotels')

If you are not sure about the Segment Directory name, you can list all of the segments in the Entrypoint like this:

truffle(ropsten)> entrypoint.getSegmentsLength()
<BN: 4>
truffle(ropsten)> entrypoint.getSegmentName(1)
truffle(ropsten)> entrypoint.getSegmentName(2)
truffle(ropsten)> entrypoint.getSegmentName(3)
truffle(ropsten)> entrypoint.getSegment('airlines')

2. Add Your ORG.ID to Segment Directory


If you are adding your ORG.ID into hotels segment directory, don't forget to publish information about your hotel in ORG.JSON.

Now you can add your 0xORG to the Segment Directory like so:

truffle(ropsten)> hotelsDirectory = await'0x2c29c421d7fd7be4cc2bfb6d1a44426e43021914')
truffle(ropsten)> hotelsDirectory.add(orgid.address)
{ tx:

Now let's verify that everything worked as it should have.

truffle(ropsten)> hotelsDirectory.getOrganizations()
[ '0x0000000000000000000000000000000000000000',
  '0xF3Ad504cAeD347cAdb6e31806CE7088EF0F09742' ]

Your ORG.ID should be the last on the list.


Congratulations! Your hotel can now be found by other market participants!


Shortcut: The Organization Factory provides the createAndAddToDirectory(orgJsonUri, orgJsonHash, segmentDirectoryAddress) shorthand method that can be used to create a fresh ORG.ID and add it to the directory in a single transaction.