The LicenseToken contract, also known as LNFT (License NFT), is an ERC721 token that represents a license agreement for IP assets within the Story ecosystem. It enables the creation, transfer, and management of programmable IP licenses.

State Variables

LICENSE_REGISTRY

ILicenseRegistry public immutable LICENSE_REGISTRY

The address of the protocol-wide License Registry.

LICENSING_MODULE

ILicensingModule public immutable LICENSING_MODULE

The address of the protocol-wide Licensing Module.

DISPUTE_MODULE

IDisputeModule public immutable DISPUTE_MODULE

The address of the protocol-wide Dispute Module.

MAX_COMMERCIAL_REVENUE_SHARE

uint32 public constant MAX_COMMERCIAL_REVENUE_SHARE = 100_000_000

The maximum royalty percentage is 100_000_000, which represents 100%.

LicenseTokenMetadata

struct LicenseTokenMetadata {
    address licensorIpId;
    address licenseTemplate;
    uint256 licenseTermsId;
    bool transferable;
    uint32 commercialRevShare;
}

Metadata structure for license tokens:

  • licensorIpId: The IP asset that is the licensor
  • licenseTemplate: The license template contract address
  • licenseTermsId: The ID of the license terms
  • transferable: Whether the license token can be transferred
  • commercialRevShare: The commercial revenue share percentage

Functions

initialize

function initialize(address accessManager, string memory imageUrl) public initializer

Initializes the LicenseToken contract.

Parameters:

  • accessManager: The address of the access manager.
  • imageUrl: The URL of the default image for license tokens.

setLicensingImageUrl

function setLicensingImageUrl(string calldata url) external restricted

Sets the licensing image URL for all license tokens.

Parameters:

  • url: The URL of the licensing image.

mintLicenseTokens

function mintLicenseTokens(
    address licensorIpId,
    address licenseTemplate,
    uint256 licenseTermsId,
    uint256 amount,
    address minter,
    address receiver,
    uint32 maxRevenueShare
) external onlyLicensingModule returns (uint256 startLicenseTokenId)

Mints a specified amount of License Tokens (LNFTs).

Parameters:

  • licensorIpId: The ID of the licensor IP for which the License Tokens are minted.
  • licenseTemplate: The address of the License Template.
  • licenseTermsId: The ID of the License Terms.
  • amount: The amount of License Tokens to mint.
  • minter: The address of the minter.
  • receiver: The address of the receiver of the minted License Tokens.
  • maxRevenueShare: The maximum revenue share percentage allowed for minting the License Tokens.

Returns:

  • startLicenseTokenId: The start ID of the minted License Tokens.

burnLicenseTokens

function burnLicenseTokens(address holder, uint256[] calldata tokenIds) external onlyLicensingModule

Burns the License Tokens (LTs) for the given token IDs.

Parameters:

  • holder: The address of the holder of the License Tokens.
  • tokenIds: An array of IDs of the License Tokens to be burned.

validateLicenseTokensForDerivative

function validateLicenseTokensForDerivative(
    address caller,
    address childIpId,
    uint256[] calldata tokenIds
) external view returns (
    address licenseTemplate,
    address[] memory licensorIpIds,
    uint256[] memory licenseTermsIds,
    uint32[] memory commercialRevShares
)

Validates License Tokens for registering a derivative IP.

Parameters:

  • caller: The address of the caller who register derivative with the given tokens.
  • childIpId: The ID of the derivative IP.
  • tokenIds: An array of IDs of the License Tokens to validate.

Returns:

  • licenseTemplate: The address of the License Template associated with the License Tokens.
  • licensorIpIds: An array of licensor IPs associated with each License Token.
  • licenseTermsIds: An array of License Terms associated with each validated License Token.
  • commercialRevShares: An array of commercial revenue share percentages associated with each License Token.

totalMintedTokens

function totalMintedTokens() external view returns (uint256)

Returns the total number of minted License Tokens since beginning. The number won’t decrease when license tokens are burned.

Returns:

  • uint256: The total number of minted License Tokens.

getLicenseTokenMetadata

function getLicenseTokenMetadata(uint256 tokenId) external view returns (LicenseTokenMetadata memory)

Returns the license data for the given license ID.

Parameters:

  • tokenId: The ID of the license token.

Returns:

  • LicenseTokenMetadata: The metadata of the license token.

getLicensorIpId

function getLicensorIpId(uint256 tokenId) external view returns (address)

Returns the ID of the IP asset that is the licensor of the given license ID.

Parameters:

  • tokenId: The ID of the license token.

Returns:

  • address: The ID of the licensor IP.

getLicenseTermsId

function getLicenseTermsId(uint256 tokenId) external view returns (uint256)

Returns the ID of the license terms that are used for the given license ID.

Parameters:

  • tokenId: The ID of the license token.

Returns:

  • uint256: The ID of the license terms.

getLicenseTemplate

function getLicenseTemplate(uint256 tokenId) external view returns (address)

Returns the address of the license template that is used for the given license ID.

Parameters:

  • tokenId: The ID of the license token.

Returns:

  • address: The address of the license template.

getTotalTokensByLicensor

function getTotalTokensByLicensor(address licensorIpId) external view returns (uint256)

Retrieves the total number of License Tokens minted for a given licensor IP.

Parameters:

  • licensorIpId: The ID of the licensor IP.

Returns:

  • uint256: The total number of License Tokens minted for the licensor IP.

isLicenseTokenRevoked

function isLicenseTokenRevoked(uint256 tokenId) public view returns (bool)

Returns true if the license has been revoked (licensor IP tagged after a dispute in the dispute module). If the tag is removed, the license is not revoked anymore.

Parameters:

  • tokenId: The ID of the license token.

Returns:

  • bool: True if the license is revoked.

tokenURI

function tokenURI(uint256 id) public view virtual override(ERC721Upgradeable, IERC721Metadata) returns (string memory)

ERC721 OpenSea metadata JSON representation of the LNFT parameters.

Parameters:

  • id: The ID of the license token.

Returns:

  • string: The metadata URI of the license token.