Solana — Methods (2/4)
API reference for Solana. All methods ->
getBlockHeight
Returns the current block height of the 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):<object>(optional): 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.
minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
<u64>: a current block height.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlockHeight",
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": 362409082,
"id": 1
}
getBlockProduction
Returns recent block production information from the current or previous 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):<object>(optional): configuration object containing the following optional 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.
range(object): a slot range to return block production for. If parameter not provided, defaults to current epoch:firstSlot(u64): the first slot to return block production information for (inclusive).lastSlot(u64): the last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot.
identity(string): only return results for this validator identity (base-58 encoded).
Returns
value(object): the value containing the following parameters:byIdentity(object): a dictionary of validator identities, as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced.range(object): a block production slot range:firstSlot(u64): the first slot of the block production information (inclusive).lastSlot(u64): the last slot of block production information (inclusive).
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlockProduction",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374432777
},
"value": {
"byIdentity": {
"3zvXem8vqvDYos6BKu66FV84tmDdQwgLxYSempy8tSrs": [
984,
984
],
"4mdQGkbfrFvo5eG722xCXik4hn3xzu2EJD47g7Hd4HfH": [
16,
16
],
"97YUjL2EK42M6jG5VA4fKuVxGXDfxsC5Zawd9haLQJGk": [
200,
200
]
},
"range": {
"firstSlot": 374112000,
"lastSlot": 374432777
}
}
}
}
getBlockCommitment
Returns commitment for particular 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):<u64>(required): the block identified by slot.
Returns
commitment: a commitment, comprising either:null: an unknown block.<array>: a commitment, array of u64 integers logging the amount of cluster stake in lamports that has voted on the block at each depth from 0 toMAX_LOCKOUT_HISTORY+ 1.
totalStake: a total active stake, in lamports, of the current epoch.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlockCommitment",
"params": [5],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"commitment": null,
"totalStake": 157766894165168736
}
}
getBlocks
Returns a list of confirmed blocks between two 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):<u64>:start_slot, as a u64 integer.<u64>:end_slot, as u64 integer (must be no more than 500,000 blocks higher than thestart_slot).<object>: a configuration object containing the following field:commitment(string; default: "finalized"): 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.
Returns
The result field will be an array of u64 integers listing confirmed blocks between start_slot and either end_slot, if provided, or latest confirmed block, inclusive. Max range allowed is 500,000 slots.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlocks",
"params": [374434259, 374434262],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
374434259,
374434260,
374434261,
374434262
]
}
getBlocksWithLimit
Returns a list of confirmed blocks starting at the given slot.
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>:start_slot, as u64 integer.<u64>: limit, as u64 integer (must be no more than 500,000 blocks higher than thestart_slot).<object>(optional): a configuration object containing the following field:commitment(string; default: "finalized"): 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.
Returns
The result field will be an array of u64 integers listing confirmed blocks starting at start_slot for up to limit blocks, inclusive.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlocksWithLimit",
"params": [370778924, 3],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
370779536,
370779537,
370779538
]
}
getBlockTime
Returns the estimated production time of a block.
Each validator reports their UTC time to the ledger on a regular interval by intermittently adding a timestamp to a Vote for a particular block. A requested block's time is calculated from the stake-weighted mean of the Vote timestamps in a set of recent blocks recorded on 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):<u64>: the block identified by slot.
Returns
<i64>: estimated production time, as Unix timestamp (seconds since the Unix epoch).null: the timestamp is not available for this block.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getBlockTime",
"params": [374436187],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": 1744726372,
"id": 1
}
getClusterNodes
Returns information about all the nodes participating in the cluster.
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 field will be an array of JSON objects, each with the following subfields:
pubkey(string): the node public key, as base-58 encoded string.gossip(string|null): a gossip network address for the node.tpu(string|null): a TPU network address for the node.rpc(string|null): a JSON RPC network address for the node, or null if the JSON RPC service is not enabled.version(string|null): the software version of the node, or null if the version information is not available.featureSet(u32|null): the unique identifier of the node's feature set.shredVersion(u16|null): the shred version the node has been configured to use.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getClusterNodes",
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"result": [
{
"featureSet": 3294202862,
"gossip": "63.251.106.87:21810",
"pubkey": "DiwJZxYKQbWBn59EhUhkiB3hM1TLWiQoGvD5mpUHJscu",
"pubsub": "63.251.106.87:21812",
"rpc": "63.251.106.87:21811",
"serveRepair": "63.251.106.87:11812",
"shredVersion": 2405,
"tpu": "63.251.106.87:11803",
"tpuForwards": "63.251.106.87:11804",
"tpuForwardsQuic": "63.251.106.87:11810",
"tpuQuic": "63.251.106.87:11809",
"tpuVote": "63.251.106.87:11805",
"tvu": "63.251.106.87:11801",
"version": "2.2.3"
}
],
"id": 1
}
getEpochInfo
Returns information about 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):<object>(optional): 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.
minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
The result field will be an object with the following fields:
absoluteSlot(u64): the current slot.blockHeight(u64): the current block height.epoch(u64): the current epoch.slotIndex(u64): the current slot relative to the start of the current epoch.slotsInEpoch(u64): the number of slots in this epoch.transactionCount(u64|null) total number of transactions processed without error since genesis.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getEpochInfo",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"absoluteSlot": 374436745,
"blockHeight": 362413120,
"epoch": 866,
"slotIndex": 324745,
"slotsInEpoch": 432000,
"transactionCount": 15534671467
}
}
getEpochSchedule
Returns epoch schedule information from this cluster's genesis config.
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 is an object containing the following parameters:
slotsPerEpoch(u64): the maximum number of slots in each epoch.leaderScheduleSlotOffset(u64): the number of slots before beginning of an epoch to calculate a leader schedule for that epoch.warmup(boolean): whether epochs start short and grow.firstNormalEpoch(u64): the first normal-length epoch, log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH).firstNormalSlot(u64): MINIMUM_SLOTS_PER_EPOCH * (2.pow(firstNormalEpoch) - 1).
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getEpochSchedule",
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"firstNormalEpoch": 0,
"firstNormalSlot": 0,
"leaderScheduleSlotOffset": 432000,
"slotsPerEpoch": 432000,
"warmup": false
}
}
getFeeForMessage
Returns the fee the network will charge for a particular message.
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):message(string, required): a base-64 encoded message.<object>(optional): a configuration object containing the following optional fields:commitment(string): 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
<u64|null>: the fee corresponding to the message at the specified blockhash.
Request example
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "getFeeForMessage",
"params":[
"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",
{
"commitment": "processed"
}
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374437860
},
"value": null
}
}