@cdr-kit/story/Overview

@cdr-kit/story

Thin TypeScript wrappers over @story-protocol/core-sdk: register an IP asset, attach PIL license terms, mint license tokens, register derivatives, wrap IP into WIP. Plus the agent.publish() one-shot.
import { PILFlavor, createStoryClient } from "@cdr-kit/story"

agent.publish() — the one-shot

Collapses 4 normally-separate Story SDK calls into a single agent method. Returns the IP / license / vault artifacts a buyer needs to subscribe + read.

ts
import { CdrAgent } from "@cdr-kit/agent";
import { PILFlavor } from "@cdr-kit/story";

const agent = new CdrAgent({ privateKey: process.env.CDR_PRIVATE_KEY!, network: "aeneid" });

const result = await agent.publish({
data: new TextEncoder().encode("the secret data"),
spgNftContract: "0xYourSpgCollection",
pilTerms: PILFlavor.commercialUse({
  defaultMintingFee: 1_000_000_000_000_000_000n,  // 1 WIP per license
  commercialRevShare: 5,                            // 5% derivative revenue
}),
});

// → { ipId, tokenId, licenseTermsId, vaultUuid,
//     vaultTxHash, ipRegisterTxHash, writeTxHash }

Buyer flow

Once the seller publishes, share { ipId, licenseTermsId, vaultUuid } with buyers (URL, QR, whatever). Buyer wraps IP → mints license token → reads vault:

ts
// Buyer flow once they have { ipId, licenseTermsId, vaultUuid }:
await agent.wrapIp({ amountWei: 1_000_000_000_000_000_000n });
await agent.approveWip({ spender: ROYALTY_MODULE, amountWei: 1_000_000_000_000_000_000n });

const { licenseTokenIds } = await agent.mintLicenseTokens({
licensorIpId: ipId,
licenseTermsId,
amount: 1n,
maxMintingFee: 1_000_000_000_000_000_000n,
});

const bytes = await agent.accessLicenseGated({
uuid: vaultUuid,
licenseTokenId: licenseTokenIds[0]!,
});

PIL flavors

  • PILFlavor.nonCommercialSocialRemixing() — open-source / free public IP (0 fee, 0 rev share).
  • PILFlavor.commercialUse({ defaultMintingFee, commercialRevShare }) — paid one-off use, no derivatives.
  • PILFlavor.commercialRemix({ defaultMintingFee, commercialRevShare }) — paid use + derivative works allowed, revenue flows back.
  • PILFlavor.creativeCommonsAttribution() — CC-BY style (0 fee, attribution required).

Lower-level wrappers

If publish() doesn't fit, the individual wrappers stay accessible from the agent: registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerPilTerms, wrapIp, approveWip. Each is a thin @story-protocol/core-sdk wrapper with normalized return shapes.

React hooks

@cdr-kit/react exposes useStoryClient (memoized client bound to the wagmi wallet), useRegisterIp, useAttachLicenseTerms, useMintLicenseToken, and usePublish (the one-shot delegator). Both @cdr-kit/agent and @cdr-kit/story are optional peer deps on the React package — pay only when you publish.

Design skill

See design-publish-with-story SKILL.md for the decision tree on picking PIL flavor, prerequisites (SPG NFT collection), common failure modes, and the agent / CLI / MCP triangulation.