Logo
New RPC users get 35% off their first monthView the offer
RPC Assistant

How do I connect to the Solana devnet API for testing?

Summary

The Solana devnet is a public test cluster where developers can deploy and test programs, run transactions, and validate client logic without risking real funds. Connecting to a reliable devnet RPC API is the first step for building and debugging Solana applications.

This guide explains how to configure your Solana tooling for devnet, get test SOL from the faucet, and choose an RPC endpoint that matches your development workflow. Whether you are using the Solana CLI, web3.js, or a custom backend, you will find practical setup steps and troubleshooting tips here.

Quick recommendation: which devnet endpoint should you use?

For most development work, the public Solana devnet endpoint https://api.devnet.solana.com is enough to get started. It is operated by the Solana Foundation and is the default for the Solana CLI and web3.js. However, public endpoints can become congested during peak testing periods, and they are shared by many developers. If you are running integration tests, load testing, or a continuous integration pipeline, you may want a more reliable endpoint.

OnFinality provides a managed Solana devnet RPC endpoint that you can use with your existing tools. It is designed for developers who need consistent performance and higher rate limits than typical public endpoints. You can find the endpoint details on the Solana Devnet network page. For production mainnet workloads, see the Solana mainnet RPC options.

Decision guide:

  • Just experimenting? Use the public devnet endpoint or a free tier from a provider.
  • Building a dApp or bot that needs reliable uptime? Consider a managed RPC service like OnFinality to avoid rate limiting and downtime.
  • Running a validator or needing full control? You can run your own devnet node, but that adds operational overhead.

What is the Solana devnet API?

The Solana devnet is a test cluster that mimics the mainnet environment. It runs the same software and uses the same JSON-RPC API, but it uses test tokens (devnet SOL) that have no real value. Developers use the devnet API to:

  • Deploy and test Solana programs (smart contracts)
  • Send transactions and test wallet integrations
  • Validate client-side logic and error handling
  • Run automated tests without spending real SOL

The API is JSON-RPC based, similar to Ethereum's JSON-RPC, but with Solana-specific methods. You can interact with it using the Solana CLI, web3.js, or any HTTP client that can send JSON-RPC requests.

Solana devnet chain settings at a glance

SettingValue
Network nameSolana Devnet
ClusterDevnet
Default RPC URLhttps://api.devnet.solana.com
OnFinality RPC URLSee Solana Devnet network page
WebSocket URLwss://api.devnet.solana.com/
Chain IDNot applicable (Solana uses a different addressing scheme)
Native tokenSOL (devnet)
Token decimals9
Explorerhttps://explorer.solana.com/?cluster=devnet
Faucethttps://faucet.solana.com

Note: Solana does not use chain IDs like EVM chains. Instead, you specify the cluster (devnet, testnet, mainnet-beta) in your configuration.

Setting up your Solana CLI for devnet

If you are using the Solana CLI, you can switch to devnet with a single command:

solana config set --url https://api.devnet.solana.com

To verify the configuration, run:

solana config get

You should see the RPC URL set to the devnet endpoint. Now you can create a wallet and get test SOL:

solana-keygen new --outfile ~/.config/solana/devnet.json
solana config set --keypair ~/.config/solana/devnet.json
solana airdrop 1

The solana airdrop command requests devnet SOL from the faucet. If you need more, you can use the Solana faucet or the solana airdrop command with a larger amount (subject to rate limits).

Connecting with web3.js

For JavaScript developers, the @solana/web3.js library is the standard way to interact with Solana. Here is a basic example of connecting to devnet and checking the balance:

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

// Use the public devnet endpoint or your OnFinality endpoint
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');

// Replace with your devnet wallet address
const address = new PublicKey('YOUR_DEVNET_WALLET_ADDRESS');

const balance = await connection.getBalance(address);
console.log(`Balance: ${balance / LAMPORTS_PER_SOL} SOL`);

If you are using a custom RPC provider, replace the URL with the one provided by OnFinality. For WebSocket support, you can use the wss:// endpoint for subscriptions.

Using the JSON-RPC API directly

You can also interact with the Solana devnet API using raw JSON-RPC requests. This is useful for debugging or for languages without a native SDK. Here is an example using curl to get the latest blockhash:

curl https://api.devnet.solana.com -X POST -H "Content-Type: application/json" -d '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getLatestBlockhash"
  }
'

The response will include a blockhash that you can use to build transactions. For a full list of methods, see the Solana RPC documentation.

Getting test SOL from the devnet faucet

To test transactions, you need devnet SOL. The official faucet is at https://faucet.solana.com. You can request SOL by entering your wallet address. There are also community faucets, but be cautious and only use trusted sources.

If you are using the CLI, the solana airdrop command is convenient, but it has rate limits. For automated testing, consider requesting a larger amount once and reusing the wallet.

Common devnet API issues and how to debug them

Even with a reliable endpoint, you may encounter issues. Here are common problems and their fixes:

SymptomLikely causeFix
429 Too Many RequestsRate limiting on the public endpointUse a managed RPC provider or reduce request frequency
Transaction simulation failedInvalid transaction or insufficient fundsCheck your wallet balance and transaction instructions
Blockhash not foundTransaction is too oldRetry with a fresh blockhash
Connection refusedEndpoint is down or unreachableCheck your network connection and try a different endpoint
UnauthorizedAPI key requiredIf using a private endpoint, ensure your API key is correct

For deeper debugging, you can enable RPC logging in the Solana CLI:

solana config set --url https://api.devnet.solana.com -v

The -v flag enables verbose output, which shows the JSON-RPC requests and responses.

Choosing between public and managed devnet RPC

Public endpoints are free and easy to use, but they have limitations:

  • Rate limits: Public endpoints often limit requests per second, which can break your tests if you make many calls.
  • Uptime: They may go down for maintenance or become overloaded.
  • No support: If you have issues, there is no one to contact.

Managed RPC providers like OnFinality offer:

  • Higher rate limits: Suitable for load testing and CI/CD pipelines.
  • Better uptime: Redundant infrastructure reduces the risk of downtime.
  • Support: You can get help from the provider if you encounter issues.

For production mainnet applications, a managed RPC is almost always recommended. For devnet, it depends on your needs. If you are just learning, the public endpoint is fine. If you are building a serious project, consider a managed service to avoid surprises.

How to switch from devnet to mainnet later

When you are ready to deploy to mainnet, you will need to change your RPC endpoint and use real SOL. The process is similar:

  1. Update your CLI config to point to the mainnet endpoint: solana config set --url https://api.mainnet-beta.solana.com
  2. Update your web3.js connection URL to the mainnet endpoint.
  3. Ensure your wallet has real SOL for transaction fees.

If you are using OnFinality, you can use the same API key for both devnet and mainnet, but you will need to switch the network in your dashboard. See the Solana mainnet network page for details.

Key Takeaways

  • The Solana devnet API is a free test environment that mirrors mainnet functionality.
  • Use the public endpoint https://api.devnet.solana.com for simple tests, but consider a managed RPC for reliable performance.
  • Configure your CLI and web3.js with the devnet URL to start building.
  • Get test SOL from the faucet to fund your transactions.
  • Debug common issues like rate limiting and transaction failures with the tips above.
  • When moving to production, switch to a mainnet endpoint and use real SOL.

Frequently Asked Questions

What is the difference between Solana devnet and testnet?

Solana has multiple test clusters. Devnet is the primary development environment where developers deploy and test programs. Testnet is used for validator testing and network upgrades. Devnet is more stable and is the recommended choice for most developers.

Can I use the same API key for devnet and mainnet?

Yes, with OnFinality you can use the same API key across networks, but you need to specify the network in your request or use the network-specific endpoint. Check the network documentation for details.

How do I get more devnet SOL if the faucet is rate-limited?

You can wait and try again later, or use a different faucet. Some community faucets offer larger amounts, but be cautious about sharing your private key.

Is the devnet API the same as the mainnet API?

Yes, the JSON-RPC methods are identical. The only difference is the network state and the value of the tokens. This makes it easy to switch between devnet and mainnet by changing the endpoint URL.

What are the rate limits for the public devnet endpoint?

The exact limits are not published and can change. If you experience rate limiting, consider using a managed RPC provider like OnFinality, which offers higher limits and better reliability.

For more information on RPC pricing and supported networks, visit the RPC pricing page and the supported networks page.

RPC Knowledge Base

Related RPC details

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started