Register A Relationship Type

Register a new relationship type


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 RelationshipClient to register a relationship type for relations.


const {txHash, success} = await client.relationship.registerRelationshipType({


  • ipOrgId: string: The identifier of the IP Organization who manages the IP Asset.
  • relType: string: The name of the relationship type. For example: APPEAR_IN.
  • relatedElements: RelatedElements: The type of the entity to be related. The entity type can be IP Asset, external NFT or others. Here is the definition of RelatedElements:
export interface RelatedElements {
    src: Relatables;
    dst: Relatables;

Here Relatables is an enum defined below:

declare enum Relatables {
    UNDEFINED = 0,
    IPA = 1,
    IPORG_ENTRY = 2,
    LICENSE = 3,
    ADDRESS = 4,

For example, the following RelatedElements defines a relationship type from IP Asset to License:

  src: Relatables.IPA,
  dst: Relatables.LICENSE,
  • allowedSrcs: string[]: the source IP Asset types. For example ["0"] means the relationship type requires that the relationship is from STORY (enum value is 0).
  • allowedDsts: string[]: the destination IP Asset types. For example ["1", "0"] means that the relationship type requires that the relationship is to CHARACTOR or STORY.
  • preHookData: Array<Record<string, unknown>>: An array of data passed into the pre-action hooks.
  • postHookData: Array<Record<string, unknown>>: An array of data passed into the post-action hooks.
  • txOptions: TxOption: the transaction option: whether or not to wait for the transaction complete.


  • txHash: string: Relationship type creation transaction hash.
  • success: boolean: Whether the relationship type is created successfully. It will be empty if waitForTransaction in txOption is set to false.


You can refer to the source code before to call registerRelationshipType function of RelationshipClient:

  ipOrgId: "0x86310d77f44e66d2db850266f3f600256d123579",
  relType: "APPEAR_IN",
  relatedElements: {src: 1, dst: 1},
  allowedSrcs: ["1"],
  allowedDsts: ["0"],
  preHooksConfig: [],
  postHooksConfig: [],
  "txOptions": { waitForTransaction: true }
}).then(({txHash, success}) => {
  console.log("txHash:", txHash);
  console.log("success:", success);

Here is the output by running above code which returns the txHash and success:

txHash: 0xf1b3fa087627232808ddc458722f4b7c5609dbf3b0b599e0147e402b0ad1a3f0
success: true

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