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

# LicenseRegistry

The LicenseRegistry manages the registration and tracking of License NFTs (LNFTs), which represent licenses granted by IP ID licensors to create derivative IPs. It provides functionality for managing license templates, license terms, and the relationships between parent and derivative IP assets.

## State Variables

### MAX\_PARENTS

```solidity theme={null}
uint256 public constant MAX_PARENTS = 16
```

The maximum number of parent IPs a derivative IP can have.

### MAX\_ANCESTORS

```solidity theme={null}
uint256 public constant MAX_ANCESTORS = 1024
```

The maximum number of ancestor IPs a derivative IP can have.

### IP\_GRAPH

```solidity theme={null}
address public constant IP_GRAPH = address(0x0101)
```

The address of the IP Graph contract that tracks relationships between IPs.

### GROUP\_IP\_ASSET\_REGISTRY

```solidity theme={null}
IGroupIPAssetRegistry public immutable GROUP_IP_ASSET_REGISTRY
```

The address of the Group IP Asset Registry contract.

### LICENSING\_MODULE

```solidity theme={null}
ILicensingModule public immutable LICENSING_MODULE
```

The address of the Licensing Module contract.

### DISPUTE\_MODULE

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

The address of the Dispute Module contract.

### IP\_GRAPH\_ACL

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

The address of the IP Graph Access Control List contract.

### EXPIRATION\_TIME

```solidity theme={null}
bytes32 public constant EXPIRATION_TIME = "EXPIRATION_TIME"
```

The key used to store expiration time in IP Account storage.

## Functions

### initialize

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

Initializes the LicenseRegistry contract.

**Parameters:**

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

### setDefaultLicenseTerms

```solidity theme={null}
function setDefaultLicenseTerms(address newLicenseTemplate, uint256 newLicenseTermsId) external restricted
```

Sets the default license terms that are attached to all IPs by default.

**Parameters:**

* `newLicenseTemplate`: The address of the new default license template.
* `newLicenseTermsId`: The ID of the new default license terms.

### registerLicenseTemplate

```solidity theme={null}
function registerLicenseTemplate(address licenseTemplate) external restricted
```

Registers a new license template on Story.

**Parameters:**

* `licenseTemplate`: The address of the license template to register.

### setLicensingConfigForLicense

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

Sets the minting license configuration for a specific license attached to a specific IP.

**Parameters:**

* `ipId`: The address of the IP for which the configuration is being set.
* `licenseTemplate`: The address of the license template used.
* `licenseTermsId`: The ID of the license terms within the license template.
* `licensingConfig`: The configuration for minting the license.

### attachLicenseTermsToIp

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

Attaches license terms to an IP.

**Parameters:**

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

### registerDerivativeIp

```solidity theme={null}
function registerDerivativeIp(
    address childIpId,
    address[] calldata parentIpIds,
    address licenseTemplate,
    uint256[] calldata licenseTermsIds,
    bool isUsingLicenseToken
) external onlyLicensingModule
```

Registers a derivative IP and its relationship to parent IPs.

**Parameters:**

* `childIpId`: The address of the derivative IP.
* `parentIpIds`: An array of addresses of the parent IPs.
* `licenseTemplate`: The address of the license template used.
* `licenseTermsIds`: An array of IDs of the license terms.
* `isUsingLicenseToken`: Whether the derivative IP is registered with license tokens.

### initializeLicenseTemplate

```solidity theme={null}
function initializeLicenseTemplate(address ipId, address licenseTemplate) external onlyLicensingModule
```

Sets license template for an IP, if the IP has no license template set.

**Parameters:**

* `ipId`: The address of the IP to which the license template is attached.
* `licenseTemplate`: The address of the license template.

### verifyMintLicenseToken

```solidity theme={null}
function verifyMintLicenseToken(
    address licensorIpId,
    address licenseTemplate,
    uint256 licenseTermsId,
    bool isMintedByIpOwner
) external view returns (Licensing.LicensingConfig memory)
```

Verifies the minting of a license token.

**Parameters:**

* `licensorIpId`: The address of the licensor IP.
* `licenseTemplate`: The address of the license template where the license terms are defined.
* `licenseTermsId`: The ID of the license terms will mint the license token.
* `isMintedByIpOwner`: Whether the license token is minted by the IP owner.

**Returns:**

* `Licensing.LicensingConfig`: The configuration for minting the license.

### verifyGroupAddIp

```solidity theme={null}
function verifyGroupAddIp(
    address groupId,
    address groupRewardPool,
    address ipId,
    address groupLicenseTemplate,
    uint256 groupLicenseTermsId
) external view returns (Licensing.LicensingConfig memory ipLicensingConfig)
```

Verifies the group can add given IP.

**Parameters:**

* `groupId`: The address of the group.
* `groupRewardPool`: The address of the reward pool of the group.
* `ipId`: The address of the IP to be added to the group.
* `groupLicenseTemplate`: The address of the license template attached to the group.
* `groupLicenseTermsId`: The ID of the license terms attached to the group.

**Returns:**

* `ipLicensingConfig`: The configuration for license attached to the IP.

### isRegisteredLicenseTemplate

```solidity theme={null}
function isRegisteredLicenseTemplate(address licenseTemplate) external view returns (bool)
```

Checks if a license template is registered.

**Parameters:**

* `licenseTemplate`: The address of the license template to check.

**Returns:**

* `bool`: Whether the license template is registered.

### isDerivativeIp

```solidity theme={null}
function isDerivativeIp(address childIpId) external view returns (bool)
```

Checks if an IP is a derivative IP.

**Parameters:**

* `childIpId`: The address of the IP to check.

**Returns:**

* `bool`: Whether the IP is a derivative IP.

### hasDerivativeIps

```solidity theme={null}
function hasDerivativeIps(address parentIpId) external view returns (bool)
```

Checks if an IP has derivative IPs.

**Parameters:**

* `parentIpId`: The address of the IP to check.

**Returns:**

* `bool`: Whether the IP has derivative IPs.

### exists

```solidity theme={null}
function exists(address licenseTemplate, uint256 licenseTermsId) external view returns (bool)
```

Checks if license terms exist.

**Parameters:**

* `licenseTemplate`: The address of the license template where the license terms are defined.
* `licenseTermsId`: The ID of the license terms.

**Returns:**

* `bool`: Whether the license terms exist.

### hasIpAttachedLicenseTerms

```solidity theme={null}
function hasIpAttachedLicenseTerms(
    address ipId,
    address licenseTemplate,
    uint256 licenseTermsId
) external view returns (bool)
```

Checks if an IP has attached any license terms.

**Parameters:**

* `ipId`: The address of the IP to check.
* `licenseTemplate`: The address of the license template where the license terms are defined.
* `licenseTermsId`: The ID of the license terms.

**Returns:**

* `bool`: Whether the IP has attached any license terms.

### getAttachedLicenseTerms

```solidity theme={null}
function getAttachedLicenseTerms(
    address ipId,
    uint256 index
) external view returns (address licenseTemplate, uint256 licenseTermsId)
```

Gets the attached license terms of an IP by its index.

**Parameters:**

* `ipId`: The address of the IP.
* `index`: The index of the attached license terms within the array of all attached license terms of the IP.

**Returns:**

* `licenseTemplate`: The address of the license template where the license terms are defined.
* `licenseTermsId`: The ID of the license terms.

### getAttachedLicenseTermsCount

```solidity theme={null}
function getAttachedLicenseTermsCount(address ipId) external view returns (uint256)
```

Gets the count of attached license terms of an IP.

**Parameters:**

* `ipId`: The address of the IP.

**Returns:**

* `uint256`: The count of attached license terms.

### getDerivativeIp

```solidity theme={null}
function getDerivativeIp(address parentIpId, uint256 index) external view returns (address childIpId)
```

