getAccountInfo
The getAccountInfo method returns detailed information about a specific account on the Solana blockchain. This is one of the most fundamental and frequently used RPC methods in Solana development, as it allows you to retrieve the current state of any account including wallets, program accounts, token accounts, and more.
Accounts are the fundamental data storage units in Solana's account model architecture. Every piece of state on Solana lives in an account, whether it's user wallet balances, token holdings, program data, or any other on-chain information. This method provides access to the account's lamport balance, owner program, executable status, rent epoch, and the raw data stored in the account. Understanding account structure is crucial for Solana development, as programs interact with accounts rather than global state.
When querying account information, you can specify the encoding format for the account data (base58, base64, or jsonParsed for known program types), set a commitment level to determine the finality of the data, and even query historical account states using specific slot numbers or minimum context slots. This flexibility makes getAccountInfo essential for building responsive dApps that need real-time or historical account data.
Parameters
parameter | type | description |
|---|---|---|
accountPubkey | string | Base-58 encoded public key of the account to query |
config | object | Optional configuration object |
config.commitment | string | Level of commitment: 'processed', 'confirmed', or 'finalized' (default: 'finalized') |
config.encoding | string | Encoding for account data: 'base58' (slow), 'base64', 'base64+zstd', or 'jsonParsed' (default: 'base58') |
config.dataSlice | object | Optional. Request a slice of the account's data. Contains 'offset' (integer) and 'length' (integer) |
config.minContextSlot | number | Optional. Minimum slot that the request can be evaluated at |
Return Object
field | type | description |
|---|---|---|
context | object | RPC response context with slot information |
context.slot | number | The slot at which this data was retrieved |
value | object | Account information object, or null if account doesn't exist |
value.lamports | number | Number of lamports assigned to this account (1 SOL = 1,000,000,000 lamports) |
value.owner | string | Base-58 encoded public key of the program this account has been assigned to |
value.data | array|object|string | Account data, encoded in the requested format. Array format: [data, encoding] |
value.executable | boolean | Boolean indicating if the account contains a program and is strictly read-only |
value.rentEpoch | number | The epoch at which this account will next owe rent |
Request Example
Response Example
Tip: Use the jsonParsed encoding for known program types (like SPL Token accounts) to get automatically parsed data structures. For custom programs, use base64 encoding for better performance. The dataSlice option is useful when you only need a portion of large account data.