getAccountInfo - Solana

This method returns the current state of an account, including its lamport balance, owning program, data payload, and rent epoch. This is the primary method for reading on-chain account data such as token mints, PDAs, and program-owned state.

Parameters

ParameterTypeRequiredDescription
pubkeystringYesBase58-encoded Pubkey of the account to query
configobjectNoConfiguration object controlling encoding and commitment

Config Object

FieldTypeRequiredDescription
encodingstringNoData encoding: base58, base64, base64+zstd, or jsonParsed
commitmentstringNoCommitment level: processed, confirmed, or finalized. Defaults to finalized
dataSliceobjectNoByte range to return, with offset and length fields
minContextSlotnumberNoMinimum slot the request can be evaluated at

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getAccountInfo",
    "params": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", {"encoding": "jsonParsed"}],
    "id": "getblock.io"
}'

example.js

javascriptconst { Connection, PublicKey } = require('@solana/web3.js');

const connection = new Connection('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', 'confirmed');

const info = await connection.getParsedAccountInfo(
  new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
);

console.log(info.value);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getAccountInfo',
        'params': ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", {"encoding": "jsonParsed"}],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getAccountInfo",
            "params": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", {"encoding": "jsonParsed"}],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "context": {
            "apiVersion": "2.3.6",
            "slot": 397234561
        },
        "value": {
            "data": {
                "parsed": {
                    "info": {
                        "decimals": 6,
                        "freezeAuthority": "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar",
                        "isInitialized": true,
                        "mintAuthority": "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG",
                        "supply": "8721043118453221"
                    },
                    "type": "mint"
                },
                "program": "spl-token",
                "space": 82
            },
            "executable": false,
            "lamports": 389532986339,
            "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
            "rentEpoch": 18446744073709551615,
            "space": 82
        }
    }
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultobjectRPC response object containing context and the account value

Value Object

FieldTypeDescription
lamportsnumberAccount balance in lamports
ownerstringBase58 Pubkey of the program that owns the account
dataarray|objectAccount data, encoded per the requested encoding
executablebooleanWhether the account holds a loaded program
rentEpochnumberEpoch at which the account next owes rent
spacenumberData length of the account in bytes

Use Cases

  • Token Mint Data: Read decimals, supply, and mint authority from an SPL Token mint
  • PDA State: Fetch program-derived account state for Anchor and native programs
  • Account Existence: Detect whether an associated token account has been initialized
  • Wallet Indexing: Resolve account owner and executable flags when classifying addresses
  • Partial Reads: Use dataSlice to fetch a single struct field from a large account

Error Handling

Error CodeMessageDescription
-32602Invalid paramsMalformed base58 Pubkey, unsupported encoding, or invalid dataSlice range
-32603Internal errorNode failed to read the account from its accounts database
-32016Minimum context slot has not been reachedThe node has not yet processed minContextSlot
-32005Node is unhealthyThe node has fallen behind the cluster tip and cannot serve account state
-32601Method not foundEncoding requested is not supported by the node build