Overview
By default, Embedded checkout includes wallet connector UI. However, if your customers have already connected their wallet to your website, you can configure that connected wallet directly as the payer. This is useful when:- You’re already using a wallet connection solution (like RainbowKit, Solana Wallet Adapter, Web3Modal, or ConnectKit)
- You are using embedded wallets (from Crossmint or other providers)
Quick Integration
Here’s a simple example using wagmi, viem and TanStack Query:Make sure you have this environment variables on
.env.local
or directly replace it in the code bash NEXT_PUBLIC_CLIENT_API_KEY="__YOUR_CLIENT_KEY__" # From API Keys page NEXT_PUBLIC_RECIPIENT_WALLET_ADDRESS="" # Address receiving the assets NEXT_PUBLIC_RECEIPT_EMAIL="user@example.com" NEXT_PUBLIC_COLLECTION_ID="__YOUR_COLLECTION_ID__" # From Collection details page
When the user clicks the hosted checkout button, our SDK will first call
handleChainSwitch
to ensure the correct
network is set, then handleSignAndSendTransaction
to complete the purchase.Payer Configuration
Thepayer
prop accepts the following configuration:
Property | Type | Description |
---|---|---|
address | string | The wallet address of the payer |
initialChain | PayerSupportedBlockchains | The initial blockchain (e.g. “polygon”, “ethereum”, “base-sepolia”) |
supportedChains | PayerSupportedBlockchains[] | Optional list of supported chains. Defaults to initialChain if not specified |
handleChainSwitch | (chain: PayerSupportedBlockchains) => Promise<void> | Function to handle chain switching |
handleSignAndSendTransaction | (serializedTx: string) => Promise<TransactionResponse> | Function to handle transaction signing and sending, where TransactionResponse is either { success: true, txId: string } or { success: false, errorMessage: string } |
Popular Wallet Solutions
You can integrate Crossmint with popular Web3 solutions:RainbowKit
Web3Modal
Best Practices
- Error Handling: Always return clear error messages in
handleSignAndSendTransaction
- Chain Support: Be explicit about supported chains to avoid runtime errors
- User Experience: Show loading states during chain switches and transactions
- Wallet Connection: Ensure wallet is connected before showing checkout