Skip to main content
MoonKey supports all Solana clusters including Mainnet Beta, Devnet, and Testnet. This guide shows you how to configure Solana RPC endpoints and work with different Solana environments in your application.

Solana Clusters

Solana provides three primary clusters for different purposes:

Configuring RPC Endpoints

To configure custom RPC endpoints for Solana embedded wallets, set them in the MoonKeyProvider configuration:
Custom RPC configuration is only required for embedded wallet UIs. If you’re using external Solana wallets (Phantom, Solflare, etc.) without embedded wallet functionality, you don’t need to configure RPCs.

Default Configuration

If you don’t configure custom RPC endpoints, MoonKey uses default Solana cluster endpoints:
  • Mainnet Beta: https://api.mainnet-beta.solana.com
  • Devnet: https://api.devnet.solana.com
  • Testnet: https://api.testnet.solana.com
These default endpoints work for development and moderate usage, but production applications should use dedicated RPC providers.

Custom RPC Providers

For production applications, we strongly recommend using dedicated RPC providers to ensure reliability and performance.

Configuring a Custom Provider

Example using Helius:

Custom SVM Networks

You can interact with custom SVM-compatible networks by creating a Connection instance with the custom RPC URL:

Environment-Based Configuration

Configure different RPC endpoints for different environments:
Environment variables (.env.local):

Working with Different Clusters

Switching Between Clusters

You can work with different clusters by creating separate Connection instances:

Detecting Current Cluster

Determine which cluster a connection is using:

Common Configurations

Development Setup (Devnet)

Production Setup (Mainnet with Helius)

Multi-Cluster Support

Best Practices

Use Dedicated RPCs for Production

  • Default public RPCs have rate limits unsuitable for production
  • Dedicated providers offer better performance and reliability
  • Set up monitoring and alerts for RPC health
  • Have fallback RPCs configured

Secure Your API Keys

Store RPC API keys securely:

Choose the Right Cluster

Monitor RPC Performance

Track key metrics:
  • Request latency
  • Error rates
  • Rate limit usage
  • Websocket connection stability

Use Websockets for Real-Time Data

For real-time updates (account changes, transaction confirmations), use websocket connections:

Troubleshooting

RPC Connection Errors

Problem: Cannot connect to Solana RPC. Solutions:
  • Verify RPC URL is correct and accessible
  • Check API key is valid and not expired
  • Ensure rate limits haven’t been exceeded
  • Try fallback RPC endpoints

Transaction Timeouts

Problem: Transactions time out or fail to confirm. Solutions:
  • Use RPC providers with better uptime (Helius, QuickNode)
  • Increase transaction confirmation timeout
  • Implement retry logic with exponential backoff
  • Check Solana network status for congestion

Websocket Disconnections

Problem: Websocket connections drop frequently. Solutions:
  • Implement reconnection logic
  • Use dedicated RPC providers with stable websockets
  • Monitor connection health and reconnect proactively
  • Consider using polling for less time-sensitive data

Rate Limit Errors

Problem: Hitting RPC rate limits. Solutions:
  • Upgrade to paid RPC provider plan
  • Implement request batching
  • Cache responses when possible
  • Use websockets instead of polling

Testing on Different Networks

Getting Test SOL

For development and testing: Devnet:
Or use the Solana Faucet Testnet:

Network-Specific Testing

Test your application on different networks: