PILicenseTemplate
The PILicenseTemplate (Programmable IP License Template) is a smart contract that defines and manages license terms for IP assets on Story. It allows IP owners to create customizable license terms that can be attached to their IP assets, enabling them to control how their IP can be used commercially and for derivative works.
State Variables
LICENSE_REGISTRY
The address of the License Registry contract that tracks license terms and tokens.
ROYALTY_MODULE
The address of the Royalty Module contract that handles royalty payments and policies.
licenseTerms
Maps license terms IDs to their corresponding PILTerms structures.
hashedLicenseTerms
Maps the hash of license terms to their corresponding license terms ID.
licenseTermsCounter
Counter for the number of registered license terms.
Functions
initialize
Initializer for this implementation contract.
Parameters:
accessManager
: The address of the protocol admin roles contract.name
: The name of the license template.metadataURI
: The URL to the off-chain metadata.
registerLicenseTerms
Registers new license terms and returns the ID of the newly registered license terms. The license terms are hashed and the hash is used to check if the terms are already registered. It will return an existing ID if the terms are already registered.
Parameters:
terms
: The PILTerms to register.
Returns:
id
: The ID of the newly registered license terms.
exists
Checks if a license terms exists.
Parameters:
licenseTermsId
: The ID of the license terms.
Returns:
- Returns true if the license terms exists, false otherwise.
verifyMintLicenseToken
Verifies the minting of a license token. The function will be called by the LicensingModule when minting a license token to verify if the minting is allowed by the license terms.
Parameters:
licenseTermsId
: The ID of the license terms.licensee
: The address of the licensee who will receive the license token.licensorIpId
: The IP ID of the licensor who attached the license terms minting the license token.
Returns:
- Returns true if the minting is verified, false otherwise.
verifyRegisterDerivative
Verifies the registration of a derivative. This function is invoked by the LicensingModule during the registration of a derivative work to ensure compliance with the parent IP’s licensing terms.
Parameters:
childIpId
: The IP ID of the derivative.parentIpId
: The IP ID of the parent.licenseTermsId
: The ID of the license terms.licensee
: The address of the licensee.
Returns:
- Returns true if the registration is verified, false otherwise.
verifyCompatibleLicenses
Verifies if the licenses are compatible. This function is called by the LicensingModule to verify license compatibility when registering a derivative IP to multiple parent IPs.
Parameters:
licenseTermsIds
: The IDs of the license terms.
Returns:
- Returns true if the licenses are compatible, false otherwise.
verifyRegisterDerivativeForAllParents
Verifies the registration of a derivative for all parent IPs. This function is called by the LicensingModule to verify licenses for registering a derivative IP to multiple parent IPs.
Parameters:
childIpId
: The IP ID of the derivative.parentIpIds
: The IP IDs of the parents.licenseTermsIds
: The IDs of the license terms.childIpOwner
: The address of the derivative IP owner.
Returns:
- Returns true if the registration is verified, false otherwise.
getRoyaltyPolicy
Returns the royalty policy of a license terms.
Parameters:
licenseTermsId
: The ID of the license terms.
Returns:
royaltyPolicy
: The address of the royalty policy specified for the license terms.royaltyData
: The data of the royalty policy.mintingFee
: The fee for minting a license.currency
: The address of the ERC20 token, used for minting license fee and royalties.
isLicenseTransferable
Checks if a license terms is transferable.
Parameters:
licenseTermsId
: The ID of the license terms.
Returns:
- Returns true if the license terms is transferable, false otherwise.
getEarlierExpireTime
Returns the earliest expiration time among the given license terms.
Parameters:
licenseTermsIds
: The IDs of the license terms.start
: The start time.
Returns:
- Returns the earliest expiration time.
getExpireTime
Returns the expiration time of a license terms.
Parameters:
licenseTermsId
: The ID of the license terms.start
: The start time.
Returns:
- Returns the expiration time.
getLicenseTermsId
Gets the ID of the given license terms.
Parameters:
terms
: The PILTerms to get the ID for.
Returns:
selectedLicenseTermsId
: The ID of the given license terms.
getLicenseTerms
Gets license terms of the given ID.
Parameters:
selectedLicenseTermsId
: The ID of the license terms.
Returns:
terms
: The PILTerms associated with the given ID.
getLicenseTermsURI
Returns the URI of the license terms.
Parameters:
licenseTermsId
: The ID of the license terms.
Returns:
- Returns the URI of the license terms.
totalRegisteredLicenseTerms
Returns the total number of registered license terms.
Returns:
- Returns the total number of registered license terms.
supportsInterface
Checks whether the contract supports the given interface.
Parameters:
interfaceId
: The interface identifier.
Returns:
- Returns true if the contract supports the interface, false otherwise.
toJson
Converts the license terms to a JSON string which will be part of the metadata of the license token.
Parameters:
licenseTermsId
: The ID of the license terms.
Returns:
- Returns the JSON string of the license terms, following the OpenSea metadata standard.
PILTerms Structure
The PILTerms structure defines the terms for a Programmable IP License (PIL):
Parameters:
transferable
: Indicates whether the license is transferable or not.royaltyPolicy
: The address of the royalty policy contract which is required by StoryProtocol in advance.mintingFee
: The fee to be paid when minting a license.expiration
: The expiration period of the license.commercialUse
: Indicates whether the work can be used commercially or not.commercialAttribution
: Whether attribution is required when reproducing the work commercially or not.commercializerChecker
: Commercializers that are allowed to commercially exploit the work. If zero address, then no restrictions are enforced.commercializerCheckerData
: The data to be passed to the commercializer checker contract.commercialRevShare
: Percentage of revenue that must be shared with the licensor.commercialRevCelling
: The maximum revenue that can be generated from the commercial use of the work.derivativesAllowed
: Indicates whether the licensee can create derivatives of their work or not.derivativesAttribution
: Indicates whether attribution is required for derivatives of the work or not.derivativesApproval
: Indicates whether the licensor must approve derivatives of the work before they can be linked to the licensor IP ID or not.derivativesReciprocal
: Indicates whether the licensee must license derivatives of the work under the same terms or not.derivativeRevCelling
: The maximum revenue that can be generated from the derivative use of the work.currency
: The ERC20 token to be used to pay the minting fee. The token must be registered in Story Protocol.uri
: The URI of the license terms, which can be used to fetch the off-chain license terms.