What are Session Keys?
Session keys allow your application to execute transactions on behalf of a user without requiring their owner private key for every action. Instead, a temporary keypair is created and registered on-chain with specific permissions (time limit, call limit, allowed functions). This enables gasless, frictionless UX for gaming, DeFi automation, social apps, and more.Session keys only work with CHIPI wallets - OpenZeppelin accounts extended with SNIP-9 session key support.
When to Use Session Keys
Requirements
- A CHIPI wallet (not READY)
- Valid bearer token from your auth provider
- User’s
encryptKey(PIN) for signing
Create a Session Key
Generate a session keypair locally. The SDK returns the data but does NOT store it - you must persist it on the client side.
Never store session keys in your backend database. Store only in client-side secure storage (localStorage, Secure Enclave, Keychain).
Register Session On-Chain
Before using a session key, you must register it on the CHIPI wallet smart contract. This requires the owner’s signature (one-time setup).
Session Configuration Options
Execute Transactions with Session
Now you can execute transactions using the session key - no owner private key needed!
Signature Format Difference:
- Owner signature:
[r, s](2 elements) - Session signature:
[sessionPubKey, r, s, validUntil](4 elements)
Security and Best Practices
Storage Guidelines
Never store session keys in your backend database. This defeats the purpose of self-custodial security.
Lifecycle Best Practices
- Always revoke on logout - Never leave active sessions when user signs out
- Set short durations - Use 1-6 hours, not days
- Limit
maxCalls- Set realistic limits based on expected usage - Whitelist entrypoints - Restrict to only the functions your app needs
Example: Secure Logout Handler
Example: Session with Restricted Permissions
Full Example: Gaming Session
Next Steps
- Session Methods Reference - Detailed API for each session method
- CHIPI Wallet Smart Contract - Cairo implementation details
- Transfer Tokens - Basic token transfers
