Overview
useChipiSession provides a unified API for managing session keys, enabling gasless transactions without requiring the owner’s signature for each operation.
This hook combines all session-related operations:
- Session creation (local keypair generation)
- Session registration (on-chain)
- Transaction execution (using session key)
- Session revocation (on-chain)
- Status checking (remaining calls, expiration)
Prerequisites
Before usinguseChipiSession, you need:
- A wallet that supports sessions: CHIPI, or SHHH with a STARK / ED25519 signer (check
supportsSession,wallet.supportsSessionKeysorwalletSupportsSessions(wallet)) - The user’s encryption key: a PIN (
encryptKey) or a function that resolves it on demand, such as a passkey (getEncryptKey, 14.14.0+) - An authentication token (from Clerk, Firebase, etc.)
Session Lifecycle
Quick Start
Passkey wallets and server-held sessions (14.14.0+)
For an agent that runs on your server, create the session key there and register it from the browser with the user’s passkey. The session and its spending caps go in one owner-signed transaction, so the user sees one prompt:allowedEntrypoints are converted to selectors. The whole flow, server side included, is in Agent with a session key and a passkey.
Configuration Options
Return Values
Session Data
Actions
Loading States
Persisting Sessions
SessionKeyData contains an encryptedPrivateKey. Where you store it matters — the SDK does not persist sessions itself; this is your responsibility.
Recommended: server-side route + privateMetadata
Persist SessionKeyData from a server route after verifying the user’s auth token. Chipi’s backend SDK ships JWKS verification (iss + aud validation) for Clerk, Firebase, BetterAuth, and generic providers — use it to authenticate the route. See the Gasless setup guides for JWKS configuration.
1. Server route — app/api/chipi/session/route.ts:
Reduce the brute-force surface
Even with server-side storage, the encryption strength ofencryptedPrivateKey depends on the encryption key:
- PIN-only wallets — a 6-digit PIN has ~20 bits of entropy; an attacker who obtains the ciphertext can crack it offline in seconds. Treat the encrypted session key as sensitive even at rest.
- Passkey wallets (recommended) — the encryption key is hardware-backed via WebAuthn PRF and never leaves the device’s secure element. This is the production-grade default. See the PIN → passkey migration guide.
Minimal session whitelist
When registering a session, restrictallowedEntrypoints to the smallest set your flow actually needs. Avoid including broad approval entrypoints (approve, set_approval_for_all) unless required — a session with these permissions can drain tokens within the validity window if compromised.
Executing Transactions
TheexecuteWithSession method accepts an array of Starknet calls:
