Register an IP Asset in TypeScript
This section demonstrates how to register an IP Asset using the TypeScript SDK. There are generally two methods of IP registration:
- Register an existing NFT as an IP Asset
- Create an NFT and register it as an IP Asset in one transaction
Prerequisites
- Setup the client object.
Register an Existing NFT as an IP Asset
You can register your NFT as an IP Asset by simply calling client.ipAsset.register()
and passing in the token's contract address and token ID, like so:
Default License Terms
Note that every single IP Asset registered on Story automatically has Non-Commercial Social Remixing License Terms attached to it.
If it's a root IP Asset (meaning it has no more parents), you can attach more License Terms to it later. Please see Attach Terms to an IP Asset in TypeScript for more info.
import { toHex } from 'viem';
const response = await client.ipAsset.register({
nftContract: "0xd516482bef63Ff19Ed40E4C6C2e626ccE04e19ED", // your NFT contract address
tokenId: "12", // your NFT token ID
ipMetadata: {
ipMetadataURI: 'test-uri',
ipMetadataHash: toHex('test-metadata-hash', { size: 32 }),
nftMetadataHash: toHex('test-nft-metadata-hash', { size: 32 }),
nftMetadataURI: 'test-nft-uri',
},
txOptions: { waitForTransaction: true }
});
console.log(`Root IPA created at transaction hash ${response.txHash}, IPA ID: ${response.ipId}`)
export type RegisterRequest = {
nftContract: Address;
tokenId: string | number | bigint;
deadline?: string | number | bigint;
} & IpMetadataAndTxOption;
type IpMetadataAndTxOption = {
ipMetadata?: {
ipMetadataURI?: string;
ipMetadataHash?: Hex;
nftMetadataURI?: string;
nftMetadataHash?: Hex;
};
txOptions?: TxOptions;
};
export type RegisterIpResponse = {
txHash?: string;
encodedTxData?: EncodedTxData;
ipId?: Address;
};
âšī¸ If the provided
tokenId
from thenftContract
has already been registered, theresponse
object will contain theipId
of the existing IP Asset and an undefinedtxHash
.
Setting waitForTransaction: true
in the transaction options will return the ipId
of the newly registered IP asset.
After we run the above code, the console output will look like:
Root IPA created at transaction hash 0xa3e1caa7c2124b1550d459abc739291cb1be77ac73b99c097707878ac4ef57ae,
IPA ID: 0x4c1f8c1035a8cE379dd4ed666758Fb29696CF721
Create an NFT and Register it as an IP Asset
To mint an NFT and register it as an IP Asset all in one transaction, you can use the mintAndRegisterIpAssetWithPilTerms
function provided by the SPG here.
Updated about 20 hours ago