Skip to main content

SpiceFlowProvider

The root provider that wraps your application. Manages wallet connections, chain configuration, theming, and execution mode.

Usage

import { SpiceFlowProvider } from "@spicenet-io/spiceflow-ui";

<SpiceFlowProvider
  provider="privy"
  network="mainnet"
  nativeChainId={8453}
  theme={{ primaryColor: "#f97316", dark: true }}
>
  {children}
</SpiceFlowProvider>

Props

PropTypeRequiredDefaultDescription
provider"privy" | "dynamic"YesWallet provider to use
childrenReactNodeYesYour application components
network"mainnet" | "testnet"No"testnet"Network environment
nativeChainIdnumberNoDefault chain for the user
brandSpiceBrandNoBranding and theme config (see Styling)
privyAppIdstringIf PrivyPrivy application ID
dynamicEnvironmentIdstringIf DynamicDynamic environment ID
supportedChainIdsnumber[]NoPer networkOverride supported chain IDs
mode"7702" | "presign" | "ondemand"No"7702"Execution mode
appNamestringNo"Spicenet"Your application name
apiUrlstringNoOverride relayer API URL
embeddedWalletConfigobjectNoEmbedded wallet configuration

Examples

<SpiceFlowProvider
  provider="privy"
  network="mainnet"
  nativeChainId={8453}
  theme={{ primaryColor: "#f97316", dark: true }}
>
  {children}
</SpiceFlowProvider>

SpiceDeposit

The main deposit flow. Handles everything: Privy login, external wallet connection, token selection, escrow deposit, 7702 signing, and solver execution. This is the primary component most apps will use.

Usage

import { SpiceDeposit } from "@spicenet-io/spiceflow-ui";

<SpiceDeposit
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  depositBatches={batches}
  styles={{ primaryColor: "#f97316" }}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYesControl modal visibility
onClose() => voidYesClose handler
stylesCustomStylesNoCustom styling
depositBatchesChainBatch[] | ((amount, token) => Promise<ChainBatch[]>)NoDestination chain calls to execute after deposit
allowedTokensstring[]NoFilter token list by symbol (lowercase), e.g. ["usdc", "eth"]
onDepositAmountChange(amount: string) => voidNoFires when user changes the deposit amount
destinationChainIdnumberNoTarget chain for execution
destinationTokenAddressstringNoTarget token on destination chain
onDepositExecute(amount: string) => Promise<void>NoCallback for non 7702 mode (app handles execution)
depositActionLabelstringNoCustom label for the action button
airdropbooleanNofalseShow testnet airdrop button
sponsorGasbooleanNofalseBackend sponsors gas
skipTokenSelectionbooleanNofalseSkip the token selection step
skipRecoverybooleanNofalseSkip the stranded funds recovery prompt
escrowRecoveryEscrowRecoveryNoRecover funds stuck in escrow
onDepositSuccess(detail) => voidNoSuccess callback with tx details

depositBatches

The depositBatches prop defines what happens on the destination chain after the deposit. It can be a static array or an async function that returns batches based on the deposit amount:
// Static batches
const batches = [
  {
    chainId: 8453,
    calls: [
      { to: TOKEN, value: 0n, data: encodeApprove(VAULT, amount) },
      { to: VAULT, value: 0n, data: encodeDeposit(TOKEN, amount) },
    ],
  },
];

// Dynamic batches (computed from deposit amount)
const dynamicBatches = async (amount: string, tokenAddress: string) => {
  const parsedAmount = parseUnits(amount, 6);
  return [
    {
      chainId: 8453,
      calls: [
        { to: tokenAddress, value: 0n, data: encodeApprove(VAULT, parsedAmount) },
        { to: VAULT, value: 0n, data: encodeDeposit(tokenAddress, parsedAmount) },
      ],
    },
  ];
};

SpiceWithdraw

Withdraw assets from the user’s Spice balance back to their wallet. Users select from their deposited tokens and receive the same token on the same chain.

Usage

import { SpiceWithdraw } from "@spicenet-io/spiceflow-ui";

<SpiceWithdraw
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  styles={{ primaryColor: "#f97316" }}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYesControl modal visibility
onClose() => voidYesClose handler
stylesCustomStylesNoCustom styling
onWithdrawExecute(amount: string) => Promise<void>NoCallback for non 7702 mode
withdrawActionLabelstringNoCustom button label
onWithdrawSuccess(data) => voidNoSuccess callback
onWithdrawError(error: string) => voidNoError callback
supportedChainsnumber[]NoFilter to specific chains

SpiceLockModal

Lock tokens for a duration (veToken style). Supports cross chain deposits into the lock. The app provides duration options and the lock batches.

Usage

import { SpiceLockModal } from "@spicenet-io/spiceflow-ui";

<SpiceLockModal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  lockBatches={lockBatches}
  lockTokenSymbol="veREPPO"
  lockChainId={4114}
  sourceChains={[8453, 42161, 4114]}
  durationOptions={[
    { label: "1 Month", months: 1 },
    { label: "3 Months", months: 3 },
    { label: "6 Months", months: 6 },
    { label: "12 Months", months: 12 },
  ]}
  styles={{ primaryColor: "#f97316" }}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYesModal visibility
onClose() => voidYesClose handler
lockBatchesChainBatch[]YesOn chain lock calls
lockTokenSymbolstringYesDisplay symbol for the lock token
lockChainIdnumberYesChain where the lock contract lives
sourceChainsnumber[]YesChains users can deposit from
durationOptionsLockDurationOption[]YesAvailable lock durations
stylesCustomStylesNoCustom styling
darkbooleanNoDark mode override
lockTokenLogoURIstringNoLogo URL for the lock token
votingPowerEstimate(amount, months) => numberNoEstimate voting power from amount and duration
sourceToDestinationConversionRatenumberNoConversion rate display
onLockSuccess(txHash?: string) => voidNoSuccess callback
onAddFunds() => voidNoHandler for “add funds” action
destinationTokenAddressAddressNoTarget token on lock chain

AccountDisplay

A popover that shows the user’s Spice balance breakdown, pending deposits, and quick actions for deposit/withdraw. Great for header navigation.

Usage

import { AccountDisplay } from "@spicenet-io/spiceflow-ui";

<AccountDisplay
  styles={{ primaryColor: "#f97316" }}
  onDepositClick={() => setDepositOpen(true)}
  onWithdrawClick={() => setWithdrawOpen(true)}
/>

Props

PropTypeRequiredDefaultDescription
stylesCustomStylesNoCustom styling
darkbooleanNoDark mode override
appNamestringNo"Spice"Display name
status"active" | "inactive"No"active"Account status indicator
statusLabelstringNoCustom status text
onDepositClick() => voidNoDeposit button handler
onWithdrawClick() => voidNoWithdraw button handler
onDepositSuccess() => voidNoCalled after successful deposit
customSectionsCustomSection[]NoAdd custom sections to the popover
extraAssetsSpiceAsset[]NoAdditional assets to display
tokenPricesRecord<string, number>NoToken price overrides
supportedChainsnumber[]NoFilter chains shown

SpiceBalance

A balance dashboard card that shows the user’s deposited assets. Usually used within a larger page layout rather than as a standalone modal.

Usage

import { SpiceBalance, useSpiceAssets } from "@spicenet-io/spiceflow-ui";

function Dashboard() {
  const { assets, loading } = useSpiceAssets({ address: userAddress });

  return (
    <SpiceBalance
      balanceData={balanceData}
      isLoading={loading}
      onDepositClick={() => setDepositOpen(true)}
      onWithdrawClick={() => setWithdrawOpen(true)}
    />
  );
}

Props

PropTypeRequiredDefaultDescription
balanceDataBalanceDataYesBalance data object
isLoadingbooleanNofalseLoading state
onDepositClick() => voidNoDeposit button handler
onWithdrawClick() => voidNoWithdraw button handler
stylesCustomStylesNoCustom styling
showHeaderbooleanNotrueShow the header
customSectionsBalanceSectionConfig[]NoCustom balance sections

AirdropModal

Request testnet tokens for development and testing.

Usage

import { AirdropModal } from "@spicenet-io/spiceflow-ui";

<AirdropModal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  chainId={5115}
  walletAddress={address}
  airdropTokens={["USDC", "WBTC"]}
  getChainConfig={getChainConfig}
  getSupportedTokens={getSupportedTokens}
/>

ProviderLogin

Wallet connection button that adapts to your selected provider (Privy or Dynamic).

Usage

import { ProviderLogin } from "@spicenet-io/spiceflow-ui";

<ProviderLogin onAuthSuccess={() => console.log("Logged in")} />

Props

PropTypeRequiredDescription
onAuthSuccess() => voidNoCallback after successful authentication
autoTriggerbooleanNoAutomatically trigger login on mount

ExportWalletButton

Lets users export their Privy embedded wallet private key.
import { ExportWalletButton } from "@spicenet-io/spiceflow-ui";

<ExportWalletButton />

Next Steps

Hooks

Build custom UIs with React hooks

Styling

Customize component appearance

Configuration

Configure chains and providers

Examples

See complete examples