License Terms는 IP에서 발행된 라이선스에 대한 제한을 정의하는 구성 가능한 값의 집합입니다. 예를 들어, “이 라이선스를 발행하면 수익의 50%를 나와 공유해야 합니다.” 전체 약관 세트는 PIL Terms에서 확인할 수 있습니다.
전제 조건
튜토리얼을 시작하기 전에 완료해야 할 몇 가지 단계가 있습니다.
- 다음을 완료하세요 Setup Your Own Project
시작하기 전에
만약 생성하려는 동일한 매개변수 집합에 대한 License Terms가 이미 존재한다면, 다시 생성할 필요가 없습니다. License Terms는 프로토콜 전체에 적용되므로, 기존 License Terms를 licenseTermsId
로 사용할 수 있습니다.
라이선스 약관 등록하기
전체 약관 세트는 PIL Terms에서 확인할 수 있습니다.
작동을 확인하고 결과를 검증하기 위해 test/1_LicenseTerms.t.sol
아래에 테스트 파일을 만들어 봅시다:
test/1_LicenseTerms.t.sol
// 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/developers/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);
}
}
PIL Flavors
위에서 보시다시피, 많은 약관 중에서 선택해야 합니다.
새로운 약관을 등록하는 데 도움이 되는 편의 함수들이 있습니다. 우리는 PIL Flavors를 만들었습니다. 이는 어떤 약관을 사용할지 결정하는 데 도움이 되는 인기 있는 라이선스 약관 조합을 미리 구성한 것입니다. 이러한 PIL Flavors를 확인한 다음 다음과 같은 편의 함수를 사용하여 약관을 등록할 수 있습니다:
예를 들어:
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
});
코드를 테스트하세요!
실행하세요 forge build
. 모든 것이 성공적이라면, 명령어가 성공적으로 컴파일될 것입니다.
이제 다음 명령어를 실행하여 테스트를 진행하세요:
forge test --fork-url https://aeneid.storyrpc.io/ --match-path test/1_LicenseTerms.t.sol
IP에 약관 첨부하기
축하합니다, 새로운 라이선스 약관을 만들었습니다!
이제 새로운 라이선스 약관을 등록했으니, 이를 IP 자산에 첨부할 수 있습니다. 이를 통해 다른 사람들이 라이선스를 발급받고 약관에 따라 제한된 방식으로 당신의 IP를 사용할 수 있게 됩니다.
다음 페이지에서 이에 대해 살펴보겠습니다.