Solana
Solana
Solana
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
getBalance returns the native SOL balance of a single Solana account, given its base-58 address. The amount comes back in lamports, Solana's smallest unit, where 1 SOL equals 1,000,000,000 lamports. It is the lightest way to check how much SOL a wallet or program account holds without pulling its full data. Call it as a JSON-RPC 2.0 POST with positional params against https://solana.therpc.io/YOUR_API_KEY, and add a commitment of processed, confirmed, or finalized in the optional config to control how settled the read is.
commitment: "confirmed" to detect incoming SOL before crediting a user.| # | Nom | Type | Obligatoire | Description |
|---|---|---|---|---|
| 1 | pubkey | string | Oui | Base-58 account address. |
| 2 | config | object | Non | Options: commitment, minContextSlot. |
| Type | Description |
|---|---|
| object | RpcResponse wrapping a u64 lamport balance. Divide by 1e9 for SOL. |
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | A param is missing, of the wrong type, or malformed (e.g. a non-base58 pubkey or a bad config field). |
-32603 | Internal error | The node hit an internal error serving the request — retry, and reduce the requested range/encoding if it persists. |
{ context, value }; read result.value for the lamport amount, not the bare result object.