Skip to main content
This guide walks through different ways to perform transfers using Swig, progressing from basic to more advanced patterns. You can find all example code in the swig-ts/examples/basic/classic directory or for kit refer to this directory swig-ts/examples/basic/kit.
Examples with svm in the file name use LiteSVM for testing. Those without svm in the file name use a local validator. Which you can run with the bun start-validator command.

Basic Transfer with Ed25519 Keys

The simplest way to use Swig is with standard Ed25519 keypairs. Here are the key parts:
You can find the complete example in 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:
Check out 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:
See transfer-svm-viem.ts for the full working code.

Using Sessions for Enhanced Security

Sessions allow limited, temporary authority:

Ed25519 Sessions

Secp256k1 Sessions


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
You can find complete session examples in (we have just mentioned a few you can find all of them labelled a specific way but it will contain the word “sessions” in the file name):
  • transfer-local-session.ts (Ed25519)
  • transfer-svm-session.ts (Ed25519)
  • transfer-svm-secp-session.ts (Secp256k1)
For more detailed information about sessions, check out the Creating Sessions Guide.

Testing Environment Options

These examples can be run in different environments: Local Validator: Use the transfer-local-* examples
  • Requires running a local Solana validator
  • Real blockchain environment
  • Good for final testing
LiteSVM: Use the transfer-svm-* examples
  • 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
LiteSVM is recommended for initial development as it provides the fastest feedback loop. Move to local validator or devnet for more thorough testing.