Solana
Pronto para usar isso em produção?
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Solana
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
This page walks through the Solana operations developers reach for first when wiring up TheRPC: reading the current slot and a wallet's SOL balance, inspecting full account state, looking up an address's transaction history and individual transactions, fetching blocks and the latest blockhash, listing and reading SPL token balances, and submitting a signed transaction. Each operation shows the raw JSON-RPC request you'd POST to your Solana endpoint.
Start with two foundational reads. getSlot returns the slot the cluster is currently processing — a quick liveness check and a reference point for time on Solana, where slots tick roughly every 400ms. getBalance returns the SOL balance of any account address. Note that the balance comes back in lamports, the smallest unit; since 1 SOL equals 1,000,000,000 lamports, divide the returned value by 1e9 to convert it to SOL.
To read an account's full state, use getAccountInfo. On Solana every account is owned by a program, so the response gives you the raw data blob, the owner program's public key, the account's lamports balance, and whether it's executable (a program account). For the data field, base58 only works for accounts up to 128 bytes, so for anything larger — most program-owned data accounts — request base64 encoding (or jsonParsed when a parser exists).
Two reads cover transaction history. getSignaturesForAddress returns a paginated list of the signatures that touched a given address, newest first — ideal for building an activity feed or paging back through a wallet's history with before/until. Then getTransaction fetches the full details for a single signature. Solana now uses versioned transactions, so pass maxSupportedTransactionVersion: 0 to getTransaction (and to getBlock); without it, the call errors on any versioned transaction it encounters.
getBlock fetches a confirmed block by its slot number. Full blocks can be large, so trim the response with transactionDetails — "signatures" returns just the signature list, "none" returns block metadata only, and "full" returns everything. Set rewards: false to drop reward data you don't need. When you're about to build and sign a transaction, call getLatestBlockhash to get a recent blockhash and the lastValidBlockHeight after which it expires — both are required to construct a valid transaction.
For SPL tokens, getTokenAccountsByOwner lists the token accounts a wallet holds. Scope the result by passing either a mint (to find the wallet's account for one specific token, like the USDC mint shown here) or a programId (to list all accounts under the SPL Token program). To read a single token account's balance directly, use getTokenAccountBalance. Request jsonParsed encoding to get human-readable amounts back — the response includes uiAmount, the raw amount, and decimals — so you don't have to decode token data yourself.
sendTransaction submits a fully-signed, base64-encoded transaction to the cluster and returns its signature. Important: a returned signature means the transaction was accepted into processing, not that it succeeded or finalized — you must poll getSignatureStatuses (or subscribe with signatureSubscribe) to confirm it reached your target commitment without error. Before spending a real send, run simulateTransaction to dry-run it against the current bank: you'll see the would-be logs and any error without paying fees, which is the cheapest way to catch a broken instruction.
@solana/web3.js Connection for balances, accounts, and sends.solana-py with solders types for the same operations.solana-client crate for native, high-performance access.solana-go) and other language clients.