Solana — Methods (1/4)
API reference for Solana. All methods ->
getMultipleAccounts
Returns the account information for a list of pubkeys.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<array>: an array of Pubkeys to query, as base-58 encoded strings (up to a maximum of 100).<object>(optional): the configuration object containing the following fields:commitment(string): the commitment describes how finalized a block is at that point in time. When querying the ledger state, it's recommended to use lower levels of commitment to report progress and higher levels to ensure the state will not be rolled back. For processing many dependent transactions in series, it's recommended to use "confirmed" commitment, which balances speed with rollback safety. For total safety, it's recommended to use "finalized" commitment:finalized: the node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.confirmed: the node will query the most recent block that has been voted on by supermajority of the cluster.- it incorporates votes from gossip and replay.
- it does not count votes on descendants of a block, only direct votes on that block.
- this confirmation level also upholds "optimistic confirmation" guarantees in release 1.3 and onwards.
processed: the node will query its most recent block. Note that the block may still be skipped by the cluster.
encoding(string): encoding for Account data, either "base58" (slow), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using Zstandard and base64-encodes the result. "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to "base64" encoding, detectable when thedatafield is typestring.dataSlice(object): limits the returned account data using the providedoffset: <usize>andlength: <usize>fields; only available for "base58", "base64" or "base64+zstd" encodings.minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
The result will be a JSON object with value equal to an array of:
null: if the account at that Pubkey doesn't exist.<object>: otherwise, a JSON object containing:lamports(u64): the number of lamports assigned to this account, as a u64.owner(string): a base-58 encoded Pubkey of the program this account has been assigned to.data([string, encoding]|object): data associated with the account, either as encoded binary data or JSON format{<program>: <state>}, depending on the encoding parameter.executable(boolean): a boolean indicating if the account contains a program (and is strictly read-only).rentEpoch(u64): the epoch at which this account will next owe rent, as u64.
Request example 1
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
],
{
"dataSlice": {
"offset": 0,
"length": 0
}
}
]
}'
Response example 1
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374443766
},
"value": [
{
"data": [
"",
"base64"
],
"executable": false,
"lamports": 88860054690252,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709551615,
"space": 0
},
{
"data": [
"",
"base64"
],
"executable": false,
"lamports": 7998763451,
"owner": "2WRuhE4GJFoE23DYzp2ij6ZnuQ8p9mJeU6gDgfsjR4or",
"rentEpoch": 18446744073709551615,
"space": 0
}
]
}
}
Request example 2
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
],
{
"encoding": "base58"
}
]
}'
Response example 2
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374443852
},
"value": [
{
"data": [
"",
"base58"
],
"executable": false,
"lamports": 88860054690252,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709551615,
"space": 0
},
{
"data": [
"",
"base58"
],
"executable": false,
"lamports": 7998763451,
"owner": "2WRuhE4GJFoE23DYzp2ij6ZnuQ8p9mJeU6gDgfsjR4or",
"rentEpoch": 18446744073709551615,
"space": 0
}
]
}
}
getProgramAccounts
Returns all accounts owned by the provided program Pubkey.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>: the Pubkey of a program, as base-58 encoded string.<object>(optional): the configuration object containing the following fields:commitment(string): the commitment describes how finalized a block is at that point in time. When querying the ledger state, it's recommended to use lower levels of commitment to report progress and higher levels to ensure the state will not be rolled back. For processing many dependent transactions in series, it's recommended to use "confirmed" commitment, which balances speed with rollback safety. For total safety, it's recommended to use "finalized" commitment:finalized: the node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.confirmed: the node will query the most recent block that has been voted on by supermajority of the cluster.- it incorporates votes from gossip and replay.
- it does not count votes on descendants of a block, only direct votes on that block.
- this confirmation level also upholds "optimistic confirmation" guarantees in release 1.3 and onwards.
processed: the node will query its most recent block. Note that the block may still be skipped by the cluster.
encoding(string): encoding for Account data, either "base58" (slow), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using Zstandard and base64-encodes the result. "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to "base64" encoding, detectable when thedatafield is typestring.dataSlice(object): limits the returned account data using the providedoffset: <usize>andlength: <usize>fields; only available for "base58", "base64" or "base64+zstd" encodings.filters(array): filters the results using up to 4 filter objects; the account must meet all the filter criteria to be included in results:memcmp(object): compares a provided series of bytes with program account data at a particular offset. Fields:offset(usize): an offset into program account data to start comparison.bytes(string): the data to match, as encoded string.encoding(string): an encoding for the filter bytes data, either "base58" or "base64". Data is limited in size to 128 or fewer decoded bytes. NEW: This field, and base64 support generally, is only available in solana-core v1.14.0 or newer. Please omit when querying nodes on earlier versions.
dataSize(u64): compares the program account data length with the provided data size
withContext(boolean): wraps the result in a JSON object.minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
By default, the result field will be an array of JSON objects. If withContext flag is set, the array will be wrapped in a JSON object.
pubkey(string): the account Pubkey as base-58 encoded string.account(object): a JSON object, with the following subfields:lamports(u64): the number of lamports assigned to this account, as a u64.owner(string): the base-58 encoded Pubkey of the program this account has been assigned to.data([string,encoding]|object): the data associated with the account, either as encoded binary data or JSON format{<program>: <state>}, depending on encoding parameter.executable(bool): a boolean indicating if the account contains a program (and is strictly read-only).rentEpoch(u64): the epoch at which this account will next owe rent, as a u64.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
{
"encoding": "base64"
}
]
}'
Response example
{
"jsonrpc": "2.0",
"result": [
{
"account": {
"data": [
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"base64"
],
"executable": false,
"lamports": 8017920,
"owner": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
"rentEpoch": 18446744073709551615,
"space": 1024
},
"pubkey": "6uSF3nNb8ZZahnLEgDjXVFWTBeS9WVMh89BiRnJKhCT8"
}
],
"id": 1
}
getRecentPerformanceSamples
Returns a list of recent performance samples, in reverse slot order.
Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):limit(usize; optional): the number of samples to return (max: 720).
Returns
The result object containing the following parameters:
slot(u64): the slot in which sample was taken at.numTransactions(u64): the number of transactions in a sample.numSlots(u64): the number of slots in a sample.samplePeriodSecs(u16): the number of seconds in a sample window.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentPerformanceSamples",
"params": [4]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"numNonVoteTransactions": 4059,
"numSlots": 152,
"numTransactions": 6339,
"samplePeriodSecs": 60,
"slot": 374448056
},
{
"numNonVoteTransactions": 5343,
"numSlots": 150,
"numTransactions": 7592,
"samplePeriodSecs": 60,
"slot": 374447904
},
{
"numNonVoteTransactions": 5971,
"numSlots": 153,
"numTransactions": 8250,
"samplePeriodSecs": 60,
"slot": 374447754
},
{
"numNonVoteTransactions": 6379,
"numSlots": 155,
"numTransactions": 8719,
"samplePeriodSecs": 60,
"slot": 374447601
}
]
}
getSignaturesForAddress
Returns signatures for confirmed transactions that include the given address in their
accountKeyslist.
Returns signatures backwards in time from the provided signature or most recent confirmed block.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(required): the account address as a base-58 encoded string.<object>(optional): the configuration object containing the following fields:limit(number): the maximum transaction signatures to return (between 1 and 1,000, default: 1,000).before(string): starts searching backwards from this transaction signature. If not provided the search starts from the top of the highest max confirmed block.until(string): searches until this transaction signature, if found before limit reached.commitment(string): the commitment describes how finalized a block is at that point in time. When querying the ledger state, it's recommended to use lower levels of commitment to report progress and higher levels to ensure the state will not be rolled back. For processing many dependent transactions in series, it's recommended to use "confirmed" commitment, which balances speed with rollback safety. For total safety, it's recommended to use "finalized" commitment:finalized: the node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.confirmed: the node will query the most recent block that has been voted on by supermajority of the cluster.- it incorporates votes from gossip and replay.
- it does not count votes on descendants of a block, only direct votes on that block.
- this confirmation level also upholds "optimistic confirmation" guarantees in release 1.3 and onwards.
processed: the node will query its most recent block. Note that the block may still be skipped by the cluster.
minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
The result field is an array of transaction signature information, ordered from newest to oldest transaction:
signature(string): the transaction signature as base-58 encoded string.slot(u64): the slot that contains the block with the transaction.err(object|null): Error if transaction failed, null if transaction succeeded. See the TransactionError definitions.memo(string|null): the memo associated with the transaction, null if there is no memo.blockTime(i64|null): estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available.confirmationStatus(string|null): the transaction's cluster confirmation status; either processed, confirmed, or finalized.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getSignaturesForAddress",
"params": [
"Vote111111111111111111111111111111111111111",
{
"limit": 1
}
]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"blockTime": 1744731098,
"confirmationStatus": "finalized",
"err": null,
"memo": null,
"signature": "3wG35yPiT69tZSJRQJ9VTsU9dNR6nd4sQkU7FSyK5cc9Fpt7DXrvYSwbLLBuEo4Sz7DNwSGmTc5bx5mf3MSjZcNN",
"slot": 374448329
}
]
}
getSignatureStatuses
Returns the statuses of a list of signatures.
Unless the searchTransactionHistory configuration parameter is included, this method only searches the recent status cache of signatures, which retains statuses for all active slots plus MAX_RECENT_BLOCKHASHES rooted slots.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<array>: an array of transaction signatures to confirm, as base-58 encoded strings (up to a maximum of 256).<object>(optional): the object containing the following field:searchTransactionHistory(boolean): iftrue, a Solana node will search its ledger cache for any signatures not found in the recent status cache.
Returns
null: an unknown transaction.<object>: a known transaction; contains the following parameters:slot(u64): the slot the transaction was processed at.confirmations(usize|null): the number of blocks since signature confirmation, null if rooted, as well as finalized by a supermajority of the cluster.err(object|null): Error if transaction failed, null if transaction succeeded. See the TransactionError definitions.confirmationStatus(string|null): the transaction's cluster confirmation status; eitherprocessed,confirmed, orfinalized.- [DEPRECATED]
status(object): the transaction status:"Ok": <null>: the transaction was successful."Err": <ERR>: the transaction failed withTransactionError.
Request example 1
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getSignatureStatuses",
"params": [
[
"5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
"5j7s6NiJS3JAkvgkoc18WVAsiSaci2pxB2A6ueCJP4tprA2TFg9wSyTLeYouxPBJEMzJinENTkpA52YStRW5Dia7"
]
]
}'
Response example 1
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374449074
},
"value": [
null,
null
]
}
}
Request example 2
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getSignatureStatuses",
"params": [
[
"5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW"
],
{
"searchTransactionHistory": true
}
]
}'
Response example 2
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374449161
},
"value": [
null
]
}
}