Skip to main content
Session keys only work with CHIPI wallets - not READY wallets. Make sure your wallet was created with walletType: "CHIPI".

Usage

Parameters

ParameterTypeRequiredDescription
encryptKeystringYesUser’s PIN/password to encrypt the session private key
durationSecondsnumberNoSession duration in seconds (default: 21600 = 6 hours)

Return Value

Returns an object containing:
PropertyTypeDescription
createSessionKeyfunctionTrigger session key generation (fire-and-forget)
createSessionKeyAsyncfunctionTrigger session key generation (returns Promise)
dataSessionKeyDataGenerated session key data
isLoadingbooleanWhether generation is in progress
isErrorbooleanWhether an error occurred
errorError | nullError details if any
isSuccessbooleanWhether generation succeeded
resetfunctionReset mutation state

SessionKeyData Structure

Example Implementation

Security Considerations

Never store session keys in your backend database. This defeats the purpose of self-custodial security. Store only in client-side secure storage.
PlatformRecommended Storage
WeblocalStorage or sessionStorage
iOSSecure Enclave / Keychain
AndroidAndroid Keystore
React Nativeexpo-secure-store or react-native-keychain

Best Practices

  1. Set short durations - Use 1-6 hours, not days
  2. Clear on logout - Always remove session from storage when user logs out
  3. Register on-chain - After creating, use useAddSessionKeyToContract to register it
This hook only generates the session keypair locally. You must call useAddSessionKeyToContract to register it on-chain before it can be used for transactions.