Skip to main content

SpiceFlowProvider

The root provider component that wraps your application and manages wallet connections.

Usage

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

<SpiceFlowProvider
  provider="privy"
  privyAppId="your-app-id"
  supportedChainIds={[11155111, 421614]}
>
  {children}
</SpiceFlowProvider>

Props

PropTypeRequiredDefaultDescription
provider'privy' | 'dynamic'Yes-Wallet provider to use
childrenReactNodeYes-Your application components
privyAppIdstringIf using Privy-Privy application ID
dynamicEnvironmentIdstringIf using Dynamic-Dynamic environment ID
supportedChainIdsnumber[]No[11155111, 421614, 5115, 123420001114]Array of supported chain IDs
mode'7702' | 'presign' | 'ondemand'No'7702'Execution mode (see Configuration)
nativeChainIdnumberNo-Native chain ID for non-7702 modes
appNamestringNo'Spicenet'Your application name
embeddedWalletConfigobjectNo-Embedded wallet configuration

Examples

<SpiceFlowProvider
  provider="privy"
  privyAppId="cmebl077a0160l40a7xpxcv84"
  supportedChainIds={[11155111, 421614]}
>
  {children}
</SpiceFlowProvider>

SwapWidget

Pre-built UI component for cross-chain swaps with built-in asset selection, balance display, and transaction execution.

Usage

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

<SwapWidget
  swapBatches={swapBatches}
  supportedChains={[11155111, 421614]}
  tokenAddress="0x0"
  showSlippageSettings={true}
/>

Props

PropTypeRequiredDefaultDescription
swapBatchesChainBatch[]Yes-Array of chain batches for cross-chain execution
supportedChainsnumber[]Yes-Array of supported chain IDs for swap
tokenAddressstringNo'0x0'Token address for the swap (0x0 for native)
theme'light' | 'dark'No'light'Color theme
stylesSwapWidgetStylesNo-Custom styling object
showSlippageSettingsbooleanNotrueShow/hide slippage settings
enableFlipSwapbooleanNotrueEnable asset flipping button
fromInputHookUseFromInputReturnNo-External hook for “from” input control
toInputUpdateHookUseToInputUpdateReturnNo-External hook for “to” input updates

ChainBatch Type

interface ChainBatch {
  chainId: number;
  recentBlock: number | bigint;
  calls: Array<{
    to: string;
    value: string | number | bigint;
    data: string;
  }>;
}

SpiceDeposit

Modal flow for depositing assets into Spicenet. Handles chain selection, wallet connection, and deposit execution.

Usage

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

<SpiceDeposit
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  allowedTokens={["USDC", "ETH"]}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYes-Control modal visibility
onClose() => voidYes-Callback when modal closes
stylesCustomStylesNo-Custom styling
classNamestringNo''Additional CSS class
walletConnectProjectIdstringNo-WalletConnect project ID
postDepositBatchesChainBatch[]No-Batches to execute after deposit
allowedTokensstring[]No-Token symbols allowed for deposit
onDepositAmountChange(amount: string) => voidNo-Callback on amount change
allowSecondAssetbooleanNo-Allow adding a second asset
destinationChainIdnumberNo-Destination chain for non-7702 mode
destinationTokenAddressstringNo-Destination token address
postDepositInstruction(bridgedAmount: string) => Promise<void> | voidNo-Post-deposit callback (e.g., vault deposit)
postDepositInstructionLabelstringNo-Label for post-deposit action
airdropbooleanNofalseShow airdrop button
sponsorGasbooleanNofalseBackend sponsors gas on Pharos

Example

function DepositExample() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Deposit</button>
      <SpiceDeposit
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        allowedTokens={["USDC"]}
        postDepositInstruction={async (amount) => {
          console.log(`Deposited ${amount}`);
        }}
        postDepositInstructionLabel="Deposit to Vault"
      />
    </>
  );
}

SpiceBalance

Balance dashboard component showing user’s deposited assets with deposit/withdraw actions.

Usage

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

