Creating a Basic Session
The simplest way to create a session is with Ed25519 keys. Here are the key parts:Using Session Authority
Once a session is created, you can use it to sign transactions within its duration:Secp256k1 Sessions (EVM Compatible)
For EVM compatibility, you can create sessions with Secp256k1 keys:Revoking Sessions
You can revoke a session by creating a new session with an all-zero session key:Key Aspects of Sessions
Sessions in Swig have several important characteristics:- Temporary Authority: Sessions expire after their specified duration
- Unique Keys: Each session must use a unique key (can’t reuse previous session keys)
- Root Override: The root authority can always override or revoke session permissions
- Inheritance: Sessions inherit permissions from their root role
- Multiple Sessions: You can have multiple active sessions for the same root authority
Testing Environment Options
These examples can be run in different environments:-
Local Validator: Use
transfer-local-session.ts- Requires running a local Solana validator
- Real blockchain environment
- Good for final testing
-
LiteSVM: Use
transfer-svm-session.tsortransfer-svm-secp-session.ts- No validator required
- Instant transaction confirmation
- Perfect for rapid development
- Simulates the Solana runtime
-
Devnet: All examples work with devnet
- Change connection URL to
https://api.devnet.solana.com - Real network environment
- Free to use with airdropped SOL
- Change connection URL to

