LicenseClient

Methods

  • attachLicenseTerms
  • mintLicenseTokens
  • registerPILTerms
  • registerNonComSocialRemixingPIL
  • registerCommercialUsePIL
  • registerCommercialRemixPIL
  • getLicenseTerms

attachLicenseTerms

Attaches license terms to an IP.

MethodType
attachLicenseTerms(request: AttachLicenseTermsRequest) => AttachLicenseTermsResponse

Parameters:

  • request.ipId: The address of the IP to which the license terms are attached.
  • request.licenseTemplate: The address of the license template.
  • request.licenseTermsId: The ID of the license terms.
  • request.txOptions: [Optional] The transaction options.
const response = await client.license.attachLicenseTerms({
  licenseTermsId: "1",
  ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
  txOptions: { waitForTransaction: true },
});

if (response.success) {
  console.log(
    `Attached License Terms to IPA at transaction hash ${response.txHash}.`
  );
} else {
  console.log(`License Terms already attached to this IPA.`);
}

mintLicenseTokens

Mints License Tokens that give permission to use the IP Asset based on License Terms. The license tokens are minted to the receiver.

Note that a license token can only be minted if the licenseTermsId are already attached to the IP Asset, making it a publicly available license. The IP owner can, however, mint a private license by minting a license token with a licenseTermsId that is not attached to the IP Asset.

It might require the caller pay a minting fee, depending on the license terms or configured by the IP owner. The minting fee is paid in the minting fee token specified in the license terms or configured by the IP owner. IP owners can configure the minting fee of their IPs or configure the minting fee module to determine the minting fee.

MethodType
mintLicenseTokens(request: MintLicenseTokensRequest) => Promise<MintLicenseTokensResponse>

Parameters:

  • request.licensorIpId: The licensor IP ID.
  • request.licenseTermsId: The ID of the license terms within the license template.
  • request.maxMintingFee: The maximum minting fee to be paid when minting a license.
  • request.maxRevenueShare: The maximum revenue share to be paid when minting a license.
  • request.amount: [Optional] The amount of license tokens to mint.
  • request.receiver: [Optional] The address of the receiver.
  • request.licenseTemplate: [Optional] The address of the license template.
  • request.txOptions: [Optional] The transaction options.
const response = await client.license.mintLicenseTokens({
  licenseTermsId: "1",
  licensorIpId: "0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba",
  receiver: "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", // optional
  amount: 1,
  maxMintingFee: BigInt(0), // disabled
  maxRevenueShare: 100, // default
  txOptions: { waitForTransaction: true },
});

console.log(
  `License Token minted at transaction hash ${response.txHash}, License IDs: ${response.licenseTokenIds}`
);

registerPILTerms

Registers new license terms and return the ID of the newly registered license terms.

MethodType
registerPILTerms(request: RegisterPILTermsRequest) => Promise<RegisterPILResponse>

Parameters:

  • Expected Parameters: Instead of listing all of the expected parameters here, please see LicenseTerms type in this file. They all come from the PIL Terms.
  • request.txOptions: [Optional] The transaction options.
import { LicenseTerms } from "@story-protocol/core-sdk";
import { zeroAddress } from "viem";

const licenseTerms: LicenseTerms = {
  transferable: false,
  royaltyPolicy: "0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E", // RoyaltyPolicyLAP address from https://docs.story.foundation/docs/deployed-smart-contracts
  defaultMintingFee: 0n,
  expiration: 0n,
  commercialUse: false,
  commercialAttribution: false,
  commercializerChecker: zeroAddress,
  commercializerCheckerData: "0x",
  commercialRevShare: 10, // 10%
  commercialRevCeiling: 0n,
  derivativesAllowed: true,
  derivativesAttribution: false,
  derivativesApproval: false,
  derivativesReciprocal: false,
  derivativeRevCeiling: 0n,
  currency: "0x1514000000000000000000000000000000000000", // $WIP address from https://docs.story.foundation/docs/deployed-smart-contracts
  uri: "",
};

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

console.log(
  `PIL Terms registered at transaction hash ${response.txHash}, License Terms ID: ${response.licenseTermsId}`
);

registerNonComSocialRemixingPIL

Convenient function to register a PIL non commercial social remix license to the registry.

No reason to call this function. Non-Commercial Social Remixing terms are already registered with licenseTermdId = 1 in our protocol. There’s no reason to register them again.

MethodType
registerNonComSocialRemixingPIL(request?: RegisterNonComSocialRemixingPILRequest) => Promise<RegisterPILResponse>

Parameters:

  • request.txOptions: [Optional] The transaction options.
const response = await client.license.registerNonComSocialRemixingPIL({
  txOptions: { waitForTransaction: true },
});

console.log(
  `PIL Terms registered at transaction hash ${response.txHash}, License Terms ID: ${response.licenseTermsId}`
);

registerCommercialUsePIL

