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πŸ’Š), attaching licenses to individual IP Assets, registering derivatives, and the like:
LicenseRegistry.sol
/// @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

LicenseRegistry.sol
function attachLicenseTermsToIp(address ipId, address licenseTemplate, uint256 licenseTermsId) external onlyLicensingModule
This function allows you to attach License Terms to an IP Asset.
LicenseRegistry.sol
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.