ILicenseToken

Git Source

Title: ILicenseToken

Interface for License Token contract (ERC-1155 semi-fungible tokens)

Manages licenses for IP assets with expiry and revocation

Payment tracking is handled by Marketplace contract

Functions

initialize

Initializes the LicenseToken contract (proxy pattern)

Sets up ERC1155, AccessControl, and contract references

Grants DEFAULT_ADMIN_ROLE, ARBITRATOR_ROLE, and IP_ASSET_ROLE

Can only be called once due to initializer modifier

function initialize(string memory baseURI, address admin, address ipAsset, address arbitrator) external;

Parameters

NameTypeDescription
baseURIstringBase URI for token metadata
adminaddressAddress to receive all initial admin roles
ipAssetaddressAddress of the IPAsset contract (granted IP_ASSET_ROLE)
arbitratoraddressAddress of the GovernanceArbitrator contract (granted ARBITRATOR_ROLE)

mintLicense

Mints a new license token

Only callable by IP_ASSET_ROLE through IPAsset contract

Validates IP asset exists via hasActiveDispute() call

Exclusive licenses must have supply = 1 and only one can exist per IP asset

If maxMissedPayments = 0, defaults to DEFAULT_MAX_MISSED_PAYMENTS (3)

If penaltyRateBPS = 0, defaults to DEFAULT_PENALTY_RATE (500)

penaltyRateBPS must be <= MAX_PENALTY_RATE (5000)

Updates IP asset active license count

function mintLicense(
    address to,
    uint256 ipAssetId,
    uint256 supply,
    string memory publicMetadataURI,
    string memory privateMetadataURI,
    uint256 expiryTime,
    string memory terms,
    bool isExclusive,
    uint256 paymentInterval,
    uint8 maxMissedPayments,
    uint16 penaltyRateBPS
) external returns (uint256 licenseId);

Parameters

NameTypeDescription
toaddressAddress to receive the license
ipAssetIduint256The IP asset to license
supplyuint256Number of license tokens to mint (must be 1 for exclusive licenses)
publicMetadataURIstringPublicly accessible metadata
privateMetadataURIstringPrivate metadata (access controlled)
expiryTimeuint256Unix timestamp when license expires (0 = perpetual)
termsstringHuman-readable license terms
isExclusiveboolWhether this is an exclusive license
paymentIntervaluint256Payment interval in seconds (0 = ONE_TIME, >0 = RECURRENT)
maxMissedPaymentsuint8Maximum missed payments before auto-revocation (0 = use DEFAULT_MAX_MISSED_PAYMENTS)
penaltyRateBPSuint16Penalty rate in basis points per month (0 = use DEFAULT_PENALTY_RATE, max = MAX_PENALTY_RATE)

Returns

NameTypeDescription
licenseIduint256The ID of the newly minted license

markExpired

Marks a license as expired

Can be called by anyone once expiry time has passed

Perpetual licenses (expiryTime = 0) cannot be expired

Updates IP asset active license count

function markExpired(uint256 licenseId) external;

Parameters

NameTypeDescription
licenseIduint256The license to mark as expired

batchMarkExpired

Marks multiple licenses as expired in a single transaction

Continues on error - does not revert entire batch if individual license fails

function batchMarkExpired(uint256[] memory licenseIds) external;

Parameters

NameTypeDescription
licenseIdsuint256[]Array of license IDs to mark as expired

revokeLicense

Revokes a license

Only callable by ARBITRATOR_ROLE (dispute resolution)

Clears exclusive license flag if applicable

Updates IP asset active license count

function revokeLicense(uint256 licenseId, string memory reason) external;

Parameters

NameTypeDescription
licenseIduint256The license to revoke
reasonstringHuman-readable revocation reason

revokeForMissedPayments

Revokes a license for missed payments

Anyone can call this function, but it will only succeed if missedCount >= maxMissedPayments

Payment tracking is handled by Marketplace contract

Spam prevention: built-in validation requires missedCount to meet threshold

Clears exclusive license flag if applicable

Updates IP asset active license count

function revokeForMissedPayments(uint256 licenseId, uint256 missedCount) external;

Parameters

NameTypeDescription
licenseIduint256The license to revoke
missedCountuint256Number of missed payments (must meet maxMissedPayments threshold)

getPublicMetadata

Gets the public metadata URI for a license

function getPublicMetadata(uint256 licenseId) external view returns (string memory uri);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
uristringThe public metadata URI

getPrivateMetadata

Gets the private metadata URI for a license

Access controlled - only license holder, granted accounts, and admin

function getPrivateMetadata(uint256 licenseId) external view returns (string memory uri);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
uristringThe private metadata URI

grantPrivateAccess

Grants access to private metadata for an account

Only license holder can grant access

function grantPrivateAccess(uint256 licenseId, address account) external;

Parameters

NameTypeDescription
licenseIduint256The license ID
accountaddressThe account to grant access to

revokePrivateAccess

Revokes private metadata access from an account

Only license holder can revoke access

function revokePrivateAccess(uint256 licenseId, address account) external;

Parameters

NameTypeDescription
licenseIduint256The license ID
accountaddressThe account to revoke access from

