getAccountInfo - Solana
The getAccountInfo JSON-RPC method retrieves detailed information about a specific account on the Solana blockchain, including its balance, owner, data, and metadata.
The getAccountInfo RPC Solana method returns all metadata associated with an account, such as lamports (balance), owner, data, and rentEpoch.
The getAccountInfo method is an essential part of Solana’s Core API, enabling applications to retrieve detailed information about on-chain accounts. It is crucial for real-time account state analysis, making it valuable for Web3 wallets, decentralized exchanges, and other blockchain-based applications.
Supported Networks
Access this method via Solana API Endpoints:
Mainnet
Devnet
Parameters
Pubkey (string, required): The account’s public key as a base-58 encoded string.
Config (object, optional): Customize the request with the following fields:
commitment (string, optional): Confirmation level: finalized (default), confirmed, or processed.
encoding (string, optional): Data encoding format: base58, base64, base64+zstd, or jsonParsed.
dataSlice (object, optional): Retrieve a subset of account data using offset (starting byte) and length (number of bytes).
minContextSlot (number, optional): The minimum slot at which the account data should be evaluated.
Request
API Endpoints:
Example (cURL) – getAccountInfo example:
Response
A successful response returns account metadata, including balance, owner, and data. If the account doesn’t exist, value is null.
Example Response:
Key Response Fields:
lamports: Balance in lamports.
owner: Program ID owning the account.
data: Encoded account data or parsed JSON (if jsonParsed encoding is used).
executable: Whether the account contains a program.
rentEpoch: Epoch at which rent is due.
space: Size of account data in bytes.
Error Handling
Common getAccountInfo error scenarios include:
Invalid Pubkey format.
Unsupported encoding or dataSlice configuration.
Missing or incorrect API key.
Error Response Example:
Use Case
The getAccountInfo RPC Solana method is ideal for:
Wallets displaying account details and balances.
Explorers analyzing account states and program interactions.
DeFi platforms verifying account ownership and data.
Analytics tools tracking account activity and value changes.
By using jsonParsed encoding, developers simplify parsing program-specific account data, enhancing Web3 integrations.
Code Example (JavaScript) – Web3 getAccountInfo Integration
Integration with Web3
Integrate the getAccountInfo RPC Solana method into Web3 applications to enable real-time account state tracking and analysis. By leveraging Core API parameters like encoding and dataSlice, developers can retrieve precise account data for wallets, dApps, and enterprise solutions.
Last updated