Returns all information associated with the account of provided public key.
Parameters
The public key of the account to query (base-58 encoded string)
Configuration object containing the following optional fields:
The level of commitment to use for querying the network:
processed: Latest block (unconfirmed)
confirmed: Confirmed by supermajority
finalized: Finalized by supermajority
Encoding format for the account data:
base58
base64
base64+zstd
jsonParsed (limited to certain account types)
Request a slice of the account’s data:
offset: number - Start position (in bytes)
length: number - Number of bytes to return
The minimum slot that the request can be evaluated at
Response
If the requested account doesn’t exist, returns null. Otherwise, returns an object containing:
The slot the request was processed at
Number of lamports assigned to the account
Base-58 encoded public key of the program that owns this account
Whether this account contains a program
The epoch at which this account will next owe rent
data
[string, string] | object
The account’s data. Format depends on the encoding parameter:
[string, encoding] tuple if encoded as base58/base64
- Parsed JSON object if encoding is “jsonParsed”
The space used by the account’s data
Code Examples
Basic Request
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"encoding": "base58"
}
]
}'
Response
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 430
},
"value": {
"data": ["", "base58"],
"executable": false,
"lamports": 5000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709551615,
"space": 0
}
},
"id": 1
}
Request with Data Slice
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"encoding": "base64",
"dataSlice": {
"offset": 0,
"length": 64
}
}
]
}'
Using web3.js
import { Connection, PublicKey } from '@solana/web3.js';
const connection = new Connection('https://rpc.orbitflare.com');
const publicKey = new PublicKey('vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg');
const accountInfo = await connection.getAccountInfo(
publicKey,
'confirmed'
);
Notes
-
The
jsonParsed encoding is only available for certain account types:
- Stake account
- Token account
- Token mint
- Token metadata
-
When using
dataSlice, the data field will be limited to the requested slice only.
-
The account data may be encoded differently based on the program that owns the account.
Common Errors
| Code | Message | Solution |
|---|
| -32602 | Invalid param: WrongSize | Verify the public key is valid |
| -32602 | Invalid param: not base58 encoded string | Ensure the public key is base58 encoded |
| -32007 | Account not found | The requested account does not exist |