Skip to main content

Wormhole Integration

Solana Agent Kit provides comprehensive integration with Wormhole protocol for cross-chain operations, enabling token transfers, USDC transfers via Circle’s CCTP (Cross-Chain Transfer Protocol), and wrapped token creation across multiple blockchains.

Overview

The Wormhole integration enables:
  • Transfer of tokens from Solana to other supported chains
  • USDC transfers via Circle’s CCTP
  • Creation of wrapped token versions on destination chains
  • Querying supported chains and networks

Supported Chains

Wormhole supports multiple blockchains across different networks: Mainnet:
  • Solana
  • Ethereum
  • Avalanche
  • Optimism
  • Arbitrum
  • Base
  • Polygon
  • Sui
  • Aptos
Testnet:
  • Solana
  • Sepolia (Ethereum testnet)
  • Avalanche testnet
  • OptimismSepolia
  • ArbitrumSepolia
  • BaseSepolia
  • Polygon testnet

Prerequisites

To use the Wormhole integration, you need to set up environment variables for the chains you plan to interact with:

Core Functions

Token Transfer

Transfer tokens from Solana to other supported chains:

Token Transfer Parameters

CCTP Transfer

Transfer USDC via Circle’s Cross-Chain Transfer Protocol:

CCTP Transfer Parameters

Create Wrapped Token

Create a wrapped version of a Solana token on another chain:

Wrapped Token Parameters

Get Supported Chains

Retrieve a list of chains supported by Wormhole:

LangChain Tools

The integration provides LangChain tools for AI agent integration:

Token Transfer Tool

CCTP Transfer Tool

Create Wrapped Token Tool

Get Supported Chains Tool

Response Types

Token Transfer Response

CCTP Transfer Response

Create Wrapped Token Response

Implementation Details

Token Transfer Process

  1. Initialize the Wormhole SDK with supported blockchain adapters
  2. Get chain contexts for source (Solana) and destination chains
  3. Create signers for both chains
  4. Determine token decimals and convert amount to base units
  5. Create and send token bridge transfer transaction
  6. Wait for attestation from Wormhole guardians
  7. Complete the transfer on the destination chain

CCTP Transfer Process

  1. Initialize the Wormhole SDK with supported blockchain adapters
  2. Get chain contexts for source (Solana) and destination chains
  3. Create signers for both chains
  4. Parse the transfer amount to correct decimal precision
  5. Create a USDC transfer object with specified parameters
  6. Initiate the transfer on the source chain
  7. Wait for the Circle attestation
  8. Complete the transfer on the destination chain

Wrapped Token Creation Process

  1. Check if the token is already wrapped on the destination chain
  2. If not wrapped, create an attestation on the source chain
  3. Wait for the attestation to be processed by Wormhole guardians
  4. Submit the attestation to the destination chain
  5. Poll for the wrapped token to be available

Error Handling

All functions include comprehensive error handling:

Common Tokens

Common token addresses on Solana:

Advanced Features

Manual vs Automatic Mode

For CCTP transfers, you can choose between manual and automatic mode:

Checking If Token Is Already Wrapped

Before creating a wrapped token, you can check if it already exists:

Utility Functions

Getting Token Decimals

Getting Signers

Troubleshooting

Common Issues

  1. Missing Environment Variables: Ensure all required private keys are set
  2. Insufficient Funds: Make sure your wallet has enough tokens for the transfer
  3. VAA Not Found: Increase timeout for waiting for VAAs
  4. Transaction Failures: Check chain congestion and try again later

Debugging Tips

  1. Enable verbose logging for more detailed information
  2. Check transaction status on blockchain explorers
  3. Verify token addresses and chain identifiers
  4. Test on testnets before using mainnet

Resources