AnySpend Widget Lab for testing React components

All the React components you can drop into your app. Each one handles a different payment pattern. Try them interactively in the SDK demo.

Swaps & Payments

Cross-chain swaps, fiat onramp, direct transfers

Learn More
Checkout

Cart, order summary, forms, shipping, discounts

Learn More
Deposits

Chain selection, custom contracts, QR codes

Learn More

Core components

<AnySpend>

The primary interface component for token-to-token exchanges, fiat onramps, and cross-chain swaps.

tsx
import { AnySpend } from "@b3dotfun/sdk/anyspend/react";<AnySpend mode="modal" defaultActiveTab="crypto" destinationTokenAddress="0x..." destinationTokenChainId={8453} recipientAddress="0x..."/>;

Props

mode'modal' | 'page'pathdefault: 'modal'

Display as modal overlay or full page

defaultActiveTab'crypto' | 'fiat'pathdefault: 'crypto'

Initial payment method tab

Target token contract address

Chain ID of destination token

recipientAddressstringpath

Recipient wallet address

sourceChainIdnumberpath

Pre-select the source chain

loadOrderstringpath

Load and display an existing order by ID

hideTransactionHistoryButtonbooleanpathdefault: false

Hide the transaction history button

hideHeaderbooleanpath

Hide the component header

Hide the bottom navigation bar

onTokenSelect(token: Token, event: { preventDefault: () => void }) => voidpath

Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.

onSuccess(txHash?: string) => voidpath

Callback fired on successful transaction

customUsdInputValuesstring[]path

Custom fiat input presets (e.g., ["10", "25", "50", "100"])

Disable URL parameter syncing for swap configuration

allowDirectTransferbooleanpath

Enable direct transfers when source and destination token/chain match (skips the swap backend)

Fixed destination amount in wei. When set, users cannot change the amount.

senderAddressstringpath

Pre-fill sender address to show token balances before wallet connection

callbackMetadataRecord<string, unknown>path

Opaque metadata passed through to order callbacks (e.g., workflow form data)

returnToHomeUrlstringpath

URL to redirect to from the "Return to Home" button on the completion screen

Custom label for the recipient display (e.g., "OBSN Telegram Bot")

returnHomeLabelstringpath

Custom label for the return home button

classesAnySpendClassespath

CSS class overrides for specific elements. See Customization.

slotsAnySpendSlotspath

Render function overrides for replaceable UI elements. See Customization.

contentAnySpendContentpath

Text/message overrides for success, error, and processing states. See Customization.

themeAnySpendThemepath

Color and theme configuration. See Customization.

Usage examples

tsx
<AnySpend mode="page" recipientAddress={userWalletAddress} onSuccess={(txHash) => console.log("Completed:", txHash)}/>

<AnySpendDeposit>

A streamlined deposit interface supporting chain selection, crypto/fiat payments, and custom contract deposits.

tsx
import { AnySpendDeposit } from "@b3dotfun/sdk/anyspend/react";<AnySpendDeposit recipientAddress="0x..." destinationTokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" destinationTokenChainId={8453} onSuccess={(amount) => console.log("Deposited:", amount)}/>;

Props

recipientAddressstringrequiredpath

The wallet address to receive the deposit

destinationTokenAddressstringrequiredpath

Destination token contract address

destinationTokenChainIdnumberrequiredpath

Destination chain ID

mode'modal' | 'page'pathdefault: 'modal'

Display mode

paymentType'crypto' | 'fiat'path

Force a payment type. If not set, shows chain selection first.

sourceTokenAddressstringpath

Pre-select the source token

sourceTokenChainIdnumberpath

Pre-select the source chain. If not provided, shows chain selection step.

loadOrderstringpath

Load an existing order by ID

onSuccess(amount: string) => voidpath

Callback when deposit completes successfully

onClose() => voidpath

Callback when the close button is clicked

onTokenSelect(token: Token, event: { preventDefault: () => void }) => voidpath

Called on token selection. Call event.preventDefault() to override default behavior.

onOpenCustomModal() => voidpath

Callback for opening a custom modal (e.g., for special token handling)

orderType'hype_duel' | 'custom_exact_in' | 'swap'pathdefault: 'swap'

Order type for the deposit

depositContractConfigDepositContractConfigpath

Configuration for depositing to a custom smart contract. Creates a custom_exact_in order that calls the specified contract.

allowDirectTransferbooleanpath

Allow direct transfers when source and destination match

Fixed destination amount in wei

Minimum destination amount required

preferEoabooleanpath

Prefer using connected EOA wallet

showChainSelectionbooleanpath

Show chain selection step. Defaults to true if sourceTokenChainId is not provided.

supportedChainsChainConfig[]path

