@cdr-kit/react/Hooks/useMintLicenseToken
useMintLicenseToken
Buyer-side helper: mint Story license token(s) against an IP's licenseTermsId. For commercial flavors the mint is the payment — the fee flows from the buyer's wallet via WIP.
import { useMintLicenseToken } from "@cdr-kit/react"
Signature
function useMintLicenseToken(client: StoryClient | undefined): {
mint: (params: {
licensorIpId: Hex;
licenseTermsId: bigint;
amount?: bigint; // default 1n
receiver?: Hex; // default connected wallet
maxMintingFee?: bigint; // default 0n (be careful with commercial flavors!)
}) => Promise<{ licenseTokenIds: bigint[]; txHash: Hex }>;
isLoading: boolean;
error?: Error;
};Example
import { useStoryClient, useMintLicenseToken } from "@cdr-kit/react";
function BuyAccess({ ipId, licenseTermsId, priceWei }) {
const client = useStoryClient();
const { mint, isLoading } = useMintLicenseToken(client);
return (
<button
disabled={!client || isLoading}
onClick={async () => {
const { licenseTokenIds } = await mint({
licensorIpId: ipId,
licenseTermsId,
amount: 1n,
maxMintingFee: priceWei, // cap exposure if seller changes price mid-tx
});
// licenseTokenIds[0] is the buyer's proof — pass as accessAuxData to read
// a license-gated CDR vault via agent.accessLicenseGated(...).
}}
>
{isLoading ? "minting…" : `Buy license (${priceWei} wei)`}
</button>
);
}WIP wrap + approval
Commercial PIL flavors charge in WIP (the ERC-20 wrap of native IP). Before mint succeeds, the buyer wallet needs (1) enough WIP to cover the fee × amount and (2) an allowance for the RoyaltyModule. Call agent.wrapIp + agent.approveWip in the buyer flow, or wire matching hooks if you build them in your dashboard.
Always set maxMintingFee
Default maxMintingFee is 0n — which means commercial mints will revert! Pass the buyer-facing price you displayed in the UI to cap the exposure if the seller changes the fee mid-tx.