Creating a React minting app

This example uses RainbowKit and Viem adapter. The SDK also works with Ethers v5 via the EthersV5 adapter.

The repository includes a complete example at examples/rainbowkit-mint, demonstrating how to implement minting with Manifold products including Edition Products

Overview

The edition RainbowKit example showcases how to:

  • Connect wallets with RainbowKit + wagmi

  • Mint Edition products through the Manifold Client SDK

  • Run on Next.js 14 with the App Router and TypeScript

  • Display mint progress, costs, and errors in the UI

  • Complete example at examples/rainbowkit-mint

Quick start

  1. Install workspace dependencies

    pnpm install
  2. Create environment variables

    cp .env.example \
       env.local

    Fill in:

    NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
    NEXT_PUBLIC_INSTANCE_ID=your_edition_instance_id
    NEXT_PUBLIC_RPC_URL_SEPOLIA=your_alchemy_rpc_url

    NEXT_PUBLIC_INSTANCE_ID must point to an Edition product you published in Manifold Studio. NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is optional but required if you want to support WalletConnect wallets. NEXT_PUBLIC_RPC_URL_SEPOLIA your Alchemy Sepolia RPC URL.

  3. Launch the example

Visit http://localhost:3000 and connect a wallet with RainbowKit’s ConnectButton.

Key implementation steps

Ensure you have the ConnectButton component on your page. This handles wallet connections, which are required to create an Account that the SDK uses for checks and transaction execution.

  1. Implement Minting Logic in MintButton.tsx

Core Steps

a. Create a Manifold Client with a public provider

b. Create an Account representing the connected user.

c. Fetch the product and verify its type

d. Check the product status to ensure it’s still active

e. Prepare the purchase by specifying the amount

f. Execute the purchase

Key points:

  • createAccountViem wraps wagmi’s wallet client so the SDK can sign and send transactions on the user’s behalf.

  • preparePurchase performs all eligibility checks (allowlists, supply, promo codes) and returns the total cost breakdown. Supply the same account so balance checks run against the connected wallet.

  • purchase executes the transaction sequence (ERC-20 approvals, mint, etc.) and returns a Receipt with the final transaction hash and minted tokens.

Display token media and on-chain stats

You can enrich the UI with product art and live supply data directly from the SDK:

Best practices:

  • Check status with getStatus before attempting a purchase to verify the product is active.

  • Handle ClientSDKError codes for common cases such as ineligibility, sold-out items, or insufficient funds.

  • Call getAllocations when you need to show remaining allowlist spots.

  • Inspect Receipt.order to display which tokens were minted after purchase.

Last updated