Create an IP Asset License

In this section, we will go through how you can programmatically generate a license, which in the context of Story Protocol refers to an NFT representing the permissions to create a derivative (or "remix") of an originating IP Asset (IPA). These licenses can then be burned to have your IP materialize as derivative IPAs in the protocol (see Register an NFT as an IPA remix).

Creating a license is a straightforward process. It simply requires identification of a originating IPA, and one of its attached policies that will be used to mint the license (to understand how policies work, refer to Adding a policy to an IPA.

In the below code, we go over how Alice can mint a license to Bob:

import { ILicensingModule } from "@story-protocol/core/interfaces/licensing/LicensingModule.sol"
import { StoryProtocolGateway } from "@story-protocol/periphery/StoryProtocolGateway.sol";
import { PILPolicy } from "@story-protocol/core/modules/licensing/PILPolicyFrameworkManager.sol";
import { IPAssetRegistry } from "@story-protocol/core/IPAssetRegistry.sol";

contract ExampleIPALicenseCreation {
   
	bytes ROYALTY_CONTEXT = "";
  StoryProtocolGateway public SPG;
  address public ROYALTY_POLICY;
  uint256 public MINTING_FEE;
  address public MINTING_FEE_TOKEN;
  
  constructor(address spg, address royaltyPolicy, uint256 mintingFee, uint256 mintingFeeToken) {
    SPG = spg;
    ROYALTY_POLICY = royaltyPolicy;
    MINTING_FEE = mintingFee;
    MINTING_FEE_TOKEN = mintingFeeToken;
  }
  
  function createLicense(
  	PILPolicy memory. pilPolicy,
    address licensorIpId
	) {
     spg.mintLicensePIL(pilPolicy, licensorIpId, 1, ROYATY_CONTEXT, MINTING_FEE, MINTING_FEE_TOKNE);
  
  }
}