Logo
新用户订阅 RPC,首月享 6.5 折优惠查看优惠
RPC Assistant

Solana Clusters and Public RPC Endpoints: Which One Should Your App Connect To?

摘要

Solana runs several distinct clusters — mainnet-beta, testnet, and devnet — and each one exposes its own RPC endpoints, genesis hash, and faucet. Picking the wrong cluster is one of the most common reasons a wallet, dApp, or indexer silently fails, so the first step is always to confirm which cluster your code is actually pointed at. This reference walks through the cluster settings, endpoint options, and debugging steps for each environment, and explains when a public endpoint is enough versus when a managed or dedicated RPC service such as OnFinality is the better fit.

Solana is not one network but a set of independent clusters, each with its own ledger, RPC endpoints, and purpose. If you are wiring up a wallet, a dApp, or a backend indexer, the cluster you connect to determines which accounts, programs, and tokens you can actually see. This page covers the cluster settings you need, the public endpoints that are available, and how to decide when a public endpoint stops being the right tool.

Which Solana cluster should you connect to?

The choice comes down to three questions: are you moving real value, are you testing program logic, or are you validating validator/client changes? The table below maps each cluster to its typical use and the practical implications.

ClusterTypical useReal value?FaucetNotes
mainnet-betaProduction apps, wallets, DeFi, NFTsYes (real SOL and tokens)NoThe canonical Solana network users interact with
devnetApplication development, testing, demosNoYesAirdrop SOL freely; resets are possible
testnetValidator and client testing, protocol changesNoYes (limited)Not intended for application development

If your app handles real funds, you belong on mainnet-beta. If you are iterating on program logic or UI flows, devnet is the right sandbox. Testnet is primarily for validator operators and core protocol testing — using it for app development usually leads to confusion because tooling and data assumptions differ from mainnet.

A frequent source of bugs is a mismatch between the cluster your frontend thinks it is using and the cluster your backend or wallet is actually connected to. Always log the genesis hash at startup and compare it against the expected value for the cluster.

Cluster settings at a glance

Each cluster is identified by a genesis hash. Checking this hash is the fastest way to confirm you are on the right network.

Settingmainnet-betadevnettestnet
Genesis hash5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9dEtWTRABZaYq6iMfeYKouRu166VU2xqa14uhcVJyU9pJkvQyS88uRDiswHXSCkY3z
Native tokenSOLSOL (no value)SOL (no value)
FaucetNot availableAvailable via CLI or webLimited
Explorerexplorer.solana.comexplorer.solana.com (devnet)explorer.solana.com (testnet)

You can verify the genesis hash of any endpoint with a single RPC call:

curl -s https://solana.api.onfinality.io/public -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getGenesisHash"}'

The response should match the table above for the cluster you intend to use. If it does not, you are pointed at the wrong environment.

Public RPC endpoints: what they are and when they are enough

A public RPC endpoint is a shared, unauthenticated URL that anyone can call. Solana's official documentation lists public endpoints for each cluster, and many infrastructure providers — including OnFinality — also expose public endpoints for Solana mainnet and devnet. These are convenient for quick tests, tutorials, and low-volume scripts.

Public endpoints typically come with tradeoffs you should plan around:

  • Shared capacity: your requests compete with everyone else's, so latency and throughput can vary.
  • Rate limits: most public endpoints apply some form of request throttling, though the exact policy varies.
  • No SLA: there is usually no commitment to availability or support.
  • Limited method access: some heavy or specialized methods may be restricted.

For a hackathon demo or a local script, a public endpoint is fine. For a production app with real users, you will quickly hit the limits of what a shared public endpoint can offer.

OnFinality provides a public Solana mainnet endpoint at https://solana.api.onfinality.io/public and a matching WebSocket endpoint at wss://solana.api.onfinality.io/public-ws. These are useful for development and light usage; for production workloads you can move to a managed or dedicated plan through RPC pricing.

Connecting a wallet or dApp to a Solana cluster

Most Solana tooling lets you specify the cluster or RPC endpoint directly. In JavaScript, the @solana/web3.js library takes a connection endpoint:

import { Connection, clusterApiUrl } from '@solana/web3.js';

// Public devnet endpoint (for testing)
const devnetConnection = new Connection(clusterApiUrl('devnet'), 'confirmed');

