Skip to main content
These flows are actively being refined. Crossmint’s customer success engineers (CSE) will work with you to review your architecture. Contact Crossmint to get started.

Overview

Funding an agent’s wallet is a two-step process: your backend creates an order server-side, and then the human user completes the payment through an embedded checkout component rendered in your frontend. This keeps the agent out of the checkout process - it can request funds, but only the human can authorize spending.

Prerequisites

  • A stablecoin wallet created for the agent
  • A server-side API key
  • A client-side API key for the embedded checkout component

Integration Steps

1

Create an order server-side

When the agent needs funds (or the user decides to top up), your backend creates an order using the Crossmint Orders API. The API returns an orderId and a clientSecret that you pass to the frontend.The tokenLocator follows the format <chain>:<contract_address>. Use the USDC contract address for your target chain.
ChainStaging Token Address
Base Sepolia0x036CbD53842c5426634e7929541eC2318f3dCF7e
Solana Devnet4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
// Server-side: create an onramp order
const baseUrl = "staging"; // or "www" for production
const agentWalletAddress = wallet.address; // from wallet creation
const userEmail = user.email; // required for compliance/KYC

const response = await fetch(
    `https://${baseUrl}.crossmint.com/api/2022-06-09/orders`,
    {
        method: "POST",
        headers: {
            "X-API-KEY": process.env.CROSSMINT_SERVER_API_KEY,
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            lineItems: [
                {
                    tokenLocator: "base-sepolia:0x036CbD53842c5426634e7929541eC2318f3dCF7e",
                    executionParameters: {
                        mode: "exact-in",
                        amount: "25",
                    },
                },
            ],
            payment: {
                method: "card",
                receiptEmail: userEmail,
            },
            recipient: {
                walletAddress: agentWalletAddress,
            },
        }),
    }
);

const { order, clientSecret } = await response.json();
// Pass order.orderId and clientSecret to your frontend
The payment.receiptEmail field is required. Crossmint uses it to determine whether KYC is needed for the transaction and to send the user a payment receipt.
2

Render the embedded checkout

KYC may be required. See Onramp Overview for details on KYC requirements.
On the client side, use the CrossmintEmbeddedCheckout component to let the user complete the payment. The component handles card collection, KYC (if required), and order confirmation.
"use client";

import {
    CrossmintProvider,
    CrossmintEmbeddedCheckout,
} from "@crossmint/client-sdk-react-ui";

function AgentWalletFunding({ orderId, clientSecret }: { orderId: string; clientSecret: string }) {
    return (
        <CrossmintProvider apiKey={process.env.NEXT_PUBLIC_CROSSMINT_CLIENT_API_KEY}>
            <CrossmintEmbeddedCheckout
                orderId={orderId}
                clientSecret={clientSecret}
                payment={{
                    crypto: { enabled: false },
                    fiat: { enabled: true },
                    defaultMethod: "fiat",
                }}
            />
        </CrossmintProvider>
    );
}
The embedded checkout renders a payment form where the user enters their card details (or uses a saved card). Once payment is confirmed, the USDC is delivered to the agent’s wallet.
For the full onramp reference including additional configuration options, see the Onramp Quickstart.