function BalanceDashboard() {
  const { balanceData, loading } = useSpiceBalance({ address });

  if (!balanceData) return null;

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

Props

PropTypeRequiredDefaultDescription
balanceDataBalanceDataYes-Balance data object
isLoadingbooleanNofalseShow loading state
stylesanyNo-Custom styling
classNamestringNo''Additional CSS class
showHeaderbooleanNotrueShow header section
onAccountClick(accountId: string) => voidNo-Account item click handler
onDepositClick() => voidNo-Deposit button handler
onWithdrawClick() => voidNo-Withdraw button handler
vaultBalancenumberNo-External vault balance
fetchVaultBalance() => Promise<number>No-Fetch vault balance function
postWithdrawInstruction(amount: string) => Promise<void> | voidNo-Post-withdraw callback
postWithdrawInstructionLabelstringNo-Label for post-withdraw action
destinationChainIdnumberNo-Destination chain for withdrawals
destinationTokenAddressstringNo-Destination token address
customSectionsBalanceSectionConfig[]No-Custom balance sections
showDefaultSectionsbooleanNotrueShow default sections

BalanceData Type

interface BalanceData {
  totalBalance: number;
  percentageChange?: number;
  tradingAccounts: TradingAccount[];
  freeCollateral: number;
  freeCollateralItems?: AccountItem[];
  defiPositions: number;
  defiPositionsItems?: AccountItem[];
  credit: number;
  creditItems?: AccountItem[];
}

SpiceWithdraw

Modal flow for withdrawing assets from Spicenet to external wallets.

Usage

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

<SpiceWithdraw
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYes-Control modal visibility
onClose() => voidYes-Callback when modal closes
stylesCustomStylesNo-Custom styling
classNamestringNo''Additional CSS class
walletConnectProjectIdstringNo-WalletConnect project ID
postWithdrawBatchesChainBatch[]No-Batches to execute after withdraw
postWithdrawInstruction(withdrawnAmount: string) => Promise<void> | voidNo-Post-withdraw callback
postWithdrawInstructionLabelstringNo-Label for post-withdraw action
useInternalWagmibooleanNotrueUse internal Wagmi provider
vaultBalancenumberNo-Available vault balance
fetchVaultBalance() => Promise<number>No-Fetch vault balance function
destinationChainIdnumberNo-Destination chain ID
destinationTokenAddressstringNo-Destination token address

LpModal

Modal for managing liquidity pool positions.

Usage

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

<LpModal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  pairLabel="ETH/USDC"
  pairApr="12.5%"
  pairAddressLabel="0x1234...5678"
  lpLabel="Uniswap V3"
  primaryAsset={primaryAsset}
  onPrimaryAssetChange={handlePrimaryChange}
  availableAssets={assets}
  showSecondaryAsset={false}
  onSubmit={handleSubmit}
/>

Props

PropTypeRequiredDefaultDescription
isOpenbooleanYes-Modal visibility
onClose() => voidYes-Close handler
pairLabelstringYes-Trading pair label (e.g., “ETH/USDC”)
pairAprstringYes-APR display string
pairAddressLabelstringYes-LP address label
lpLabelstringYes-LP provider label
onViewPool() => voidNo-View pool button handler
primaryAssetLpAssetInputYes-Primary asset input state
secondaryAssetLpAssetInputNo-Secondary asset input state
onPrimaryAssetChange(asset: Asset | null, amount: string) => voidYes-Primary asset change handler
onSecondaryAssetChange(asset: Asset | null, amount: string) => voidNo-Secondary asset change handler
availableAssetsAsset[]Yes-Available assets for selection
showSecondaryAssetbooleanYes-Show secondary asset input
onAddSecondaryAsset() => voidNo-Add secondary asset handler
alertVariant'none' | 'crossNetworkAssets' | 'noCollateral'No'none'Alert type to display
crossNetworkCopyCrossNetworkCopyNo-Cross-network alert content
onClickDepositCollateral() => voidNo-Deposit collateral handler
transactionDetailsCollapsedbooleanNotrueTransaction details collapsed
onToggleTransactionDetails() => voidNo-Toggle transaction details
transactionDetailsTransactionDetail[]No-Transaction detail items
isSubmittingbooleanNofalseSubmission in progress
canSubmitbooleanNofalseEnable submit button
onSubmit() => voidYes-Submit handler
stylesCustomStylesNo-Custom styling

ProviderLogin

Wallet connection button that adapts to your selected provider.

Usage

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

<ProviderLogin />

Props

PropTypeRequiredDescription
stylesLoginStylesNoCustom styling for the login button
onAuthSuccess() => voidNoCallback after successful authentication
autoTriggerbooleanNoAutomatically trigger login on mount

Next Steps