Creating a Basic Session
The simplest way to create a session is with Ed25519 keys. Here are the key parts:- Classic
- Kit
Using Session Authority
Once a session is created, you can use it to sign transactions within its duration:- Classic
- Kit
Secp256k1 Sessions (EVM Compatible)
For EVM compatibility, you can create sessions with Secp256k1 keys:- Classic
- Kit
Revoking Sessions
You can revoke a session by creating a new session with an all-zero session key:- Classic
- Kit
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 the examples with ‘local’ in the filename
- Requires running a local Solana validator with
bun start-validator - Real blockchain environment
- Good for final testing
- Requires running a local Solana validator with
-
LiteSVM: Use examples with
svmin the filename- 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
- Classic
- Kit

