@cdr-kit/react/Hooks/useRegisterIp

useRegisterIp

Mint a fresh NFT (via your SPG collection) and register it as a Story IP asset in a single tx. Pair with useAttachLicenseTerms to make the IP licensable.
import { useRegisterIp } from "@cdr-kit/react"

Signature

type
function useRegisterIp(client: StoryClient | undefined): {
registerIp: (params: {
  spgNftContract: Hex;
  recipient?: Hex;
  ipMetadataURI?: string;
  ipMetadataHash?: Hex;
}) => Promise<{ ipId: Hex; tokenId: bigint; txHash: Hex }>;
isLoading: boolean;
error?: Error;
};

Example

tsx
import { useStoryClient, useRegisterIp } from "@cdr-kit/react";

function RegisterButton() {
const client = useStoryClient();
const { registerIp, isLoading, error } = useRegisterIp(client);
return (
  <button
    disabled={!client || isLoading}
    onClick={async () => {
      const { ipId, tokenId } = await registerIp({
        spgNftContract: "0xYourSpgCollection",
        ipMetadataURI: "ipfs://bafy...",
      });
      console.log("registered IP", ipId, "tokenId", tokenId);
    }}
  >
    {isLoading ? "registering…" : "register IP"}
  </button>
);
}

Prerequisites

You need an existing SPG NFT collection. Create one via Story's registration workflows (registrationWorkflows.createCollection) or use a previously deployed collection address. The connected wallet must be allowed to mint into it.