Custom list of supported chains for chain selection

topChainsCountnumberpathdefault: 3

Number of top chains to show in chain selection

Custom title for the chain selection step

Custom description for the chain selection step

minPoolSizenumberpathdefault: 1000000

Minimum pool size for filtering tokens

customUsdInputValuesstring[]path

Custom fiat input presets

actionLabelstringpath

Custom label for the action button

header(props: { anyspendPrice, isLoadingAnyspendPrice }) => JSX.Elementpath

Custom header component

mainFooterReactNodepath

Custom footer content

returnToHomeUrlstringpath

Redirect URL for the "Return to Home" button

Custom label for recipient display

returnHomeLabelstringpath

Custom label for the return button

senderAddressstringpath

Pre-fill sender address for token balance display

callbackMetadataRecord<string, unknown>path

Metadata passed through to order callbacks

isCustomDepositbooleanpathdefault: false

When true, uses AnySpendCustomExactIn for custom function deposits

classesAnySpendAllClassespath

CSS class overrides. See Customization.

slotsAnySpendSlotspath

Render function overrides. See Customization.

contentAnySpendContentpath

Text/message overrides. See Customization.

themeAnySpendThemepath

Theme configuration. See Customization.

DepositContractConfig

Use this to configure custom contract deposits:

typescript
interface DepositContractConfig { /** Custom function ABI JSON string */ functionAbi: string; /** The function name to call */ functionName: string; /** Arguments for the function. Use "{{amount_out}}" as a placeholder for the deposit amount */ functionArgs: string[]; /** Contract address to deposit to */ to: string; /** Optional spender address if different from contract */ spenderAddress?: string; /** Custom action label (e.g., "Stake", "Deposit") */ action?: string;}

ChainConfig

