Mint a License

This section demonstrates how to mint a license for an IP asset. You can only mint a license for an IP asset if it has a policy added to its configuration. A license is minted as an ERC1155 token and contains the necessary licensing details.

Prerequisites

  • Setup the client object.
  • An IP asset that has a policy added. Learn how to add a policy to an IP asset here

Mint License

To mint a license, we will need the ipId (address of the IP asset), the policyId string of the policy for the intended license, the mintAmount of licenses to be minted (usually 1, unless the minter decides to mint a batch and distribute it in another way later on), and the receiverAddress (usually the wallet address that is executing the transaction).

const response = await client.license.mintLicense({
   policyId: "5", 
   licensorIpId: response.ipId! as `0x${string}`,
   receiverAddress: "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", 
   mintAmount: 1, 
   txOptions: { waitForTransaction: true }
});

console.log(`License minted at transaction hash ${response.txHash}, license id: ${response.licenseId}`)
export type MintLicenseRequest = {
  policyId: string;
  licensorIpId: `0x${string}`;
  mintAmount: number;
  receiverAddress: `0x${string}`;
  txOptions?: TxOptions;
};
export type MintLicenseResponse = {
  txHash: string;
  licenseId?: string;
};

SettingwaitForTransaction: true in the transaction options will return the licenseId of the newly minted license(s).