Register License Terms
Learn how to create new License Terms in Solidity.
License Terms are a configurable set of values that define restrictions on licenses minted from your IP that have those terms. For example, "If you mint this license, you must share 50% of your revenue with me." You can view the full set of terms in PIL Terms.
⚠️ Prerequisites
There are a few steps you have to complete before you can start the tutorial.
- Complete the Setup Your Own Project
0. Before We Start
It's important to know that if License Terms already exist for the identical set of parameters you intend to create, it is unnecessary to create it again. License Terms are protocol-wide, so you can use existing License Terms by its licenseTermsId
.
1. Register License Terms
You can view the full set of terms in PIL Terms.
Let's create a test file under test/1_LicenseTerms.t.sol
to see it work and verify the results:
Contract Addresses
We have filled in the addresses from the Story contracts for you. However you can also find the addresses for them here: Deployed Smart Contracts
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
import { Test } from "forge-std/Test.sol";
import { IPILicenseTemplate } from "@storyprotocol/core/interfaces/modules/licensing/IPILicenseTemplate.sol";
import { PILTerms } from "@storyprotocol/core/interfaces/modules/licensing/IPILicenseTemplate.sol";
// Run this test:
// forge test --fork-url https://aeneid.storyrpc.io/ --match-path test/1_LicenseTerms.t.sol
contract LicenseTermsTest is Test {
address internal alice = address(0xa11ce);
// For addresses, see https://docs.story.foundation/docs/deployed-smart-contracts
// Protocol Core - PILicenseTemplate
IPILicenseTemplate internal PIL_TEMPLATE = IPILicenseTemplate(0x2E896b0b2Fdb7457499B56AAaA4AE55BCB4Cd316);
// Protocol Core - RoyaltyPolicyLAP
address internal ROYALTY_POLICY_LAP = 0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E;
// Revenue Token - MERC20
address internal MERC20 = 0xF2104833d386a2734a4eB3B8ad6FC6812F29E38E;
function setUp() public {}
/// @notice Registers new PIL Terms. Anyone can register PIL Terms.
function test_registerPILTerms() public {
PILTerms memory pilTerms = PILTerms({
transferable: true,
royaltyPolicy: ROYALTY_POLICY_LAP,
defaultMintingFee: 0,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
commercializerChecker: address(0),
commercializerCheckerData: "",
commercialRevShare: 0,
commercialRevCeiling: 0,
derivativesAllowed: true,
derivativesAttribution: true,
derivativesApproval: true,
derivativesReciprocal: true,
derivativeRevCeiling: 0,
currency: MERC20,
uri: ""
});
uint256 licenseTermsId = PIL_TEMPLATE.registerLicenseTerms(pilTerms);
uint256 selectedLicenseTermsId = PIL_TEMPLATE.getLicenseTermsId(pilTerms);
assertEq(licenseTermsId, selectedLicenseTermsId);
}
}
1a. 🍦 PIL Flavors
As you see above, you have to choose between a lot of terms.
We have convenience functions to help you register new terms. We have created PIL Flavors, which are pre-configured popular combinations of License Terms to help you decide what terms to use. You can view those PIL Flavors and then register terms using the following convenience functions:
Non-Commercial Social Remixing
Free remixing with attribution. No commercialization.
Commercial Use
Pay to use the license with attribution, but don't have to share revenue.
Commercial Remix
Pay to use the license with attribution and pay % of revenue earned.
Creative Commons Attribution
Free remixing and commercial use with attribution.
For example:
import { PILFlavors } from "@storyprotocol/core/lib/PILFlavors.sol";
PILTerms memory pilTerms = PILFlavors.commercialRemix({
mintingFee: 0,
commercialRevShare: 5 * 10 ** 6, // 5% rev share
royaltyPolicy: ROYALTY_POLICY_LAP,
currencyToken: MERC20
});
2. Test Your Code!
Run forge build
. If everything is successful, the command should successfully compile.
Now run the test by executing the following command:
forge test --fork-url https://aeneid.storyrpc.io/ --match-path test/1_LicenseTerms.t.sol
3. Attach Terms to Your IP
Congratulations, you created new license terms!
Now that you have registered new license terms, we can attach them to an IP Asset. This will allow others to mint a license and use your IP, restricted by the terms.
We will go over this on the next page.
Updated 5 days ago