Mint a License Token

This section demonstrates how to mint a License Token for an IPA. You can only mint a License Token for an IPA if it has License Terms attached to it. A License Token is minted as an ERC1155 token and contains the necessary licensing details.

Prerequisites

  • Setup the client object.
  • An IPA that has License Terms added. Learn how to add License Terms to an IPA here.

Mint License

To mint a License Token, we will need the:

  • licenseTermsId - the id of the License Terms (ex. "1" for Non-Commercial Social Remixing)
  • licensorIpId - the ipId of the IPA we are minting a License Token from
  • receiver - wallet receiving the License Token, usually the wallet address that is executing the transaction
  • amount - # of License Tokens to be minted (usually 1, unless the minter decides to mint a batch and distribute it in another way later on)
const response = await client.license.mintLicenseTokens({
   licenseTermsId: "1", 
   licensorIpId: "0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba",
   receiver: "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", 
   amount: 1, 
   txOptions: { waitForTransaction: true }
});

console.log(`License Token minted at transaction hash ${response.txHash}, License ID: ${response.licenseTokenId}`)
export type MintLicenseTokensRequest = {
  licenseTermsId: string;
  licensorIpId: Address;
  amount: number;
  receiver: Address;
  txOptions?: TxOptions;
};
export type MintLicenseTokensResponse = {
  txHash?: string;
  licenseTokenId?: bigint;
};

Setting waitForTransaction: true in the transaction options will return the licenseTokenId of the newly minted license(s).