Granular Session Keys via API: Secure Server-Side Automation for User Wallets
FirekeeperWe are excited to announce full support for EIP-7702 Session Keys in the Wallets API. This feature allows you to create secure, scoped permissions for your backend to execute transactions on behalf of your users—without ever taking custody of their main keys.
This is perfect for:
- AI Agents: Allow an agent to trade or interact with contracts within strict limits.
- Automated DeFi: Execute recurring payments or rebalancing without user confirmation for every step.
- Gaming: Perform background actions (like crafting or harvesting) while the user is offline.
How It Works
- Create a Session Key: Your server generates a new "Server Wallet". This wallet will act as the authorized signer grantee.
- Grant Permissions: The user (client-side) signs a transaction authorizing this Session Key. You can restrict it to specific contracts, functions, or spending limits.
- Execute: Your server uses the Session Key to sign and send transactions. The blockchain treats these transactions as if they came from the user's main account.
End-to-End Example
Here is a complete, reproducible example using fetch. We will simulate a full flow: creating a guest user, generating a session key, granting permissions, and executing a transaction.
Prerequisites
- Secret Key: For server-side calls (backend).
- Client ID: For client-side calls (frontend/simulation).
Step 1: Create a Guest User (Client-Side)
First, we simulate a user logging in. We'll use the "guest" auth method to instantly generate a wallet and get an authentication token.
Step 2: Create a Server Wallet (Session Key Target)
Your backend creates a fresh wallet that will act as the session key.
Step 3: User Grants Permission (Client-Side)
The user approves the session key using their auth token.
Step 4: Execute Transaction (Server-Side)
Finally, your server executes a transaction. The server uses the Session Key to sign, but the transaction is executed on the User's account.
Summary
With just three API calls, you've set up a secure, non-custodial automation flow. The user retains full control and can revoke the session key at any time, while your server gets the convenience of programmatic execution.
Try It Yourself
Visit our API reference here.