Last modified: Fri Aug 16 2019 11:27:04 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')
'0x2c29c421d7fd7be4cc2bfb6d1a44426e43021914'

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)
'hotels'
truffle(ropsten)> entrypoint.getSegmentName(2)
'airlines'
truffle(ropsten)> entrypoint.getSegmentName(3)
'otas'
truffle(ropsten)> entrypoint.getSegment('airlines')
'0x6f8Ab047Ccc0C8128Cc4d343Feb618065a13D965'

2. Add Your ORG.ID to Segment Directory

Info

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 SegmentDirectory.at('0x2c29c421d7fd7be4cc2bfb6d1a44426e43021914')
undefined
truffle(ropsten)> hotelsDirectory.add(orgid.address)
{ tx:
   '0x60b630352602d282b523184d5ead4d2dd8a1b044aded429194d3206a4292d804',
   ...
}

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.

Success

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

Info

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.