DEV Community

Cover image for FluxRPC Quickstart: Query Solana in 5 Minutes
Shivam Soni
Shivam Soni

Posted on

FluxRPC Quickstart: Query Solana in 5 Minutes

You want to read data from Solana. This guide gets you there in 5 minutes.

What you'll build: A script that queries a wallet balance from Solana mainnet using FluxRPC.


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');
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Output:

{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 123456789 },
    "value": 35737443
  },
  "id": 1
}
Enter fullscreen mode Exit fullscreen mode

Get your API key → dashboard.fluxbeam.xyz


Prerequisites


Step 1 — Get Your API Key

  1. Go to dashboard.fluxbeam.xyz
  2. Sign in (Google, GitHub, or Solana wallet)
  3. Click Create API Key
  4. Copy the key

Step 2 — Create Project

mkdir fluxrpc-quickstart && cd fluxrpc-quickstart
npm init -y
npm install @solana/web3.js tsx
Enter fullscreen mode Exit fullscreen mode

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<void> {
  const connection = new Connection(RPC_URL, 'confirmed');
  const publicKey = new PublicKey(WALLET);

  const start: number = Date.now();
  const lamports: number = await connection.getBalance(publicKey);
  const ms: number = Date.now() - start;

  console.log(`Wallet:  ${WALLET}`);
  console.log(`Balance: ${lamports / LAMPORTS_PER_SOL} SOL`);
  console.log(`Latency: ${ms}ms`);
}

main();
Enter fullscreen mode Exit fullscreen mode

Replace your-api-key-here with your API key.


Step 4 — Run

npx tsx index.ts
Enter fullscreen mode Exit fullscreen mode

Output:

Wallet:  Wallet Address
Balance: 0.035737443 SOL
Latency: 142ms
Enter fullscreen mode Exit fullscreen mode

You just read from Solana mainnet.


What Just Happened

Connection — Opens a connection to FluxRPC. The second param 'confirmed' is the commitment level (how finalized the data needs to be).

PublicKey — Parses the wallet address string into a format Solana understands.

getBalance — Returns the wallet balance in lamports. 1 SOL = 10^9 lamports.

This pattern repeats for all RPC calls: connect → query → handle response.


Why FluxRPC

Fresh Data

Most providers cache responses. FluxRPC returns HEAD slot data, the latest confirmed state. No stale reads.

No Rate Limits

Pay for bandwidth, not requests. $0.06 per GB. That getBalance call? About 0.5KB. 2 million calls = 6 cents.

Free tier: 10GB.

Built for Load

Consistent performance when Solana's congested. No slowdowns during high traffic.

Want Sub-Millisecond?

Lantern caches account state locally. Response times: 0.1–0.25ms. Throughput: 10k+ req/sec.


More Methods

getLatestBlockhash

Required before sending transactions.

const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
console.log('Blockhash:', blockhash);
Enter fullscreen mode Exit fullscreen mode

getAccountInfo

Returns account details, owner, balance, executable flag, data.

import type { AccountInfo } from '@solana/web3.js';

const account: AccountInfo<Uint8Array> | 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);
}
Enter fullscreen mode Exit fullscreen mode

Reference

Endpoints

Region URL
EU https://eu.fluxrpc.com?key=API_KEY
US https://us.fluxrpc.com?key=API_KEY

Choose the closest region. Wrong region adds ~100ms 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 Check wallet address is valid base58
Failed to fetch Verify API key and endpoint URL
403 Forbidden Regenerate API key from dashboard
TypeError: fetch failed Upgrade to Node.js 18+
try {
  const balance = await connection.getBalance(publicKey);
} catch (error) {
  console.error('RPC error:', error);
}
Enter fullscreen mode Exit fullscreen mode

Next Steps

  • Transactions — Build and send SOL transfers
  • WebSockets — Subscribe to account changes

Docs: fluxrpc.com


Stuck? Discord — we respond fast. Twitter

Top comments (0)