Solana — Methods (3/4)
API reference for Solana. All methods ->
getFirstAvailableBlock
Returns the slot of the lowest confirmed block that has not been purged from the ledger.
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): None.
Returns
<u64>: a slot.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getFirstAvailableBlock",
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": 370779475,
"id": 1
}
getGenesisHash
Returns the genesis hash.
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): None.
Returns
<string>: the hash as base-58 encoded string.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getGenesisHash",
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG",
"id": 1
}
getHealth
Returns the current health of the node.
If one or more --known-validator arguments are provided to solana-validator, "ok" is returned when the node has within HEALTH_CHECK_SLOT_DISTANCE slots of the highest known validator, otherwise an error is returned. "ok" is always returned if no known validators are provided.
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): None.
Returns
If the node is healthy: "ok" If the node is unhealthy, a JSON RPC error response is returned. The specifics of the error response are UNSTABLE and may change in the future.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getHealth",
"id": 1
}'
Response example (healthy)
{
"jsonrpc": "2.0",
"result": "ok",
"id": 1
}
Response example (unhealthy)
{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "Node is unhealthy",
"data": {}
},
"id": 1
}
Response example (unhealthy; additional info)
{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "Node is behind by 42 slots",
"data": {
"numSlotsBehind": 42
}
},
"id": 1
}
getHighestSnapshotSlot
NEW: This method is only available in solana-core v1.9 or newer. Please use getSnapshotSlot for solana-core v1.8
Returns the highest slot information that the node has snapshots for.
This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.
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): None.
Returns
<object>:full(u64): the highest full snapshot slot.incremental(u64|undefined): the highest incremental snapshot slot based onfull.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getHighestSnapshotSlot",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"full": 374423617,
"incremental": 374438029
}
}
Response example (no snapshot)
{
"jsonrpc": "2.0",
"error": {
"code": -32008,
"message": "No snapshot"
},
"id": 1
}
getIdentity
Returns the identity pubkey for the current node.
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): None.
Returns
The result parameter containing the following field:
identity(base-58 encoded string): the identity pubkey of the current node.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getIdentity",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"identity": "6ZaNrpjNZMmtAaZ4Tjj7GhmgbqpRR9vnipoCgwqjCHR5"
}
}
getInflationGovernor
Returns the current inflation governor.
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):<object>(optional): the configuration object containing the following field: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.
Returns
initial(f64): the initial inflation percentage from time 0.terminal(f64): the terminal inflation percentage.taper(f64): the rate per year at which inflation is lowered. Rate reduction is derived using the target slot time in genesis config.foundation(f64): the percentage of total inflation allocated to the foundation.foundationTerm(f64): the duration of foundation pool inflation in years.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getInflationGovernor",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"foundation": 0.0,
"foundationTerm": 0.0,
"initial": 0.08,
"taper": 0.15,
"terminal": 0.015
}
}
getInflationRate
Returns the specific inflation values for the current epoch.
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): None.
Returns
total(f64): the total inflation.validator(f64): the inflation allocated to validators.foundation(f64): the inflation allocated to the foundation.epoch(u64): the epoch for which these values are valid.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getInflationRate",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"epoch": 866,
"foundation": 0.0,
"total": 0.03846001179398413,
"validator": 0.03846001179398413
}
}
getInflationReward
Returns the inflation / staking reward for a list of addresses for an epoch.
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 addresses to query, as base-58 encoded strings:<object>(optional): the configuration object containing the following fields:- commitment (string; optional): 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.
epoch(u64; optional): an epoch for which the reward occurs. If omitted, the previous epoch will be used.minContextSlot(number): sets the minimum slot that the request can be evaluated at.
- commitment (string; optional): 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:
Returns
epoch(u64): the epoch for which reward occurred.effectiveSlot(u64): the slot in which the rewards are effectiveamount(u64): the reward amount in lamports.postBalance(u64): the post balance of the account in lamports.commission(u8|undefined): the vote account commission when the reward was credited.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getInflationReward",
"params": [["vgcDar2pryHvMgPkKaZfh8pQy4BJxv7SpwUG7zinWjG"], {"epoch": 865}],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"amount": 62104278891217,
"commission": 95,
"effectiveSlot": 374112000,
"epoch": 865,
"postBalance": 10748380652807189
}
]
}
getLargestAccounts
Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours).
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):<object>(optional): the configuration object containing the following optional fields:- commitment (string; optional): 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.
filter(string; optional): filters results by account type; currently supported:circulating|nonCirculating.
- commitment (string; optional): 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:
Returns
The result will be a JSON object with value equal to an array of:
<object>: a JSON object containing the following fields:address(string): the base-58 encoded address of the account.lamports(u64): the number of lamports in the account, 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",
"method": "getLargestAccounts",
"params": [
{ "filter": "nonCirculating" }
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": [
{
"lamports": 999999990000000000,
"address": "11111111111111111111111111111111"
},
{
"lamports": 854321560000000000,
"address": "SysvarC1ock11111111111111111111111111111111"
},
{
"lamports": 732000000000000000,
"address": "Stake11111111111111111111111111111111111111"
},
{
"lamports": 690000000000000000,
"address": "Vote111111111111111111111111111111111111111"
},
{
"lamports": 540000000000000000,
"address": "NativeLoader1111111111111111111111111111111"
},
{
"lamports": 500000000000000000,
"address": "Config1111111111111111111111111111111111111"
}
],
"id": 1
}
getLatestBlockhash
NEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8
Returns the latest blockhash.
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):<object>(optional): the configuration object containing the following fields:commitment(string; optional): used for retrieving blockhash); 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; optional): sets the minimum slot that the request can be evaluated at.
Returns
<object>: a JSON object with value field set to a JSON object including:blockhash(string): a hash as base-58 encoded string.lastValidBlockHeight(u64): the last block height at which the blockhash will be valid.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getLatestBlockhash",
"params": [
{
"commitment": "processed"
}
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374442143
},
"value": {
"blockhash": "5SVbJEwUwvS2PmGSMKcshCanrCnYcDBEpCp3aR7up6GV",
"lastValidBlockHeight": 362418664
}
}
}
getLeaderSchedule
Returns the leader schedule for an epoch.
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):<u64>(optional): fetches the leader schedule for the epoch that corresponds to the provided slot. If unspecified, fetches the leader schedule for the current epoch.<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.
identity(string): returns only the results for this validator identity (base-58 encoded).
Returns
null: if requested epoch is not found.<object>: otherwise, the result field will be a dictionary of validator identities, as base-58 encoded strings, and their corresponding leader slot indices as values (indices are relative to the first slot in the requested epoch).
Request example 1
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getLeaderSchedule",
"params": [374442395],
"id": 1
}'
Response example 1
{
"jsonrpc": "2.0",
"result": {
"3zvXem8vqvDYos6BKu66FV84tmDdQwgLxYSempy8tSrs": [
2576,
2577,
2578,
2579,
3448,
3449,
3450
]
},
"id": 1
}
Request example 2
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getLeaderSchedule",
"params": [
null,
{
"identity": "dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS"
}
],
"id": 1
}'
Response example 2
{
"jsonrpc": "2.0",
"result": {
"dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS": [
12,
13,
14,
15,
32,
33,
34,
35,
44,
45,
46,
47
]
},
"id": 1
}
getMaxRetransmitSlot
Returns the max slot seen from retransmit stage.
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): None.
Returns
<u64>: the slot.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getMaxRetransmitSlot",
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": 374443337,
"id": 1
}