hasPrivateAccess

Checks if an account has been granted private metadata access

function hasPrivateAccess(uint256 licenseId, address account) external view returns (bool hasAccess);

Parameters

NameTypeDescription
licenseIduint256The license ID
accountaddressThe account to check

Returns

NameTypeDescription
hasAccessboolWhether the account has been granted access

isRevoked

Checks if a license is revoked

function isRevoked(uint256 licenseId) external view returns (bool revoked);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
revokedboolWhether the license is revoked

isExpired

Checks if a license is expired

function isExpired(uint256 licenseId) external view returns (bool expired);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
expiredboolWhether the license is expired

setArbitratorContract

Updates the GovernanceArbitrator contract address

Only callable by DEFAULT_ADMIN_ROLE

Revokes ARBITRATOR_ROLE from old address and grants to new address

function setArbitratorContract(address arbitrator) external;

Parameters

NameTypeDescription
arbitratoraddressNew arbitrator contract address (cannot be zero address)

setIPAssetContract

Updates the IPAsset contract address

Only callable by DEFAULT_ADMIN_ROLE

Revokes IP_ASSET_ROLE from old address and grants to new address

function setIPAssetContract(address ipAsset) external;

Parameters

NameTypeDescription
ipAssetaddressNew IP asset contract address (cannot be zero address)

grantRole

Grants a role to an account

Only callable by role admin

function grantRole(bytes32 role, address account) external;

Parameters

NameTypeDescription
rolebytes32The role identifier
accountaddressThe account to grant the role to

supportsInterface

Checks if contract supports a given interface

function supportsInterface(bytes4 interfaceId) external view returns (bool supported);

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier (ERC-165)

Returns

NameTypeDescription
supportedboolWhether the interface is supported

getPaymentInterval

Gets the payment interval for a license

function getPaymentInterval(uint256 licenseId) external view returns (uint256 interval);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
intervaluint256Payment interval in seconds (0 = ONE_TIME, >0 = RECURRENT)

isRecurring

Checks if a license has recurring payments

function isRecurring(uint256 licenseId) external view returns (bool recurring);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
recurringboolTrue if payment interval > 0

isOneTime

Checks if a license is one-time payment

function isOneTime(uint256 licenseId) external view returns (bool oneTime);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
oneTimeboolTrue if payment interval == 0

getLicenseInfo

Gets comprehensive license information

function getLicenseInfo(uint256 licenseId)
    external
    view
    returns (
        uint256 ipAssetId,
        uint256 supply,
        uint256 expiryTime,
        string memory terms,
        uint256 paymentInterval,
        bool isExclusive,
        bool revokedStatus,
        bool expiredStatus
    );

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
ipAssetIduint256The IP asset this license is for
supplyuint256Number of license tokens minted
expiryTimeuint256Unix timestamp when license expires
termsstringHuman-readable license terms
paymentIntervaluint256Payment interval in seconds
isExclusiveboolWhether this is an exclusive license
revokedStatusboolWhether the license has been revoked
expiredStatusboolWhether the license has expired

isActiveLicense

Checks if a license is currently active

A license is active if it is neither revoked nor expired

function isActiveLicense(uint256 licenseId) external view returns (bool active);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
activeboolTrue if license is not revoked and not expired

getMaxMissedPayments

Gets the maximum number of missed payments allowed for a license

function getMaxMissedPayments(uint256 licenseId) external view returns (uint8 maxMissed);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
maxMisseduint8Maximum number of missed payments before auto-revocation

setPenaltyRate

Sets the penalty rate for a specific license

function setPenaltyRate(uint256 licenseId, uint16 penaltyRateBPS) external;

Parameters

NameTypeDescription
licenseIduint256The license ID
penaltyRateBPSuint16Penalty rate in basis points (100 bps = 1% per month)

getPenaltyRate

Gets the penalty rate for a license

function getPenaltyRate(uint256 licenseId) external view returns (uint16 penaltyRate);

Parameters

NameTypeDescription
licenseIduint256The license ID

Returns

NameTypeDescription
penaltyRateuint16Penalty rate in basis points (100 bps = 1% per month)

Events

LicenseCreated

Emitted when a new license is created

event LicenseCreated(
    uint256 indexed licenseId,
    uint256 indexed ipAssetId,
    address indexed licensee,
    bool isExclusive,
    uint256 paymentInterval
);

Parameters

NameTypeDescription
licenseIduint256The ID of the newly created license
ipAssetIduint256The IP asset this license is for
licenseeaddressThe address receiving the license
isExclusiveboolWhether this is an exclusive license
paymentIntervaluint256Payment interval in seconds (0 = ONE_TIME, >0 = RECURRENT)

LicenseExpired

Emitted when a license expires

event LicenseExpired(uint256 indexed licenseId);

Parameters

NameTypeDescription
licenseIduint256The license that expired

LicenseRevoked

Emitted when a license is revoked

event LicenseRevoked(uint256 indexed licenseId, string reason);

Parameters

NameTypeDescription
licenseIduint256The license that was revoked
reasonstringHuman-readable revocation reason

AutoRevoked