Convenient function to register a PIL commercial use license to the registry.

MethodType
registerCommercialUsePIL(request: RegisterCommercialUsePILRequest) => Promise<RegisterPILResponse>

Parameters:

  • request.defaultMintingFee: The fee to be paid when minting a license.
  • request.currency: The ERC20 token to be used to pay the minting fee and the token must be registered on Story’s protocol.
  • request.royaltyPolicyAddress: [Optional] The address of the royalty policy contract, default value is LAP.
  • request.txOptions: [Optional] The transaction options.
import { parseEther } from "viem";

const commercialUseParams = {
  currency: "0x1514000000000000000000000000000000000000", // $WIP address from https://docs.story.foundation/docs/deployed-smart-contracts
  defaultMintingFee: parseEther("1"), // 1 $WIP
  royaltyPolicyAddress: "0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E", // RoyaltyPolicyLAP address from https://docs.story.foundation/docs/deployed-smart-contracts
};

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}`
);

registerCommercialRemixPIL

Convenient function to register a PIL commercial Remix license to the registry.

MethodType
registerCommercialRemixPIL(request: RegisterCommercialRemixPILRequest) => Promise<RegisterPILResponse>

Parameters:

  • request.defaultMintingFee: The fee to be paid when minting a license.
  • request.commercialRevShare: Percentage of revenue that must be shared with the licensor.
  • request.currency: The ERC20 token to be used to pay the minting fee and the token must be registered on Story’s protocol.
  • request.royaltyPolicyAddress: [Optional] The address of the royalty policy contract, default value is LAP.
  • request.txOptions: [Optional] The transaction options.
import { parseEther } from "viem";

const commercialRemixParams = {
  currency: "0x1514000000000000000000000000000000000000", // $WIP address from https://docs.story.foundation/docs/deployed-smart-contracts
  defaultMintingFee: parseEther("1"), // 1 $WIP
  royaltyPolicyAddress: "0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E", // RoyaltyPolicyLAP address from https://docs.story.foundation/docs/deployed-smart-contracts
  commercialRevShare: 10, // 10%
};

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}`
);

getLicenseTerms

Gets License Terms of the given ID.

MethodType
getLicenseTerms`(selectedLicenseTermsId: string \number \bigint) => PiLicenseTemplateGetLicenseTermsResponse`

Parameters:

  • selectedLicenseTermsId: The ID of the license terms.
Response Type
export type PiLicenseTemplateGetLicenseTermsResponse = {
  terms: {
    transferable: boolean;
    royaltyPolicy: Address;
    defaultMintingFee: bigint;
    expiration: bigint;
    commercialUse: boolean;
    commercialAttribution: boolean;
    commercializerChecker: Address;
    commercializerCheckerData: Hex;
    commercialRevShare: number;
    commercialRevCeiling: bigint;
    derivativesAllowed: boolean;
    derivativesAttribution: boolean;
    derivativesApproval: boolean;
    derivativesReciprocal: boolean;
    derivativeRevCeiling: bigint;
    currency: Address;
    uri: string;
  };
};

predictMintingLicenseFee

Pre-compute the minting license fee for the given IP and license terms. The function can be used to calculate the minting license fee before minting license tokens.

MethodType
predictMintingLicenseFee(request: PredictMintingLicenseFeeRequest) => LicensingModulePredictMintingLicenseFeeResponse

Parameters:

  • request.licensorIpId: The IP ID of the licensor.
  • request.licenseTermsId: The ID of the license terms.
  • request.amount: The amount of license tokens to mint.
  • request.licenseTemplate: [Optional] The address of the license template, default value is Programmable IP License.
  • request.receiver: [Optional] The address of the receiver, default value is your wallet address.
  • request.txOptions: [Optional] The transaction options.
Response Type
export type LicensingModulePredictMintingLicenseFeeResponse = {
  currencyToken: Address;
  tokenAmount: bigint;
};

setLicensingConfig

Sets the licensing configuration for a specific license terms of an IP.

MethodType
setLicensingConfig(request: SetLicensingConfigRequest) => SetLicensingConfigResponse

Parameters:

  • request.ipId: The address of the IP for which the configuration is being set.
  • request.licenseTermsId: The ID of the license terms within the license template.
  • request.licenseTemplate: The address of the license template used, If not specified, the configuration applies to all licenses.
  • request.licensingConfig: The licensing configuration for the license.
    • request.licensingConfig.isSet: Whether the configuration is set or not.
    • request.licensingConfig.mintingFee: The minting fee to be paid when minting license tokens.
    • request.licensingConfig.hookData: The data to be used by the licensing hook.
    • request.licensingConfig.licensingHook: The hook contract address for the licensing module, or address(0) if none.
  • request.txOptions: [Optional] The transaction options.
Response Type
export type SetLicensingConfigResponse = {
  txHash?: string;
  encodedTxData?: EncodedTxData;
  success?: boolean;
};