Register PIL Terms

This section demonstrates how to register a selection of License Terms using the PIL.

๐Ÿ“˜

Before Reading

It's important to note that it would be rare for you to have to use this function. PIL Terms, which are defined by its parameters, only have to be created once. Thus, it is likely it has already been created by someone else.

You can view a list of popular premade License Terms here.

Prerequisites

  • Setup the client object.
  • If License Terms already exist for the identical set of parameters you intend to create, it is unnecessary to create it again and the function will simply return the existing licenseTermsId and an undefined txHash. You can use existing License Terms by its licenseTermsId.

Create a Commercial Use License

const commercialUseParams = {
  currency: '0xB132A6B7AE652c974EE1557A3521D53d18F6739f',
  mintingFee: '10'
}

const response = await client.license.registerCommercialUsePIL({
  ...commercialUseParams,
  txOptions: { waitForTransaction: true }
});

console.log(`PIL Terms registered at transaction hash ${response.txHash}, License Terms ID: ${response.licenseTermsId}`) 
export type RegisterCommercialUsePILRequest = {
  mintingFee: string;
  currency: Address;
  txOptions?: TxOptions;
};
export type RegisterPILResponse = {
  licenseTermsId?: bigint;
  txHash?: string;
};

Setting waitForTransaction: true in the transaction options will return the licenseTermsId value.

Create a Commercial Remix License

const commercialRemixParams = {
  currency: '0xB132A6B7AE652c974EE1557A3521D53d18F6739f',
  mintingFee: '10',
  commercialRevShare: 10 // 10 = 1%
}

const response = await client.license.registerCommercialRemixPIL({
  ...commercialRemixParams,
  txOptions: { waitForTransaction: true }
});

console.log(`PIL Terms registered at transaction hash ${response.txHash}, License Terms ID: ${response.licenseTermsId}`) 
export type RegisterCommercialRemixPILRequest = {
  mintingFee: string;
  commercialRevShare: number;
  currency: Address;
  txOptions?: TxOptions;
};
export type RegisterPILResponse = {
  licenseTermsId?: bigint;
  txHash?: string;
};

Setting waitForTransaction: true in the transaction options will return the licenseTermsId value.

Create a Non-Commercial Social Remixing License

There are currently no parameters to be passed in here, so this function should not really be used other than to get back the licenseTermsId for this license.

const nonComSocialRemixingParams = {}

const response = await client.license.registerNonComSocialRemixingPIL({
  ...nonComSocialRemixingParams,
  txOptions: { waitForTransaction: true }
});

console.log(`PIL Terms registered at transaction hash ${response.txHash}, License Terms ID: ${response.licenseTermsId}`) 
export type RegisterNonComSocialRemixingPILRequest = {
  txOptions?: TxOptions;
};
export type RegisterPILResponse = {
  licenseTermsId?: bigint;
  txHash?: string;
};

Setting waitForTransaction: true in the transaction options will return the licenseTermsId value.