Basic Transfer with Ed25519 Keys
The simplest way to use Swig is with standard Ed25519 keypairs. Here are the key parts:- Classic
- Kit
transfer-local.ts and transfer-svm.ts for local and LiteSVM environments respectively.
Using Secp256k1 Keys (EVM Compatible)
For EVM compatibility, Swig supports Secp256k1 keys. Note the key differences from the Ed25519 example:- Classic
- Kit
transfer-local-secp.ts and transfer-svm-secp.ts for complete examples.
Using Viem for Ethereum Wallet Integration
For a more complete Ethereum wallet integration using Viem:transfer-svm-viem.ts for the full working code.
Using Sessions for Enhanced Security
Sessions allow limited, temporary authority:Ed25519 Sessions
- Classic
- Kit
Secp256k1 Sessions
- Classic
- Kit
Key aspects of sessions:
- Can be created with any supported authority type (Ed25519, Secp256k1)
- Limited duration specified in slots
- Restricted set of actions (defined by sessionActions)
- Perfect for dApp integrations where temporary access is needed
transfer-local-session.ts(Ed25519)transfer-svm-session.ts(Ed25519)transfer-svm-secp-session.ts(Secp256k1)
Testing Environment Options
These examples can be run in different environments: Local Validator: Use thetransfer-local-* examples
- Requires running a local Solana validator
- Real blockchain environment
- Good for final testing
transfer-svm-* examples
- No validator required
- Instant transaction confirmation
- Perfect for rapid development
- Simulates the Solana runtime
- Change connection URL to
https://api.devnet.solana.com - Real network environment
- Free to use with airdropped SOL