Emitted when a license is automatically revoked for missed payments

event AutoRevoked(uint256 indexed licenseId, uint256 missedPayments);

Parameters

NameTypeDescription
licenseIduint256The license that was auto-revoked
missedPaymentsuint256Number of missed payments that triggered revocation

PenaltyRateUpdated

Emitted when a license's penalty rate is updated

event PenaltyRateUpdated(uint256 indexed licenseId, uint16 penaltyRateBPS);

Parameters

NameTypeDescription
licenseIduint256The license ID
penaltyRateBPSuint16The new penalty rate in basis points

PrivateAccessGranted

Emitted when private metadata access is granted

event PrivateAccessGranted(uint256 indexed licenseId, address indexed account);

Parameters

NameTypeDescription
licenseIduint256The license ID
accountaddressThe account granted access

PrivateAccessRevoked

Emitted when private metadata access is revoked

event PrivateAccessRevoked(uint256 indexed licenseId, address indexed account);

Parameters

NameTypeDescription
licenseIduint256The license ID
accountaddressThe account whose access was revoked

ArbitratorContractUpdated

Emitted when the arbitrator contract is updated

event ArbitratorContractUpdated(address indexed oldArbitrator, address indexed newArbitrator);

Parameters

NameTypeDescription
oldArbitratoraddressThe previous arbitrator contract address
newArbitratoraddressThe new arbitrator contract address

IPAssetContractUpdated

Emitted when the IP asset contract is updated

event IPAssetContractUpdated(address indexed oldIPAsset, address indexed newIPAsset);

Parameters

NameTypeDescription
oldIPAssetaddressThe previous IP asset contract address
newIPAssetaddressThe new IP asset contract address

Errors

InvalidIPAsset

Thrown when attempting to create license for invalid IP asset

error InvalidIPAsset();

InvalidSupply

Thrown when license supply is invalid (e.g., zero)

error InvalidSupply();

ExclusiveLicenseMustHaveSupplyOne

Thrown when exclusive license does not have supply of exactly 1

error ExclusiveLicenseMustHaveSupplyOne();

ExclusiveLicenseAlreadyExists

Thrown when attempting to create multiple exclusive licenses for same IP

error ExclusiveLicenseAlreadyExists();

LicenseIsPerpetual

Thrown when attempting to expire a perpetual license

error LicenseIsPerpetual();

LicenseNotYetExpired

Thrown when attempting to mark a license as expired before expiry time

error LicenseNotYetExpired();

AlreadyMarkedExpired

Thrown when attempting to mark an already expired license as expired

error AlreadyMarkedExpired();

AlreadyRevoked

Thrown when attempting to revoke an already revoked license

error AlreadyRevoked();

NotAuthorizedForPrivateMetadata

Thrown when unauthorized access to private metadata is attempted

error NotAuthorizedForPrivateMetadata();

NotLicenseOwner

Thrown when non-license owner attempts owner-only operation

error NotLicenseOwner();

NotIPOwner

Thrown when non-IP owner attempts IP-owner-only operation

error NotIPOwner();

InsufficientMissedPayments

Thrown when insufficient missed payments for auto-revocation

error InsufficientMissedPayments();

CannotTransferExpiredLicense

Thrown when attempting to transfer an expired license

error CannotTransferExpiredLicense();

CannotTransferRevokedLicense

Thrown when attempting to transfer a revoked license

error CannotTransferRevokedLicense();

InvalidArbitratorAddress

Thrown when attempting to set arbitrator to zero address

error InvalidArbitratorAddress();

InvalidIPAssetAddress

Thrown when attempting to set IP asset contract to zero address

error InvalidIPAssetAddress();

InvalidMaxMissedPayments

Thrown when maxMissedPayments is zero or exceeds allowed maximum

error InvalidMaxMissedPayments();

InvalidPenaltyRate

Thrown when penalty rate exceeds maximum allowed rate

error InvalidPenaltyRate();

Structs

License

License configuration and state

struct License {
    uint256 ipAssetId;
    uint256 supply;
    uint256 expiryTime;
    string terms;
    bool isExclusive;
    bool isRevoked;
    string publicMetadataURI;
    string privateMetadataURI;
    uint256 paymentInterval;
    uint8 maxMissedPayments;
    uint16 penaltyRateBPS;
}

Properties

NameTypeDescription
ipAssetIduint256The IP asset this license is for
supplyuint256Number of license tokens minted (ERC-1155 supply)
expiryTimeuint256Unix timestamp when license expires (0 = perpetual, never expires)
termsstringHuman-readable license terms
isExclusiveboolWhether this is an exclusive license
isRevokedboolWhether the license has been revoked
publicMetadataURIstringPublicly accessible metadata URI
privateMetadataURIstringPrivate metadata URI (access controlled)
paymentIntervaluint256Payment interval in seconds (0 = ONE_TIME, >0 = RECURRENT)
maxMissedPaymentsuint8Maximum number of missed payments before auto-revocation (1-255, 0 defaults to 3)
penaltyRateBPSuint16Penalty rate in basis points (100 bps = 1% per month, 0 defaults to 500, max 5000 = 50%)