FluxRPC Quickstart: Query Solana in 5 Minutes
Source: Dev.to

You want to read data from Solana. This guide gets you there in 5 minutes.
TL;DR
TypeScript
import { Connection, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
const connection = new Connection('https://eu.fluxrpc.com?key=YOUR_API_KEY', 'confirmed');
const balance = await connection.getBalance(new PublicKey('YOUR_WALLET_ADDRESS'));
console.log(balance / LAMPORTS_PER_SOL, 'SOL');
cURL
curl -s -X POST https://eu.fluxrpc.com?key=YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["YOUR_WALLET_ADDRESS"]}' | jq
Sample output
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 123456789 },
"value": 35737443
},
"id": 1
}
Get your API key → dashboard.fluxbeam.xyz
Prerequisites
- Node.js 18+
- FluxRPC API key (free, takes ~30 seconds to generate)
Step 1 — Get Your API Key
- Go to dashboard.fluxbeam.xyz
- Sign in (Google, GitHub, or Solana wallet)
- Click Create API Key
- Copy the key
Step 2 — Create the Project
mkdir fluxrpc-quickstart && cd fluxrpc-quickstart
npm init -y
npm install @solana/web3.js tsx
Step 3 — Write the Code
Create index.ts:
import { Connection, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
const API_KEY: string = 'your-api-key-here';
const RPC_URL: string = `https://eu.fluxrpc.com?key=${API_KEY}`;
const WALLET: string = 'YOUR_WALLET_ADDRESS';
async function main(): Promise {
const connection = new Connection(RPC_URL, 'confirmed');
const publicKey = new PublicKey(WALLET);
const start = Date.now();
const lamports = await connection.getBalance(publicKey);
const ms = Date.now() - start;
console.log(`Wallet: ${WALLET}`);
console.log(`Balance: ${lamports / LAMPORTS_PER_SOL} SOL`);
console.log(`Latency: ${ms}ms`);
}
main();
Replace your-api-key-here with the key you generated.
Step 4 — Run
npx tsx index.ts
Sample output
Wallet: Wallet Address
Balance: 0.035737443 SOL
Latency: 142ms
You just read from Solana mainnet.
What Just Happened
| Component | Purpose |
|---|---|
| Connection | Opens a connection to FluxRPC. The second argument 'confirmed' sets the commitment level (how finalized the data must be). |
| PublicKey | Parses the wallet address string into a Solana‑compatible format. |
| getBalance | Returns the wallet balance in lamports (1 SOL = 10⁹ lamports). |
This pattern repeats for all RPC calls: connect → query → handle response.
Why FluxRPC?
Fresh Data
Most providers cache responses. FluxRPC returns the latest confirmed (HEAD slot) state—no stale reads.
No Rate Limits
Pay for bandwidth, not request count.
- $0.06 per GB
- A
getBalancecall is ~0.5 KB → 2 million calls ≈ $0.06
Free tier: 10 GB.
Built for Load
Consistent performance even when Solana is congested.
Sub‑Millisecond Latency (Lantern)
Lantern caches account state locally.
- Response time: 0.1–0.25 ms
- Throughput: 10k+ req/sec
More Methods
getLatestBlockhash
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
console.log('Blockhash:', blockhash);
getAccountInfo
import type { AccountInfo } from '@solana/web3.js';
const account: AccountInfo | null = await connection.getAccountInfo(publicKey);
if (account) {
console.log('Owner:', account.owner.toBase58());
console.log('Lamports:', account.lamports);
console.log('Executable:', account.executable);
console.log('Data length:', account.data.length);
}
Reference
Endpoints
| Region | URL |
|---|---|
| EU | https://eu.fluxrpc.com?key=API_KEY |
| US | https://us.fluxrpc.com?key=API_KEY |
Choose the closest region; the wrong region adds ~100 ms latency.
Commitment Levels
| Level | Meaning |
|---|---|
processed | Node has seen it |
confirmed | Supermajority voted |
finalized | Won’t be rolled back |
Common Errors
| Error | Fix |
|---|---|
Invalid public key input | Verify the wallet address is a valid Base58 string |
Failed to fetch | Check API key and endpoint URL |
403 Forbidden | Regenerate API key from the dashboard |
TypeError: fetch failed | Upgrade to Node.js 18+ |
Example error handling
try {
const balance = await connection.getBalance(publicKey);
} catch (error) {
console.error('RPC error:', error);
}
Happy building with FluxRPC!
Exit fullscreen mode
Next Steps
- Transactions — Build and send SOL transfers
- WebSockets — Subscribe to account changes
Docs: fluxrpc.com
