Skip to main content
useCalm() reads the active provider’s configuration — destination chain, mode, currency, wallet callbacks, plus the logout and chain setters. It throws when called outside <PrivyCalmProvider> or <WagmiCalmProvider>.

Import

import { useCalm } from "@calm-xyz/react";

Usage

app/page.tsx
"use client";
import { useCalm } from "@calm-xyz/react";

function ChainPicker() {
  const { chain, setChain } = useCalm();
  return (
    <select
      value={chain}
      onChange={(e) => setChain(Number(e.target.value) as 1 | 8453 | 42161 | 999)}
    >
      <option value={1}>Ethereum</option>
      <option value={8453}>Base</option>
      <option value={42161}>Arbitrum</option>
      <option value={999}>HyperEVM</option>
    </select>
  );
}

Return Type

import { type CalmContext } from "@calm-xyz/react";

address

string The wallet address the provider was configured with.

chain

1 | 8453 | 42161 | 999 Destination chain ID for the USDC payout. Initialized from the provider’s initialChain prop (default 999).

setChain

(next: 1 | 8453 | 42161 | 999) => void Switch the destination chain at runtime. Always resets mode to the new chain’s default — "hypercore" on 999, null on every other chain. Call setMode afterwards to keep a non-default mode.

mode

"hyperevm" | "hypercore" | null Hyperliquid execution layer — "hyperevm" (USDC on the rollup) or "hypercore" (USDC delivered to the user’s L1 spot account). Only meaningful when chain === 999. Default "hypercore" on chain 999; null on every other chain.

setMode

(next: "hyperevm" | "hypercore") => void Switch the execution layer at runtime. Throws when called with chain !== 999 — mode only carries meaning on Hyperliquid.

currency

"usd" | "gbp" | "eur" Source fiat currency for the bank-deposit onramp.

sendTransaction

(transaction: SendTransactionInput) => Promise<\0x$`>` Wallet-stack-agnostic single-tx sender installed by the provider. Returns the tx hash.

setSourceChain

(chainId: number) => Promise<void> Asks the connected wallet to switch its active network. Exists so swap transactions can be signed — the wallet must be on the source chain before signing. Distinct from setChain, which updates Calm’s destination chain.

logout

() => Promise<void> Sign the current session out — clears both session cookies and invalidates the cached session so useSession flips back to loading. Best-effort; resolves whether the server call succeeds or not. Call after (or alongside) your own wallet-stack logout.

createSession

() => Promise<SessionResponse> Modality-specific session-creation callback installed by the provider. useSession calls this on a cadence; rarely needs to be called directly.

baseUrl

string The Calm API root (https://api.calmtreasury.xyz by default; the provider’s baseUrl prop overrides).