// OnFinality public mainnet endpoint (for light production use)
const mainnetConnection = new Connection('https://solana.api.onfinality.io/public', 'confirmed');

// Always confirm the cluster before sending transactions
const genesisHash = await mainnetConnection.getGenesisHash();
console.log('Connected to genesis hash:', genesisHash);

For wallets that support custom RPC configuration, the settings usually ask for an RPC URL and sometimes a WebSocket URL. Use the mainnet endpoint above for mainnet-beta, and the devnet endpoint from the Solana docs for devnet. Keep the WebSocket URL separate if your app subscribes to account or program changes.

A common pitfall is hardcoding a devnet endpoint in a build that later ships to production. Use environment variables and assert the genesis hash at startup so this fails loudly rather than silently.

Requesting an airdrop on devnet or testnet

Devnet and testnet provide faucets so you can obtain SOL for testing. On devnet, you can request an airdrop via the CLI:

solana airdrop 2 --url https://api.devnet.solana.com

Or programmatically:

const signature = await devnetConnection.requestAirdrop(publicKey, 1_000_000_000); // 1 SOL
await devnetConnection.confirmTransaction(signature);

Faucet limits apply, and devnet may reset, wiping test state. Do not rely on devnet for anything you need to persist. If you need a stable, isolated environment for integration tests, a dedicated node or a managed RPC plan with a private endpoint can give you more predictable behavior than a shared public faucet-backed cluster.

Production readiness checklist

Before you point real users at a Solana endpoint, work through these checks:

  • Cluster confirmed: genesis hash matches the intended cluster at startup and in health checks.
  • Endpoint capacity: the endpoint can handle your expected request rate, including bursts during popular mints or market events.
  • WebSocket support: if you use subscriptions, confirm the endpoint supports wss and that your client reconnects cleanly.
  • Failover: you have at least one backup endpoint and a strategy for switching when the primary degrades.
  • Observability: you log request latency, error rates, and rate-limit responses so you can detect problems before users do.
  • Method coverage: the methods you rely on (for example getProgramAccounts, getSignaturesForAddress, or simulateTransaction) are available and perform acceptably.

If several of these are uncertain on a public endpoint, that is a signal to evaluate a managed or dedicated RPC service. OnFinality offers Solana RPC through its API service and dedicated node options, with endpoints you can test before committing. See the Solana network page for current endpoint details.

Debugging cluster and endpoint problems

When something breaks, the symptom often points to a specific cause. The table below maps common symptoms to likely fixes.

SymptomLikely causeWhat to check
Transactions fail with "blockhash not found"Wrong cluster or stale blockhashConfirm genesis hash; fetch a fresh blockhash before signing
Account data is empty or unexpectedConnected to devnet/testnet instead of mainnet-betaLog the RPC URL and genesis hash at runtime
Airdrop request failsFaucet rate limit or mainnet endpointEnsure you are on devnet/testnet and within faucet limits
WebSocket subscriptions stop firingEndpoint dropped the connection or does not support wssVerify the WebSocket URL and implement reconnect logic
Intermittent 429 responsesPublic endpoint rate limitingReduce request rate, batch calls, or move to a managed endpoint
Slow getProgramAccounts callsLarge account set on a shared endpointUse filters, paginate, or use a dedicated/archive-capable endpoint

A useful first debugging step is to run getGenesisHash and getHealth against the endpoint your app is using. If those succeed but your application still fails, the issue is likely in how the client is configured rather than the endpoint itself.

Moving from a public endpoint to managed or dedicated RPC

Public endpoints are a starting point, not a production strategy. As your app grows, you will want more predictable throughput, clearer limits, and support when something goes wrong. Managed RPC services provide authenticated endpoints with defined capacity, while dedicated nodes give you isolated infrastructure for workloads that need consistent performance or access to heavier methods.

OnFinality provides both managed RPC API access and dedicated node infrastructure across a range of networks, including Solana. You can review supported RPC networks to see what is available, and compare plans on the RPC pricing page. If you are still deciding between providers, the guide on how to choose an RPC provider covers the evaluation criteria in more detail.

When migrating, keep the old endpoint configured as a fallback until you have verified the new one under real traffic. Test WebSocket subscriptions, heavy read methods, and error handling before cutting over.