Gets the derivative IP of an IP by its index.

**Parameters:**

* `parentIpId`: The address of the IP.
* `index`: The index of the derivative IP within the array of all derivative IPs of the IP.

**Returns:**

* `childIpId`: The address of the derivative IP.

### getDerivativeIpCount

```solidity theme={null}
function getDerivativeIpCount(address parentIpId) external view returns (uint256)
```

Gets the count of derivative IPs of an IP.

**Parameters:**

* `parentIpId`: The address of the IP.

**Returns:**

* `uint256`: The count of derivative IPs.

### getParentIp

```solidity theme={null}
function getParentIp(address childIpId, uint256 index) external view returns (address parentIpId)
```

Gets the parent IP of an IP by its index.

**Parameters:**

* `childIpId`: The address of the IP.
* `index`: The index of the parent IP within the array of all parent IPs of the IP.

**Returns:**

* `parentIpId`: The address of the parent IP.

### isParentIp

```solidity theme={null}
function isParentIp(address parentIpId, address childIpId) external view returns (bool)
```

Checks if an IP is a parent of another IP.

**Parameters:**

* `parentIpId`: The address of the potential parent IP.
* `childIpId`: The address of the potential child IP.

**Returns:**

* `bool`: Whether the IP is a parent of the other IP.

### getParentIpCount

```solidity theme={null}
function getParentIpCount(address childIpId) external view returns (uint256)
```

Gets the count of parent IPs.

**Parameters:**

* `childIpId`: The address of the child IP.

**Returns:**

* `uint256`: The count of parent IPs.

### getAncestorsCount

```solidity theme={null}
function getAncestorsCount(address ipId) external returns (uint256)
```

Gets the count of ancestors IPs.

**Parameters:**

* `ipId`: The ID of IP asset.

**Returns:**

* `uint256`: The count of ancestor IPs.

### getLicensingConfig

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

Retrieves the minting license configuration for a given license terms of the IP.

**Parameters:**

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

**Returns:**

* `Licensing.LicensingConfig`: The configuration for minting the license.

### getExpireTime

```solidity theme={null}
function getExpireTime(address ipId) external view returns (uint256)
```

Gets the expiration time for an IP.

**Parameters:**

* `ipId`: The address of the IP.

**Returns:**

* `uint256`: The expiration time, 0 means never expired.

### isExpiredNow

```solidity theme={null}
function isExpiredNow(address ipId) external view returns (bool)
```

Checks if an IP is expired.

**Parameters:**

* `ipId`: The address of the IP.

**Returns:**

* `bool`: Whether the IP is expired.

### getDefaultLicenseTerms

```solidity theme={null}
function getDefaultLicenseTerms() external view returns (address licenseTemplate, uint256 licenseTermsId)
```

Returns the default license terms.

**Returns:**

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

### isDefaultLicense

```solidity theme={null}
function isDefaultLicense(address licenseTemplate, uint256 licenseTermsId) external view returns (bool)
```

Checks if the license terms are the default license terms.

**Parameters:**

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

**Returns:**

* `bool`: Whether the license terms are the default license terms.

### getParentLicenseTerms

```solidity theme={null}
function getParentLicenseTerms(
    address childIpId,
    address parentIpId
) external view returns (address licenseTemplate, uint256 licenseTermsId)
```

Returns the license terms through which a child IP links to a parent IP.

**Parameters:**

* `childIpId`: The address of the child IP.
* `parentIpId`: The address of the parent IP.

**Returns:**

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

### getRoyaltyPercent

```solidity theme={null}
function getRoyaltyPercent(
    address ipId,
    address licenseTemplate,
    uint256 licenseTermsId
) external view returns (uint32 royaltyPercent)
```

Return the Royalty percentage of the license terms of the IP.

**Parameters:**

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

**Returns:**

* `royaltyPercent`: The Royalty percentage 100% is 100\_000\_000.
