These methods give developers access to account states, balances, token holdings, and program-specific storage. They are used to fetch, inspect, and query information about both native and SPL-token accounts.
getAccountInfo
Returns detailed information about an account given its public key. This method queries the blockchain for the account associated with the provided public key string. It can be used to inspect balances, ownership, and program-related metadata.
Parameters
pubkey_str
: A base-58 encoded string representing the account's public key.config
: Optional configuration that controls encoding, commitment level, data slicing, and other response details.
Returns
A [RpcResponse
] containing an optional [UiAccount
] object if the account exists.
If the account does not exist, the response will contain null
.
Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"9XQeWMPMPXwW1fzLEQeTTrfF5Eb9dj8Qs3tCPoMw3GiE",
{
"encoding": "jsonParsed",
"commitment": "finalized"
}
]
}
Example Response
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 12345678
},
"value": {
"lamports": 10000000,
"data": {
"program": "spl-token",
"parsed": { ... },
"space": 165
},
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"executable": false,
"rentEpoch": 203,
"space": 165
}
},
"id": 1
}
Errors
- Returns an error if the public key is malformed or invalid
- Returns an internal error if the ledger cannot be accessed
See also
- [
UiAccount
]: A readable structure representing on-chain accounts
getTokenSupply
Returns the total supply of a token, given its mint address. This method provides the total circulating supply of a specific token, including the raw amount and human-readable UI-formatted values. It can be useful for tracking token issuance and verifying the supply of a token on-chain.
Parameters
mint_str
: The base-58 encoded string of the mint address for the token.commitment
: Optional commitment configuration to specify the desired confirmation level of the query.
Returns
A [RpcResponse
] containing the total token supply in a [UiTokenAmount
] struct.
If the token does not exist or is invalid, the response will return an error.
Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenSupply",
"params": [
"So11111111111111111111111111111111111111112",
{
"commitment": "confirmed"
}
]
}
Example Response
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 12345678
},
"value": {
"uiAmount": 1000000000.0,
"decimals": 6,
"amount": "1000000000000000",
"uiAmountString": "1000000000.000000"
}
},
"id": 1
}
Errors
- If the mint address is invalid or does not correspond to a token.
- If the token supply cannot be fetched due to network issues or node synchronization problems.
See also
- [
UiTokenAmount
]: Represents the token balance or supply in a user-friendly format.