> ## 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.

# LicensingModule

The Licensing Module is the main entry point for the licensing system on Story. It is responsible for:

* Attaching license terms to IP assets
* Minting license tokens
* Registering derivatives

## State Variables

### name

```solidity theme={null}
string public constant override name = LICENSING_MODULE_KEY
```

Returns the name of the module.

### ROYALTY\_MODULE

```solidity theme={null}
RoyaltyModule public immutable ROYALTY_MODULE
```

Returns the canonical protocol-wide RoyaltyModule.

### LICENSE\_REGISTRY

```solidity theme={null}
ILicenseRegistry public immutable LICENSE_REGISTRY
```

Returns the canonical protocol-wide LicenseRegistry.

### DISPUTE\_MODULE

```solidity theme={null}
IDisputeModule public immutable DISPUTE_MODULE
```

Returns the protocol-wide dispute module.

### LICENSE\_NFT

```solidity theme={null}
ILicenseToken public immutable LICENSE_NFT
```

Returns the License NFT.

### MODULE\_REGISTRY

```solidity theme={null}
IModuleRegistry public immutable MODULE_REGISTRY
```

Returns the protocol-wide ModuleRegistry.

### IP\_GRAPH\_ACL

```solidity theme={null}
IPGraphACL public immutable IP_GRAPH_ACL
```

Returns the protocol-wide IP Graph Access Control List.

## Functions

### initialize

```solidity theme={null}
function initialize(address accessManager) public initializer
```

Initializer for this implementation contract.

**Parameters:**

* `accessManager`: The address of the protocol admin roles contract.

### attachDefaultLicenseTerms

```solidity theme={null}
function attachDefaultLicenseTerms(address ipId) external
```

Attaches the default license terms to an IP.

**Parameters:**

* `ipId`: The IP ID to attach default license terms to.

### attachLicenseTerms

```solidity theme={null}
function attachLicenseTerms(
    address ipId,
    address licenseTemplate,
    uint256 licenseTermsId
) external
```

Attaches specific license terms to an IP. The function must be called by the IP owner or an authorized operator.

**Parameters:**

* `ipId`: The IP ID.
* `licenseTemplate`: The address of the license template.
* `licenseTermsId`: The ID of the license terms.

### mintLicenseTokens

```solidity theme={null}
function mintLicenseTokens(
    address licensorIpId,
    address licenseTemplate,
    uint256 licenseTermsId,
    uint256 amount,
    address receiver,
    bytes calldata royaltyContext,
    uint256 maxMintingFee,
    uint32 maxRevenueShare
) external returns (uint256 startLicenseTokenId)
```

Mints license tokens for the license terms attached to an IP. The license tokens are minted to the receiver.

The license terms must be attached to the IP before calling this function, but it can mint license tokens of default license terms without explicitly attaching them, since they are attached to all IPs by default.

IP owners can mint license tokens for their IPs for arbitrary license terms without attaching the license terms to the IP.

It might require the caller to pay a minting fee, depending on the license terms or as 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.

**Parameters:**

* `licensorIpId`: The licensor IP ID.
* `licenseTemplate`: The address of the license template.
* `licenseTermsId`: The ID of the license terms within the license template.
* `amount`: The amount of license tokens to mint.
* `receiver`: The address of the receiver.
* `royaltyContext`: The context of the royalty.
* `maxMintingFee`: The maximum minting fee that the caller is willing to pay. If set to 0, then no limit.
* `maxRevenueShare`: The maximum revenue share percentage allowed for minting the License Tokens.

**Returns:**

* `startLicenseTokenId`: The start ID of the minted license tokens.

### registerDerivative

```solidity theme={null}
function registerDerivative(
    address childIpId,
    address[] calldata parentIpIds,
    uint256[] calldata licenseTermsIds,
    address licenseTemplate,
    bytes calldata royaltyContext,
    uint256 maxMintingFee,
    uint32 maxRts,
    uint32 maxRevenueShare
) external
```

Registers a derivative directly with parent IP's license terms, without needing license tokens, and attaches the license terms of the parent IPs to the derivative IP.

The license terms must be attached to the parent IP before calling this function. All IPs have default license terms attached by default.

The derivative IP owner must be the caller or an authorized operator.

**Parameters:**

* `childIpId`: The derivative IP ID.
* `parentIpIds`: The parent IP IDs.
* `licenseTermsIds`: The IDs of the license terms that the parent IP supports.
* `licenseTemplate`: The address of the license template of the license terms IDs.
* `royaltyContext`: The context of the royalty.
* `maxMintingFee`: The maximum minting fee that the caller is willing to pay. If set to 0, then no limit.
* `maxRts`: The maximum number of royalty tokens that can be distributed to the external royalty policies.
* `maxRevenueShare`: The maximum revenue share percentage allowed for minting the License Tokens.

### registerDerivativeWithLicenseTokens

```solidity theme={null}
function registerDerivativeWithLicenseTokens(
    address childIpId,
    uint256[] calldata licenseTokenIds,
    bytes calldata royaltyContext,
    uint32 maxRts
) external
```

Registers a derivative with license tokens. The derivative IP is registered with license tokens minted from the parent IP's license terms.

The license terms of the parent IPs issued with license tokens are attached to the derivative IP.

The caller must be the derivative IP owner or an authorized operator.

**Parameters:**

* `childIpId`: The derivative IP ID.
* `licenseTokenIds`: The IDs of the license tokens.
* `royaltyContext`: The context of the royalty.
* `maxRts`: The maximum number of royalty tokens that can be distributed to the external royalty policies.

### setLicensingConfig

```solidity theme={null}
function setLicensingConfig(
    address ipId,
    address licenseTemplate,
    uint256 licenseTermsId,
    Licensing.LicensingConfig memory licensingConfig
) external
```

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

If both licenseTemplate and licenseTermsId are not specified, then the licensing config applies to all licenses of the given IP.

**Parameters:**

* `ipId`: The address of the IP for which the configuration is being set.
* `licenseTemplate`: The address of the license template used. If not specified, the configuration applies to all licenses.
* `licenseTermsId`: The ID of the license terms within the license template. If not specified, the configuration applies to all licenses.
* `licensingConfig`: The licensing configuration for the license.

### predictMintingLicenseFee

```solidity theme={null}
function predictMintingLicenseFee(
    address licensorIpId,
    address licenseTemplate,
    uint256 licenseTermsId,
    uint256 amount,
    address receiver,
    bytes calldata royaltyContext
) external view returns (address currencyToken, uint256 tokenAmount)
```

Pre-computes the minting license fee for the given IP and license terms.

This function can be used to calculate the minting license fee before minting license tokens.

**Parameters:**

* `licensorIpId`: The IP ID of the licensor.
* `licenseTemplate`: The address of the license template.
* `licenseTermsId`: The ID of the license terms.
* `amount`: The amount of license tokens to mint.
* `receiver`: The address of the receiver.
* `royaltyContext`: The context of the royalty.

**Returns:**

* `currencyToken`: The address of the ERC20 token used for minting license fee.
* `tokenAmount`: The amount of the currency token to be paid for minting license tokens.
