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

> Learn about the registry that manages license-related states on Story.

<CardGroup cols={1}>
  <Card title="LicenseRegistry.sol" href="https://github.com/storyprotocol/protocol-core-v1/blob/main/contracts/registries/LicenseRegistry.sol" icon="scroll" color="#ccb092">
    View the smart contract for the License Registry.
  </Card>
</CardGroup>

The License Registry stores all license-related states within the protocol, including managing global state like registering new License Templates like the [Programmable IP License (PIL💊)](/concepts/programmable-ip-license/overview), attaching licenses to individual [IP Assets](/concepts/ip-asset/overview), registering derivatives, and the like:

```solidity LicenseRegistry.sol theme={null}
/// @dev Storage of the LicenseRegistry
/// @param defaultLicenseTemplate The default license template address
/// @param defaultLicenseTermsId The default license terms ID
/// @param registeredLicenseTemplates Registered license templates
/// @param registeredRoyaltyPolicies Registered royalty policies
/// @param registeredCurrencyTokens Registered currency tokens
/// @param parentIps Mapping of parent IPs to derivative IPs
/// @param parentLicenseTerms Mapping of parent IPs to license terms used to link to derivative IPs
/// @param childIps Mapping of derivative IPs to parent IPs
/// @param attachedLicenseTerms Mapping of attached license terms to IP IDs
/// @param licenseTemplates Mapping of license templates to IP IDs
/// @param expireTimes Mapping of IP IDs to expire times
/// @param licensingConfigs Mapping of minting license configs to a licenseTerms of an IP
/// @dev Storage structure for the LicenseRegistry
/// @custom:storage-location erc7201:story-protocol.LicenseRegistry
struct LicenseRegistryStorage {
  address defaultLicenseTemplate;
  uint256 defaultLicenseTermsId;
  mapping(address licenseTemplate => bool isRegistered) registeredLicenseTemplates;
  mapping(address childIpId => EnumerableSet.AddressSet parentIpIds) parentIps;
  mapping(address childIpId => mapping(address parentIpId => uint256 licenseTermsId)) parentLicenseTerms;
  mapping(address parentIpId => EnumerableSet.AddressSet childIpIds) childIps;
  mapping(address ipId => EnumerableSet.UintSet licenseTermsIds) attachedLicenseTerms;
  mapping(address ipId => address licenseTemplate) licenseTemplates;
  mapping(bytes32 ipLicenseHash => Licensing.LicensingConfig licensingConfig) licensingConfigs;
}
```

### Notable Functions

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

This function allows you to attach License Terms to an IP Asset.

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

This function allows you to register an IP Asset as a derivative of another IP Asset, unlocking things like claimable royalty flows from the [💸 Royalty Module](/concepts/royalty-module/overview).
