in-solana by Supanode

getAccountInfo — Solana RPC Method

getAccountInfo returns the lamport balance, owner program, data contents, and executable flag for any Solana account identified by its public key.

Parameters

NameTypeRequiredDescription
pubkeystringYesBase-58 encoded public key of the account.
commitmentstringNoprocessed, confirmed, or finalized. Default: finalized.
encodingstringNobase58, base64, base64+zstd, jsonParsed. Default: base64.
dataSliceobjectNo{offset: usize, length: usize} — byte range to return. Not available with jsonParsed.
minContextSlotnumberNoMinimum slot at which the request can be evaluated.

Request

curl -X POST https://api.mainnet-beta.solana.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
      "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
      {"encoding": "base64"}
    ]
  }'

TypeScript (@solana/kit)

import { createSolanaRpc, address } from "@solana/kit";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const account = await rpc
  .getAccountInfo(address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"), {
    encoding: "base64",
  })
  .send();

Response

{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 341197000, "apiVersion": "2.2.4" },
    "value": {
      "data": ["base64-encoded-bytes", "base64"],
      "executable": false,
      "lamports": 1000000000,
      "owner": "11111111111111111111111111111111",
      "rentEpoch": 18446744073709551615,
      "space": 0
    }
  },
  "id": 1
}
FieldTypeDescription
datastring or array or objectAccount data. Format depends on encoding. With jsonParsed, returns {program, parsed, space}.
executableboolWhether the account contains a program.
lamportsu64Balance in lamports (1 SOL = 1,000,000,000 lamports).
ownerstringBase-58 public key of the program that owns this account.
rentEpochu64Epoch at which the account will next owe rent. u64::MAX means rent-exempt.
spaceu64Account data size in bytes.

When the account does not exist, value is null.

Encoding options

  • base64 (recommended): fast, compact, works for any account.
  • base64+zstd: Zstandard-compressed base64. Useful for large accounts.
  • base58: slow for large data. Avoid for accounts over 128 bytes.
  • jsonParsed: returns structured data for known programs (SPL Token, System Program, Stake, Vote). Falls back to base64 when no parser is available.

Common errors

  • Account not found — value returns null. The account either does not exist or was garbage-collected after its lamports dropped to zero.
  • Encoding mismatch — requesting dataSlice with jsonParsed encoding returns an error.

Performance

getAccountInfo is a lightweight method. Most RPC providers cache recent results. For fetching multiple accounts in one call, use getMultipleAccounts to reduce round trips. A single getMultipleAccounts call can return up to 100 accounts.

FAQ

What encoding should I use? Use base64 for raw data. Use jsonParsed when you need structured output for SPL Token accounts, Stake accounts, or Vote accounts. Avoid base58 for accounts with more than 128 bytes of data — it is significantly slower.

Does getAccountInfo return historical data? No. It always returns the current account state at the selected commitment level. For historical account state, use a snapshot service or an indexer.

What happens when the account does not exist? The value field is null. The context field still contains the slot the node evaluated.

What is the dataSlice parameter for? dataSlice lets you fetch a byte range instead of the full account data. This is useful when you only need a specific field from a known account layout, reducing bandwidth and response time.

Can I use getAccountInfo with Token accounts? Yes. Set encoding to jsonParsed and the response includes the parsed token balance, mint, owner, and delegate fields for SPL Token and Token-2022 accounts.

Parameters

ParameterTypeRequiredDescriptionDefault
pubkeystringYesBase-58 encoded public key of the account to query.—
commitmentstringNoCommitment level: processed, confirmed, or finalized.finalized
encodingstringNoData encoding: base58, base64, base64+zstd, jsonParsed.base64
dataSliceobjectNoLimit returned data with offset and length (bytes). Not available with jsonParsed.—
minContextSlotnumberNoMinimum slot at which the request can be evaluated.—

Updated: