English
Learn how to use the SDK in React once you have it set up.
import { custom, toHex } from 'viem'; import { useWalletClient } from "wagmi"; import { StoryClient, StoryConfig } from "@story-protocol/core-sdk"; // example of how you would now use the fully setup sdk export default function TestComponent() { const { data: wallet } = useWalletClient(); async function setupStoryClient(): Promise<StoryClient> { const config: StoryConfig = { wallet: wallet, transport: custom(wallet!.transport), chainId: "aeneid", }; const client = StoryClient.newClient(config); return client; } async function registerIp() { const client = await setupStoryClient(); const response = await client.ipAsset.mintAndRegisterIp({ spgNftContract: '0xc32A8a0FF3beDDDa58393d022aF433e78739FAbc', ipMetadata: { ipMetadataURI: "test-metadata-uri", ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), nftMetadataURI: "test-nft-metadata-uri", nftMetadataHash: toHex("test-nft-metadata-hash", { size: 32 }), } }); console.log( `Root IPA created at tx hash ${response.txHash}, IPA ID: ${response.ipId}` ); } return ( {/* */} ) }