Skip to content

v2.23.0

Compare
Choose a tag to compare
@0xFirekeeper 0xFirekeeper released this 23 Jun 21:09
· 2 commits to main since this release
4666962

Session Key Support for EIP-7702 Smart EOAs

Building on the EIP-7702 Account Abstraction and transaction sponsorship introduced in v2.21.0, this release extends Session Key functionality to EIP-7702 Smart EOAs. Session Keys enable granular permission delegation to external wallets for executing transactions on your behalf.

Key Features

  • Permission Delegation: Grant time-limited access to external wallets
  • Granular Controls: Define precise execution permissions per session
  • Smart EOA Integration: Now available for EIP-7702-powered In-App Wallets, inspired by and improved from Smart Wallet session keys
  • Backend Flexibility: Delegate transaction execution to external systems while maintaining control

Usage Example

Create session keys with either full permissions or custom policies:

// Grant full permissions for 24 hours
var sessionKeyReceipt = await smartEoa.CreateSessionKey(
    chainId: chain,
    signerAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    durationInSeconds: 86400,
    grantFullPermissions: true
);

// Grant custom permissions
var sessionKeyReceipt = await smartEoa.CreateSessionKey(
    chainId: chain,
    signerAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    durationInSeconds: 86400,
    grantFullPermissions: false,
    callPolicies: new List<CallSpec>(), // Contract interaction rules
    transferPolicies: new List<TransferSpec>() // Value transfer rules
);

Implementation Workflow

const int chain = 11155111; // 7702-compatible chain

// Initialize EIP-7702 wallet
var smartEoa = await InAppWallet.Create(
    client, 
    authProvider: AuthProvider.Guest, 
    executionMode: ExecutionMode.EIP7702Sponsored
);

// Authenticate and upgrade EOA
if (!await smartEoa.IsConnected())
{
    await smartEoa.LoginWithGuest(defaultSessionIdOverride: Guid.NewGuid().ToString());
}

// Execute upgrade transaction (optional)
var receipt = await smartEoa.Transfer(
    chainId: chain, 
    toAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"), 
    weiAmount: 0
);

// Verify account delegation (optional)
var isDelegated = await Utils.IsDelegatedAccount(client, chain, await smartEoa.GetAddress());

// Create session key
var sessionKeyReceipt = await smartEoa.CreateSessionKey(
    chainId: chain, 
    signerAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    durationInSeconds: 86400,
    grantFullPermissions: true
);

Practical Applications

Once created, these session keys can be used to:

  • Delegate transactions to backend services while maintaining security boundaries
  • Enable temporary access for third-party services
  • Create specialized roles with limited permissions
  • Automate workflows without exposing primary wallet credentials

The session key mechanism opens up numerous possibilities for secure, permissioned delegation patterns while maintaining full control over your assets and contracts.