Get A Relationship

Get relationship by ID

🚧

This is a SDK for Alpha

This SDK is alpha and not production complete yet, which means that we could change the schemas, smart contract deployment and backend endpoints that at any time without warning or notice to you. When this SDK is production ready, we will remove this warning and will endeavor to ensure the production quality of the SDK and update the SDK in regular basis with formal notice.

Developers can use the get function of RelationshipClient to get the relationship by ID.

Usage

const { relationship }  = await client.relationship.get({ relationshipId });

Parameters

  • relationshipId: string: The relationship identifier.

Response

  • relationship: Relationship: The relationship object for the specified ID. The Relationship object is defined as below.
export type Relationship = {
    id: string;							// The ID of the relationship
    type: string;						// The relationship type
    srcContract: string;		// The smart contract address of the source entity registry
    srcTokenId: string;			// The token ID of the source entity to be related.
    dstContract: string;		// The smart contract address of the destination entity registry.
    dstTokenId: string;			// The token ID of the destination entity to be related.
    registeredAt: string;		// The relationship registration time
    txHash: string;					// The transaction hash of the relationship creation
};

Example

You can refer to the source code below to call get function of RelationshipClient:

client.relationship.get({ relationshipId: '187' })
  .then(({relationship}) => {
    console.log(relationship);
  });

Here is the output of the above code:

{
  id: '187',
  type: '0x5ffafde2050246ca3984140f46f79c0ccee4ef7ee4c9b33ba9585f97db9a3f4c',
  srcContract: '0x309c205347e3826472643f9b7ebd8a50d64ccd9e',
  srcTokenId: '1000',
  dstContract: '0x309c205347e3826472643f9b7ebd8a50d64ccd9e',
  dstTokenId: '2000',
  registeredAt: '2023-12-01T20:19:00Z',
  txHash: '0x17eb09661f0c3c97f925a40b84d0d006a37860725bd9285d897d04921b544c99'
}

For the full source of the example, please refer to this link.