Attach Terms to an IP Asset in React

This section demonstrates how to add License Terms to an IPA. By attaching terms, an IPA becomes eligible for licensing creation. Users who then wish to creative derivatives of the IP may then mint licenses, which can be burned to enroll their IPs as derivative IPAs of the original work.

Prerequisites

  • React SDK Setup
  • An existing IPA (ipId). Learn how to register an IP Asset here.
  • An existing License Terms (termsId). Learn how to create PIL Terms here.

Attach License Terms

Below is a code example to add License Terms to our IP Asset:

import { useLicense } from "@story-protocol/react-sdk";

export default async function AttachTerms() {
  const { attachLicenseTerms } = useLicense();
  
  const response = await attachLicenseTerms({
     licenseTermsId: "1", 
     ipId: "0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721",
     txOptions: { waitForTransaction: true }
  });

  console.log(`Attached License Terms to IPA at transaction hash ${response.txHash}.`)
  
  return (
    {/* */} 
  )
}
export type AttachLicenseTermsRequest = {
  ipId: Address;
  licenseTermsId: string | number | bigint;
  licenseTemplate?: Address;
  txOptions?: TxOptions;
};
export type AttachLicenseTermsResponse = {
  txHash?: string;
  encodedTxData?: EncodedTxData;
  success?: boolean;
};

Note: Non-Commercial Social Remixing License Terms are attached by default to every IP Asset.