Wormhole Integration
Learn how to use Wormhole for cross-chain operations with Solana Agent Kit
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
Parameter | Type | Description |
---|---|---|
destinationChain | string | Target blockchain (e.g., “Ethereum”, “Avalanche”) |
network | string | ”Mainnet”, “Testnet”, or “Devnet” |
transferAmount | string | Amount to transfer (in human-readable format) |
tokenAddress | string | Address of the token on Solana to transfer |
CCTP Transfer
Transfer USDC via Circle’s Cross-Chain Transfer Protocol:
CCTP Transfer Parameters
Parameter | Type | Description |
---|---|---|
destinationChain | string | Target blockchain (e.g., “Ethereum”, “Base”) |
transferAmount | string | Amount of USDC to transfer |
network | string | ”Mainnet” or “Testnet” (default: “Mainnet”) |
Create Wrapped Token
Create a wrapped version of a Solana token on another chain:
Wrapped Token Parameters
Parameter | Type | Description |
---|---|---|
destinationChain | string | Target blockchain for the wrapped token |
tokenAddress | string | Address of token on Solana to be wrapped |
network | string | ”Mainnet”, “Testnet”, or “Devnet” |
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
- Initialize the Wormhole SDK with supported blockchain adapters
- Get chain contexts for source (Solana) and destination chains
- Create signers for both chains
- Determine token decimals and convert amount to base units
- Create and send token bridge transfer transaction
- Wait for attestation from Wormhole guardians
- Complete the transfer on the destination chain
CCTP Transfer Process
- Initialize the Wormhole SDK with supported blockchain adapters
- Get chain contexts for source (Solana) and destination chains
- Create signers for both chains
- Parse the transfer amount to correct decimal precision
- Create a USDC transfer object with specified parameters
- Initiate the transfer on the source chain
- Wait for the Circle attestation
- Complete the transfer on the destination chain
Wrapped Token Creation Process
- Check if the token is already wrapped on the destination chain
- If not wrapped, create an attestation on the source chain
- Wait for the attestation to be processed by Wormhole guardians
- Submit the attestation to the destination chain
- 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
- Missing Environment Variables: Ensure all required private keys are set
- Insufficient Funds: Make sure your wallet has enough tokens for the transfer
- VAA Not Found: Increase timeout for waiting for VAAs
- Transaction Failures: Check chain congestion and try again later
Debugging Tips
- Enable verbose logging for more detailed information
- Check transaction status on blockchain explorers
- Verify token addresses and chain identifiers
- Test on testnets before using mainnet