Key Takeaways

  • Solana has three main clusters: mainnet-beta (production), devnet (app development), and testnet (validator/protocol testing).
  • Each cluster has its own genesis hash; checking it is the fastest way to confirm you are on the right network.
  • Public RPC endpoints are convenient for development and light use but are shared, often rate-limited, and not designed for production traffic.
  • Devnet and testnet provide faucets; mainnet-beta does not.
  • For production apps, evaluate managed or dedicated RPC services such as OnFinality for more predictable capacity and support.
  • Always implement failover, logging, and genesis-hash checks before going live.

Frequently Asked Questions

What is the difference between a Solana cluster and an RPC endpoint?

A cluster is the network itself — a set of validators maintaining a shared ledger (mainnet-beta, devnet, or testnet). An RPC endpoint is the HTTP or WebSocket URL your application uses to talk to a node in that cluster. One cluster can have many endpoints.

Can I use a public RPC endpoint for a production Solana app?

You can start with one, but public endpoints are shared and often rate-limited. For production traffic, a managed or dedicated RPC service gives you more predictable performance and a clearer support path.

How do I know which cluster my app is connected to?

Call getGenesisHash on your endpoint and compare the result to the known genesis hash for mainnet-beta, devnet, or testnet. Log this at startup so mismatches are caught early.

Does OnFinality provide a public Solana RPC endpoint?

Yes. OnFinality exposes a public Solana mainnet endpoint at https://solana.api.onfinality.io/public and a WebSocket endpoint at wss://solana.api.onfinality.io/public-ws. For production workloads, managed and dedicated options are available.

What should I do if my Solana transactions fail with "blockhash not found"?

This usually means you are on the wrong cluster or using a stale blockhash. Confirm your genesis hash, fetch a fresh blockhash immediately before signing, and retry.

Where can I find Solana devnet and testnet endpoints?

Solana's official documentation lists public endpoints for devnet and testnet. OnFinality also offers a Solana Devnet endpoint for development and testing.

RPC 知识库

相关 RPC 内容

网络 RPCPolygon

Polygon MATIC API:开发者应该了解什么?

Polygon MATIC API 是指开发者用于与 Polygon PoS 链交互的一组接口,包括用于读写区块链数据的 JSON-RPC 端点。本指南解释了不同类型的 API——从原始 RPC 到 SDK 和索引器——以及如何为你的应用选择正确的 API。...

网络 RPCpeaq

什么是 peaq 网络 RPC?如何连接?

peaq 网络 RPC 是您的应用程序与 peaq 区块链之间的 API 网关,peaq 是一个兼容 EVM 的 Layer-1,专为 DePIN 和机器经济而设计。本参考涵盖链 ID 3338、PEAQ 代币详情、公共端点、JSON-RPC 测试以及生产前需要关注的提供商标准。 公共 peaq R...

网络 RPCOptimism

Optimism 端点:链设置、连接和调试

Optimism 端点是 JSON-RPC URL,可让您的 dApp 或后端在 OP Mainnet 或 OP Sepolia 上读写数据。本文涵盖确切的链设置、如何通过 curl 或 ethers.js 连接,以及如何调试常见的端点故障。...

RPC 提供商选择Optimism

如何为 Optimism 设置自定义 RPC?

为 Optimism 设置自定义 RPC 意味着将你的钱包或 dApp 配置为使用特定的端点,而不是默认的公共端点。本指南涵盖了你需要的链设置、如何将 Optimism 添加到 MetaMask,以及如何为生产环境选择可靠的 RPC 提供商。...

RPC 提供商选择Solana

是什么让 Solana RPC 变快,以及如何为你的应用选择最快的 RPC?

Solana 的性能要求低延迟的 RPC 基础设施。最适合你的用例的最快 RPC 取决于工作负载类型、地理邻近性以及你是否需要共享或专用资源。本文解释了影响 Solana RPC 速度的关键因素以及如何评估提供商。...

RPC 提供商选择Ethereum

2025年最佳以太坊RPC性能监控服务

以太坊RPC端点的性能监控意味着跟踪延迟、错误率、吞吐量以及随时间变化的方法级行为。本文解释了要测量什么、如何构建监控探针,以及如何评估RPC提供商的可观测性,包括OnFinality的以太坊RPC服务。...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始