> ## Documentation Index
> Fetch the complete documentation index at: https://docs.story.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# License

> LicenseClient allows you to manage license terms and tokens within Story.

## LicenseClient

### Methods

* attachLicenseTerms
* mintLicenseTokens
* registerPILTerms
* registerPilTermsAndAttach
* registerNonComSocialRemixingPIL
* registerCommercialUsePIL
* registerCommercialRemixPIL
* registerCreativeCommonsAttributionPIL
* getLicenseTerms
* predictMintingLicenseFee
* setLicensingConfig
* getLicensingConfig
* setMaxLicenseTokens

### attachLicenseTerms

Attaches license terms to an IP.

| Method               | Type                                                                 |
| -------------------- | -------------------------------------------------------------------- |
| `attachLicenseTerms` | `(request: AttachLicenseTermsRequest) => AttachLicenseTermsResponse` |

Parameters:

* `request.ipId`: The address of the IP to which the license terms are attached.
* `request.licenseTermsId`: The ID of the license terms.
* `request.licenseTemplate`: \[Optional] The address of the license template.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.license.attachLicenseTerms({
    licenseTermsId: "1",
    ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
  });

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

  ```typescript Request Type theme={null}
  export type AttachLicenseTermsRequest = {
    ipId: Address;
    licenseTermsId: string | number | bigint;
    licenseTemplate?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type AttachLicenseTermsResponse = {
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
    success?: boolean;
  };
  ```
</CodeGroup>

### mintLicenseTokens

Mints [License Tokens](/concepts/licensing-module/license-token) that give permission to use the IP Asset based on [License Terms](/concepts/licensing-module/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](/concepts/licensing-module/license-token#private-licenses) by minting a license token with a `licenseTermsId` that is not attached to the IP Asset.

<Warning>
  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.
</Warning>

<Frame>
  <img src="https://mintcdn.com/story/Ci-RgMKFKns3XzFq/images/concepts/private-licenses.png?fit=max&auto=format&n=Ci-RgMKFKns3XzFq&q=85&s=41fbeab6460274071950c739ed5cbd75" alt="A diagram showing how private licenses are minted." width="2026" height="1312" data-path="images/concepts/private-licenses.png" />
</Frame>

| Method              | Type                                                                        |
| ------------------- | --------------------------------------------------------------------------- |
| `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`: \[Optional] The maximum minting fee to be paid when minting a license.
* `request.maxRevenueShare`: \[Optional] 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.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.license.mintLicenseTokens({
    licenseTermsId: "1",
    licensorIpId: "0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba",
    receiver: "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", // optional
    amount: 1,
  });

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

  ```typescript Request Type theme={null}
  export type MintLicenseTokensRequest = {
    licensorIpId: Address;
    licenseTermsId: string | number | bigint;
    licenseTemplate?: Address;
    maxMintingFee: bigint | string | number;
    maxRevenueShare: number | string;
    amount?: number | string | bigint;
    receiver?: Address;
  } & WithWipOptions;
  ```

  ```typescript Response Type theme={null}
  export type MintLicenseTokensResponse = {
    licenseTokenIds?: bigint[];
    receipt?: TransactionReceipt;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### registerPILTerms

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

| Method             | Type                                                                 |
| ------------------ | -------------------------------------------------------------------- |
| `registerPILTerms` | `(request: RegisterPILTermsRequest) => Promise<RegisterPILResponse>` |

Parameters:

* Expected Parameters: Instead of listing all of the expected parameters here, please see `LicenseTerms` type in [this](https://github.com/storyprotocol/sdk/blob/main/packages/core-sdk/src/types/resources/license.ts) file. They all come from the [PIL Terms](/concepts/programmable-ip-license/pil-terms).

<CodeGroup>
  ```typescript TypeScript theme={null}
  import {
    LicenseTerms,
    PILFlavor,
    WIP_TOKEN_ADDRESS,
  } from "@story-protocol/core-sdk";
  import { zeroAddress, parseEther } from "viem";

  // OPTION 1. If you want to specify all the terms

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

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

  // OPTION 2. If you want to use a PIL flavor for convenience

  const response = await client.license.registerPILTerms(
    PILFlavor.commercialRemix({
      commercialRevShare: 5,
      defaultMintingFee: parseEther("1"), // 1 $IP
      currency: WIP_TOKEN_ADDRESS,
    })
  );

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

  ```typescript Request Type theme={null}
  export type RegisterPILTermsRequest = Omit<
    LicenseTerms,
    | "defaultMintingFee"
    | "expiration"
    | "commercialRevCeiling"
    | "derivativeRevCeiling"
  > & {
    defaultMintingFee: bigint | string | number;
    expiration: bigint | string | number;
    commercialRevCeiling: bigint | string | number;
    derivativeRevCeiling: bigint | string | number;
  };

  export type LicenseTerms = {
    /*Indicates whether the license is transferable or not.*/
    transferable: boolean;
    /*The address of the royalty policy contract which required to StoryProtocol in advance.*/
    royaltyPolicy: Address;
    /*The default minting fee to be paid when minting a license.*/
    defaultMintingFee: bigint;
    /*The expiration period of the license.*/
    expiration: bigint;
    /*Indicates whether the work can be used commercially or not.*/
    commercialUse: boolean;
    /*Whether attribution is required when reproducing the work commercially or not.*/
    commercialAttribution: boolean;
    /*Commercializers that are allowed to commercially exploit the work. If zero address, then no restrictions is enforced.*/
    commercializerChecker: Address;
    /*The data to be passed to the commercializer checker contract.*/
    commercializerCheckerData: Address;
    /**Percentage of revenue that must be shared with the licensor. Must be from 0-100.*/
    commercialRevShare: number;
    /*The maximum revenue that can be generated from the commercial use of the work.*/
    commercialRevCeiling: bigint;
    /*Indicates whether the licensee can create derivatives of his work or not.*/
    derivativesAllowed: boolean;
    /*Indicates whether attribution is required for derivatives of the work or not.*/
    derivativesAttribution: boolean;
    /*Indicates whether the licensor must approve derivatives of the work before they can be linked to the licensor IP ID or not.*/
    derivativesApproval: boolean;
    /*Indicates whether the licensee must license derivatives of the work under the same terms or not.*/
    derivativesReciprocal: boolean;
    /*The maximum revenue that can be generated from the derivative use of the work.*/
    derivativeRevCeiling: bigint;
    /*The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol.*/
    currency: Address;
    /*The URI of the license terms, which can be used to fetch the offchain license terms.*/
    uri: string;
  };
  ```

  ```typescript Response Type theme={null}
  export type RegisterPILResponse = {
    licenseTermsId?: bigint;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### registerPilTermsAndAttach

Register Programmable IP License Terms (if unregistered) and attach it to IP.

| Method                      | Type                                                                                        |
| --------------------------- | ------------------------------------------------------------------------------------------- |
| `registerPilTermsAndAttach` | `(request: RegisterPilTermsAndAttachRequest) => Promise<RegisterPilTermsAndAttachResponse>` |

Parameters:

* `request.ipId`: The ID of the IP.
* `request.licenseTermsData[]`: The array of license terms to be attached.
  * `request.licenseTermsData.terms`: See the [LicenseTerms type](https://github.com/storyprotocol/sdk/blob/main/packages/core-sdk/src/types/resources/license.ts#L26).
  * `request.licenseTermsData.licensingConfig`: \[Optional] See the [LicensingConfig type](https://github.com/storyprotocol/sdk/blob/main/packages/core-sdk/src/types/common.ts#L15). If none provided, it will default to the one shown [here](https://github.com/storyprotocol/sdk/blob/main/packages/core-sdk/src/utils/validateLicenseConfig.ts).
* `request.deadline`: \[Optional] The deadline for the signature in milliseconds. **Defaults to 1000**.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { PILFlavor, WIP_TOKEN_ADDRESS } from "@story-protocol/core-sdk";
  import { parseEther } from "viem";

  const response = await client.license.registerPilTermsAndAttach({
    ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
    licenseTermsData: [
      {
        terms: PILFlavor.commercialRemix({
          commercialRevShare: 5,
          defaultMintingFee: parseEther("1"), // 1 $IP
          currency: WIP_TOKEN_ADDRESS,
        }),
      },
    ],
  });
  console.log(`License Terms ${response.licenseTermsId} attached to IP Asset.`);
  ```

  ```typescript Request Type theme={null}
  export type RegisterPilTermsAndAttachRequest = {
    ipId: Address;
    licenseTermsData: LicenseTermsData<
      RegisterPILTermsRequest,
      LicensingConfig
    >[];
    deadline?: string | number | bigint;
  };
  ```

  ```typescript Response Type theme={null}
  export type RegisterPilTermsAndAttachResponse = {
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
    licenseTermsIds?: bigint[];
  };
  ```
</CodeGroup>

### registerNonComSocialRemixingPIL

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

<Warning>
  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.
</Warning>

| Method                            | Type                                                                                 |
| --------------------------------- | ------------------------------------------------------------------------------------ |
| `registerNonComSocialRemixingPIL` | `(request?: RegisterNonComSocialRemixingPILRequest) => Promise<RegisterPILResponse>` |

Parameters:

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.license.registerNonComSocialRemixingPIL({});

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

  ```typescript Request Type theme={null}
  export type RegisterNonComSocialRemixingPILRequest = {};
  ```

  ```typescript Response Type theme={null}
  export type RegisterPILResponse = {
    licenseTermsId?: bigint;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### registerCommercialUsePIL

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

| Method                     | Type                                                                         |
| -------------------------- | ---------------------------------------------------------------------------- |
| `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.

<CodeGroup>
  ```typescript TypeScript theme={null}
  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,
  });

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

  ```typescript Request Type theme={null}
  export type RegisterCommercialUsePILRequest = {
    defaultMintingFee: string | number | bigint;
    currency: Address;
    royaltyPolicyAddress?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type RegisterPILResponse = {
    licenseTermsId?: bigint;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### registerCommercialRemixPIL

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

| Method                       | Type                                                                           |
| ---------------------------- | ------------------------------------------------------------------------------ |
| `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.

<CodeGroup>
  ```typescript TypeScript theme={null}
  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,
  });

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

  ```typescript Request Type theme={null}
  export type RegisterCommercialRemixPILRequest = {
    defaultMintingFee: string | number | bigint;
    commercialRevShare: number;
    currency: Address;
    royaltyPolicyAddress?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type RegisterPILResponse = {
    licenseTermsId?: bigint;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### registerCreativeCommonsAttributionPIL

Convenient function to register a PIL creative commons attribution license to the registry.

| Method                                  | Type                                                                                      |
| --------------------------------------- | ----------------------------------------------------------------------------------------- |
| `registerCreativeCommonsAttributionPIL` | `(request: RegisterCreativeCommonsAttributionPILRequest) => Promise<RegisterPILResponse>` |

Parameters:

* `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.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.license.registerCreativeCommonsAttributionPIL({
    currency: "0x1514000000000000000000000000000000000000", // $WIP address from https://docs.story.foundation/docs/deployed-smart-contracts
    royaltyPolicyAddress: "0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E", // RoyaltyPolicyLAP address from https://docs.story.foundation/docs/deployed-smart-contracts
  });

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

  ```typescript Request Type theme={null}
  export type RegisterCreativeCommonsAttributionPILRequest = {
    currency: Address;
    royaltyPolicyAddress?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type RegisterPILResponse = {
    licenseTermsId?: bigint;
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
  };
  ```
</CodeGroup>

### getLicenseTerms

Gets License Terms of the given ID.

| Method            | Type                                                                                               |
| :---------------- | :------------------------------------------------------------------------------------------------- |
| `getLicenseTerms` | `(selectedLicenseTermsId: string \| number \| bigint) => PiLicenseTemplateGetLicenseTermsResponse` |

Parameters:

* `selectedLicenseTermsId`: The ID of the license terms.

```typescript Response Type theme={null}
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.

| Method                     | Type                                                                                            |
| -------------------------- | ----------------------------------------------------------------------------------------------- |
| `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.

```typescript Response Type theme={null}
export type LicensingModulePredictMintingLicenseFeeResponse = {
  currencyToken: Address;
  tokenAmount: bigint;
};
```

### setLicensingConfig

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

| Method               | Type                                                                 |
| -------------------- | -------------------------------------------------------------------- |
| `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`: \[Optional] 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.licensingConfig.commercialRevShare`: The commercial revenue share percentage (from 0 to 100).
  * `request.licensingConfig.disabled`: Whether the licensing is disabled or not. If this is true, then no licenses can be minted and no more derivatives can be attached at all.
  * `request.licensingConfig.expectMinimumGroupRewardShare`: The minimum percentage of the group's reward share (from 0 to 100).
  * `request.licensingConfig.expectGroupRewardPool`: The address of the expected group reward pool. The IP can only be added to a group with this specified reward pool address, or zero address if the IP does not want to be added to any group.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { parseEther, zeroAddress } from "viem";

  const response = await client.license.setLicensingConfig({
    ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
    licenseTermsId: 1,
    licensingConfig: {
      isSet: true,
      mintingFee: parseEther("1"),
      licensingHook: "0xaBAD364Bfa41230272b08f171E0Ca939bD600478",
      hookData: "0x",
      commercialRevShare: 10,
      disabled: false,
      expectMinimumGroupRewardShare: 0,
      expectGroupRewardPool: zeroAddress,
    },
  });
  ```

  ```typescript Request Type theme={null}
  export type SetLicensingConfigRequest = GetLicensingConfigRequest & {
    /** The licensing configuration for the license. */
    licensingConfig: LicensingConfigInput;
  };

  export type GetLicensingConfigRequest = {
    /** The address of the IP for which the configuration is being set. */
    ipId: Address;
    /** The ID of the license terms within the license template. */
    licenseTermsId: number | bigint;
    /**
     * The address of the license template.
     * Defaults to {@link https://docs.story.foundation/docs/programmable-ip-license | PIL} address if not provided.
     */
    licenseTemplate?: Address;
  };

  export type LicensingConfigInput = {
    /** Whether the licensing configuration is active. If false, the configuration is ignored. */
    isSet: boolean;
    /** The minting fee to be paid when minting license tokens. */
    mintingFee: bigint | string | number;
    /**
     * The licensingHook is an address to a smart contract that implements the `ILicensingHook` interface.
     * This contract's `beforeMintLicenseTokens` function is executed before a user mints a License Token,
     * allowing for custom validation or business logic to be enforced during the minting process.
     * For detailed documentation on licensing hook, visit {@link https://docs.story.foundation/concepts/hooks#licensing-hooks}
     */
    licensingHook: Address;
    /**
     * The data to be used by the licensing hook.
     * Set to a zero hash if no data is provided.
     */
    hookData: Hex;
    /** The commercial revenue share percentage (from 0 to 100%, represented as 100_000_000). */
    commercialRevShare: number | string;
    /** Whether the licensing is disabled or not. If this is true, then no licenses can be minted and no more derivatives can be attached at all. */
    disabled: boolean;
    /** The minimum percentage of the group’s reward share (from 0 to 100%, represented as 100_000_000) that can be allocated to the IP when it is added to the group. */
    expectMinimumGroupRewardShare: number | string;
    /** The address of the expected group reward pool. The IP can only be added to a group with this specified reward pool address, or zero address if the IP does not want to be added to any group. */
    expectGroupRewardPool: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type SetLicensingConfigResponse = {
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
    success?: boolean;
  };
  ```
</CodeGroup>

### getLicensingConfig

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

| Method               | Type                                                      |
| -------------------- | --------------------------------------------------------- |
| `getLicensingConfig` | `(request: GetLicensingConfigRequest) => LicensingConfig` |

Parameters:

* `request.ipId`: The address of the IP for which the configuration is being fetched.
* `request.licenseTermsId`: The ID of the license terms within the license template.
* `request.licenseTemplate`: \[Optional] The address of the license template used.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const licensingConfig = await client.license.getLicensingConfig({
    ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
    licenseTermsId: 1,
  });
  ```

  ```typescript Request Type theme={null}
  export type GetLicensingConfigRequest = {
    /** The address of the IP for which the configuration is being set. */
    ipId: Address;
    /** The ID of the license terms within the license template. */
    licenseTermsId: number | bigint;
    /**
     * The address of the license template.
     * Defaults to {@link https://docs.story.foundation/docs/programmable-ip-license | PIL} address if not provided.
     */
    licenseTemplate?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type LicensingConfig = {
    /** Whether the licensing configuration is active. If false, the configuration is ignored. */
    isSet: boolean;
    /** The minting fee to be paid when minting license tokens. */
    mintingFee: bigint;
    /**
     * The licensingHook is an address to a smart contract that implements the `ILicensingHook` interface.
     * This contract's `beforeMintLicenseTokens` function is executed before a user mints a License Token,
     * allowing for custom validation or business logic to be enforced during the minting process.
     * For detailed documentation on licensing hook, visit {@link https://docs.story.foundation/concepts/hooks#licensing-hooks}
     */
    licensingHook: Address;
    /**
     * The data to be used by the licensing hook.
     * Set to a zero hash if no data is provided.
     */
    hookData: Hex;
    /** The commercial revenue share percentage (from 0 to 100%, represented as 100_000_000). */
    commercialRevShare: number;
    /** Whether the licensing is disabled or not. If this is true, then no licenses can be minted and no more derivatives can be attached at all. */
    disabled: boolean;
    /** The minimum percentage of the group's reward share (from 0 to 100%, represented as 100_000_000) that can be allocated to the IP when it is added to the group. */
    expectMinimumGroupRewardShare: number;
    /** The address of the expected group reward pool. The IP can only be added to a group with this specified reward pool address, or zero address if the IP does not want to be added to any group. */
    expectGroupRewardPool: Address;
  };
  ```
</CodeGroup>

### setMaxLicenseTokens

Set the max license token limit for a specific license.

This method automatically configures the licensing hook to use the [TotalLicenseTokenLimitHook](https://github.com/storyprotocol/protocol-periphery-v1/blob/release/1.3/contracts/hooks/TotalLicenseTokenLimitHook.sol) contract if the current licensing hook is not set to `TotalLicenseTokenLimitHook`, and sets the max license tokens to the specified limit.

| Method                | Type                                                                    |
| --------------------- | ----------------------------------------------------------------------- |
| `setMaxLicenseTokens` | `(request: SetMaxLicenseTokensRequest) => Promise<TransactionResponse>` |

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.maxLicenseTokens`: The total license token limit, 0 means no limit.
* `request.licenseTemplate`: \[Optional] The address of the license template used.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await client.license.setMaxLicenseTokens({
    ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
    licenseTermsId: 1,
    maxLicenseTokens: 1000,
  });

  console.log(`Max license tokens set at transaction hash ${response.txHash}`);
  ```

  ```typescript Request Type theme={null}
  export type SetMaxLicenseTokensRequest = GetLicensingConfigRequest & {
    /** The total license token limit, 0 means no limit */
    maxLicenseTokens: bigint | number;
  };

  export type GetLicensingConfigRequest = {
    /** The address of the IP for which the configuration is being set. */
    ipId: Address;
    /** The ID of the license terms within the license template. */
    licenseTermsId: number | bigint;
    /**
     * The address of the license template.
     * Defaults to {@link https://docs.story.foundation/docs/programmable-ip-license | PIL} address if not provided.
     */
    licenseTemplate?: Address;
  };
  ```

  ```typescript Response Type theme={null}
  export type TransactionResponse = {
    txHash?: Hex;
    encodedTxData?: EncodedTxData;
    success?: boolean;
  };
  ```
</CodeGroup>
