Create License for IP Asset

Creates a License and mints a License NFT to the creator's wallet

🚧

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 LicenseClient to create a license for an IP asset and a franchise. It will return the txHash on a successful creation transaction.

Usage

const { txHash } = await client.license.create({
  ipOrgId,
  parentLicenseId,
  ipaId,
  params,
  preHookData,
  postHookData,
  txOptions
});

Parameters

  • ipOrg: string: The ID of the IP Org where the license will be created.
  • parentLicenseId: string: The ID of the parent license. If the value is "0", the license to be created will not have parent license.
  • ipaId: string: The IP asset ID. The specified IP asset will have the license attached to it.
  • params: ParamValues[]: The parameter tags and values for the license, you can find the definition of ParamValues at Configure License for IP Org.
  • preHookData: Array<TypedData>: the data types and values for the pre-action hooks when creating the license.
  • postHookData: Array<TypedData>: the data types and values for the post-action hooks when creating the license.
  • txOptions: TxOption: the transaction option: whether or not to wait for the transaction complete.

Response

  • txHash: string: the license creation transaction hash.
  • licenseId: string: the ID of the license that has been created.

Example

You can refer to the source code below to call create function of LicenseClient:

// Create a license for an IP asset
client.license.create({
  ipOrgId: "0xF509f04Ab4a926805312DD30accA4a2bcC18D98D",
  parentLicenseId: "0",
  ipaId: "74",
  params:[
    {
      tag: "Channels-Of-Distribution",
      value: {
        interface: "string",
        data: ["Telegram"],
      }
    }
  ],
  preHookData: [],
  postHookData: [],
  txOptions: {waitForTransaction: true}
}).then({txHash, licenseId} => {
  console.log("txHash:", txHash);
  console.log("licenseId:", success);
});

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

txHash: 0xf1b3fa087627232808ddc458722f4b7c5609dbf3b0b599e0147e402b0ad1a3f0
licenseId: 58