typescript
interface ChainConfig { id: number; // Chain ID name: string; // Display name iconUrl?: string; // Optional icon URL}

Usage examples

tsx
<AnySpendDeposit recipientAddress={walletAddress} destinationTokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" destinationTokenChainId={8453} onSuccess={(amount) => toast.success(`Deposited ${amount}`)}/>

<AnySpendCheckout>

A full-featured checkout component with cart display, order summary, custom forms, shipping selection, discount codes, and multi-payment-method support.

tsx
import { AnySpendCheckout } from "@b3dotfun/sdk/anyspend/react";<AnySpendCheckout recipientAddress="0x..." destinationTokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" destinationTokenChainId={8453} items={[ { name: "Pro Plan", amount: "10000000", quantity: 1 }, ]} organizationName="Acme Inc" onSuccess={(result) => console.log("Paid:", result)}/>;

For full checkout documentation, see the Checkout Guide.

Props

recipientAddressstringrequiredpath

Payment recipient wallet address

destinationTokenAddressstringrequiredpath

Destination token contract address

destinationTokenChainIdnumberrequiredpath

Destination chain ID

itemsCheckoutItem[]requiredpath

Line items to display in the cart

mode'page' | 'embedded'pathdefault: 'page'

Display mode

totalAmountstringpath

Override the computed total (in wei). Useful when the total differs from the sum of item amounts.

organizationNamestringpath

Merchant/organization name displayed in the checkout header

stringpath

URL for the organization logo

themeColorstringpath

Hex color for theming the checkout (e.g., "#6366f1")

buttonTextstringpath

Custom text for the payment button

checkoutSessionIdstringpath

Link this checkout to a checkout session for backend tracking

onSuccess(result: { txHash?: string; orderId?: string }) => voidpath

Called on successful payment

onError(error: Error) => voidpath

Called on payment error

returnUrlstringpath

URL to redirect to after payment

returnLabelstringpath

Label for the return button

defaultPaymentMethodPaymentMethodpath

Which payment method to expand initially

senderAddressstringpath

Pre-fill sender address for token balance display

footerReactNode | nullpath

Custom footer for the order summary. Pass null to hide the default footer.

showPointsbooleanpathdefault: false

Show points earned in the order status summary

showOrderIdbooleanpathdefault: false

Show the order ID in the order status summary

shippingstring | { amount: string; label?: string }path

Shipping cost. String = amount in wei. Object = amount with custom label.

taxstring | { amount: string; label?: string; rate?: string }path

Tax amount. String = amount in wei. Object = amount with custom label and optional rate display.

discountstring | { amount: string; label?: string; code?: string }path

Discount amount (displayed as negative). String = amount in wei. Object = amount with label and optional code.

summaryLinesCheckoutSummaryLine[]path

Additional summary line items (e.g., platform fees, tips, service charges)

formSchemaCheckoutFormSchemapath

JSON schema for collecting customer info. See Checkout Guide.

formComponentReact.ComponentType<CheckoutFormComponentProps>path

Custom React form component. See Checkout Guide.

onFormSubmit(data: Record<string, unknown>) => voidpath

Called when form data changes

shippingOptionsShippingOption[]path

Shipping options displayed as a selector. See Checkout Guide.

Show a shipping address form

onShippingChange(option: ShippingOption) => voidpath

Called when shipping option changes

enableDiscountCodebooleanpath

Show a discount code input

validateDiscount(code: string) => Promise<DiscountResult>path

Async discount code validation function

onDiscountApplied(result: DiscountResult) => voidpath

Called when a discount is applied

classesAnySpendCheckoutClassespath

CSS class overrides. See Customization.

slotsAnySpendSlotspath

Render function overrides. See Customization.

contentAnySpendContentpath

Text/message overrides. See Customization.

themeAnySpendThemepath

Theme configuration. See Customization.

CheckoutItem

typescript
interface CheckoutItem { id?: string; name: string; description?: string; imageUrl?: string; /** Amount in wei (smallest unit of destination token) */ amount: string; quantity: number; /** Custom metadata displayed as label: value pairs */ metadata?: Record<string, string>;}

CheckoutSummaryLine

typescript
interface CheckoutSummaryLine { /** Display label (e.g., "Platform Fee", "Service Charge") */ label: string; /** Amount in token's smallest unit (wei). Negative values shown as deductions. */ amount: string; /** Optional description or note */ description?: string;}

<AnySpendCheckoutTrigger>

Extends AnySpendCheckout with B3 workflow integration. Automatically triggers a workflow on successful payment.

tsx
import { AnySpendCheckoutTrigger } from "@b3dotfun/sdk/anyspend/react";<AnySpendCheckoutTrigger recipientAddress="0x..." destinationTokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" destinationTokenChainId={8453} items={[{ name: "API Credits", amount: "5000000", quantity: 1 }]} workflowId="wf_abc123" orgId="org_xyz" onSuccess={(result) => console.log("Payment & workflow triggered:", result)}/>;

Additional Props (beyond AnySpendCheckout)

workflowIdstringpath

B3 workflow ID to trigger on successful payment

orgIdstringpath

Organization ID that owns the workflow

callbackMetadataobjectpath

Metadata merged into the order for workflow access. The inputs field is accessible via {{root.result.inputs.*}} in workflows.

tsx
<AnySpendCheckoutTrigger recipientAddress="0x..." destinationTokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" destinationTokenChainId={8453} items={[{ name: "Pro Plan - Monthly", amount: "10000000", quantity: 1 }]} workflowId="wf_provision_subscription" orgId="org_acme" callbackMetadata={{ inputs: { plan: "pro", userId: "user_123", email: "user@example.com", }, }} onSuccess={(result) => { console.log("Subscription activated:", result); }}/>

<AnySpendWorkflowTrigger>

A payment component designed specifically for triggering B3 workflows. Requires a fixed payment amount and workflow configuration.

tsx
import { AnySpendWorkflowTrigger } from "@b3dotfun/sdk/anyspend/react";<AnySpendWorkflowTrigger recipientAddress="0x..." chainId={8453} tokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" amount="5000000" workflowId="wf_abc123" orgId="org_xyz" onSuccess={(amount) => console.log("Workflow triggered with:", amount)}/>;

Props

recipientAddressstringrequiredpath

Payment recipient address

chainIdnumberrequiredpath

Destination chain ID

tokenAddressstringrequiredpath

Destination token address

amountstringrequiredpath

Required payment amount in wei

workflowIdstringrequiredpath

B3 workflow ID to trigger

orgIdstringrequiredpath

Organization ID that owns the workflow

callbackMetadataobjectpath

Metadata for workflow access. inputs are accessible via {{root.result.inputs.*}}.

onSuccess(amount: string) => voidpath

Callback when payment succeeds

onClose() => voidpath

Callback when the component is closed

mode'modal' | 'page'path

Display mode

actionLabelstringpath

Custom label for the action button (e.g., "Pay & Activate")

classesAnySpendAllClassespath

CSS class overrides


<QRDeposit>

A QR code-based deposit interface that generates a deposit address for users to send funds to.

tsx
import { QRDeposit } from "@b3dotfun/sdk/anyspend/react";<QRDeposit recipientAddress="0x..." destinationToken={usdcToken} destinationChainId={8453} onSuccess={(txHash) => console.log("Deposit received:", txHash)}/>;

Props

recipientAddressstringrequiredpath

The wallet address to receive the deposit

destinationTokenTokenrequiredpath

The destination token to receive

destinationChainIdnumberrequiredpath

The destination chain ID

mode'modal' | 'page'path

Display mode

sourceTokenTokenpath

Source token to deposit (defaults to ETH on Base)

sourceChainIdnumberpath

Source chain ID (defaults to Base)

creatorAddressstringpath

Creator address for order tracking

depositContractConfigDepositContractConfigpath

Custom contract execution after deposit

onBack() => voidpath

Callback when back button is clicked

onClose() => voidpath

Callback when close button is clicked

onOrderCreated(orderId: string) => voidpath

Callback when the deposit order is created

onSuccess(txHash?: string) => voidpath

Callback when deposit is completed

classesQRDepositClassespath

CSS class overrides


Specialized components

<AnySpendNFTButton>

A streamlined button for NFT purchases with built-in payment handling.

tsx
import { AnySpendNFTButton } from "@b3dotfun/sdk/anyspend/react";<AnySpendNFTButton nftContract={nftContractDetails} recipientAddress="0x..." />;

Props

nftContractNFTContractrequiredpath

NFT contract configuration object

recipientAddressstringrequiredpath

Wallet address to receive the NFT

NFTContract Interface

typescript
interface NFTContract { chainId: number; contractAddress: string; price: string; // Price in wei priceFormatted: string; // Human-readable price currency: { chainId: number; address: string; // 0x0 for native ETH name: string; symbol: string; decimals: number; metadata: { logoURI: string }; }; name: string; description: string; imageUrl: string; tokenId: number | null; // null for ERC721 type: "erc721" | "erc1155";}

<AnySpendCustom>

Flexible component for custom smart contract interactions, including staking, gaming, and DeFi operations.

tsx
import { AnySpendCustom } from "@b3dotfun/sdk/anyspend/react";<AnySpendCustom orderType="custom" dstChainId={8453} dstToken={tokenDetails} dstAmount="1000000000000000000" contractAddress="0x..." encodedData="0x..." onSuccess={(txHash) => console.log("Done:", txHash)}/>;

Props

orderType'custom'requiredpath

Order type identifier

dstChainIdnumberrequiredpath

Target blockchain network

dstTokenTokenrequiredpath

Token used for payment

dstAmountstringrequiredpath

Amount in wei

contractAddressstringrequiredpath

Target smart contract address

encodedDatastringrequiredpath

Encoded function call data

spenderAddressstringpath

Token spender address

metadataobjectpath

Custom metadata for tracking

headerReact.ComponentTypepath

Custom header component

onSuccess(txHash?: string) => voidpath

Success callback


<AnySpendNFT>

Enhanced NFT purchase component with marketplace features.

tsx
<AnySpendNFT nftContract={nftDetails} recipientAddress="0x..." />

<AnySpendStakeB3>

Pre-configured component for B3 token staking.

tsx
<AnySpendStakeB3 recipientAddress="0x..." />

<AnySpendBuySpin>

Gaming-specific component for purchasing spin wheel or lottery entries.

tsx
<AnySpendBuySpin recipientAddress="0x..." />

<AnySpendTournament>

Tournament entry payment component.

tsx
<AnySpendTournament recipientAddress="0x..." />

<AnySpendBondKit>

BondKit integration for bonding curve token purchases.

tsx
<AnySpendBondKit recipientAddress="0x..." />

Providers

<AnyspendProvider>

Required provider that wraps all AnySpend components. Manages query client, Stripe redirect handling, and feature flags.

tsx
import { AnyspendProvider } from "@b3dotfun/sdk/anyspend/react";import { B3Provider } from "@b3dotfun/sdk/global-account/react";import "@b3dotfun/sdk/index.css";function App() { return ( <B3Provider theme="light" environment="production" partnerId="your-partner-id"> <AnyspendProvider> {/* Your app components */} </AnyspendProvider> </B3Provider> );}

Props

childrenReactNoderequiredpath

Child components

featureFlagsFeatureFlagspath

Optional feature flag overrides


Payment method types

typescript
// Crypto payment methodsenum CryptoPaymentMethodType { NONE = "NONE", CONNECT_WALLET = "CONNECT_WALLET", // External EOA wallet (MetaMask, etc.) GLOBAL_WALLET = "GLOBAL_WALLET", // B3 smart wallet TRANSFER_CRYPTO = "TRANSFER_CRYPTO", // Direct crypto transfer}// Fiat payment methodsenum FiatPaymentMethod { NONE = "NONE", COINBASE_PAY = "COINBASE_PAY", // Coinbase onramp STRIPE = "STRIPE", // Stripe redirect flow STRIPE_WEB2 = "STRIPE_WEB2", // Stripe embedded form}

Next steps

Customization

Customize slots, content, theme, and CSS classes

Learn More
Checkout Guide

Build checkout experiences with order summaries

Learn More
Hooks Reference

React hooks for custom payment flows

Learn More