Solana — Methods (2/4)
API reference for Solana. All methods ->
getSlot
Returns the slot that has reached the given (finalized/confirmed/processed) or default (finalized) commitment level.
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): 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>: the current slot.
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": "getSlot"
}'
Response example
{
"jsonrpc": "2.0",
"result": 374449197,
"id": 1
}
getSlotLeader
Returns the current slot leader.
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>: 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.
minContextSlot(number): sets the minimum slot that the request can be evaluated at.
Returns
<string>: the node identity Pubkey 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",
"id": 1,
"method": "getSlotLeader"
}'
Response example
{
"jsonrpc": "2.0",
"result": "dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS",
"id": 1
}
getSlotLeaders
Returns the slot leaders for a given slot range.
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 start slot, as u64 integer.<u64>: the limit, as a u64 integer (between 1 and 5,000).
Returns
<array[string]>: the node identity public keys as base-58 encoded strings.
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": "getSlotLeaders",
"params": [374449190, 10]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB",
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB",
"dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS",
"dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS",
"dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS",
"dv3qDFk1DTF36Z62bNvrCXe9sKATA6xvVy6A798xxAS",
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB",
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB",
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB",
"dv4ACNkpYPcE3aKmYDqZm9G5EB3J4MRoeE7WNDRBVJB"
]
}
getSupply
Returns information about the current supply.
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>: 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.
excludeNonCirculatingAccountsList(boolean): set totrueto exclude non-circulating accounts list from response.
Returns
The result contains the value object with the following fields:
total(u64): the total supply in lamports.circulating(u64): the circulating supply in lamports.nonCirculating(u64): the non-circulating supply in lamports.nonCirculatingAccounts(array): an array of account addresses of non-circulating accounts, as strings. IfexcludeNonCirculatingAccountsListis enabled, the returned array will be empty.
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": "getSupply"
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374451103
},
"value": {
"circulating": 968499669854531580,
"nonCirculating": 315864946596719089,
"nonCirculatingAccounts": [
"AsrYX4FeLXnZcrjcZmrASY2Eq1jvEeQfwxtNTxS5zojA",
"CY7X5o3Wi2eQhTocLmUS6JSWyx1NinBfW7AXRrkRCpi8",
"CHmdL15akDcJgBkY6BP3hzs98Dqr6wbdDC5p8odvtSbq",
"3fV2GaDKa3pZxyDcpMh5Vrh2FVAMUiWUKbYmnBFv8As3",
"9xbcBZoGYFnfJZe81EDuDYKUm8xGkjzW8z4EgnVhNvsv",
"3vSVZC7LfnnyGuacykWoWrbzrmTyFVSXxCbKJUFbJcKS",
"CuatS6njAcfkFHnvai7zXCs7syA9bykXWsDCJEWfhjHG",
"APnSR52EC1eH676m7qTBHUJ1nrGpHYpV7XKPxgRDD8gX",
"9NFMpkv65d2G7UMMFYHeXrBAaB6rVD3BgQ95bKiwr448",
"4U9iUGSHj1kJa7AefG4UdEPd1xVvMyK3suDhngnvazyf",
"6Uz9bTkdAtmzsDWk3Jso9YzzfYiNpEShBZbxUsvMnRbJ",
"8MrstTxNJpwXSFxn5FGwvre2uCcCaRPs94f2FcknVUyr"
],
"total": 1284364616451250669
}
},
"id": 1
}
getTokenAccountBalance
Returns the token balance of an SPL Token account.
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 pubkey of Token account to query, as base-58 encoded string.<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
The result contains the value object with the following fields:
amount(string): the raw balance without decimals, a string representation of u64.decimals(u8): the number of base 10 digits to the right of the decimal place.uiAmount(number|null): the balance, using mint-prescribed decimals [DEPRECATED].uiAmountString(string): the balance as a string, using mint-prescribed decimals.
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": "getTokenAccountBalance",
"params": ["7nxXxpEEsAFf5CSqapwjBjt65xnQUBAdug2pXS89YzmY"]
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374621302
},
"value": {
"amount": "828545484",
"decimals": 6,
"uiAmount": 828.545484,
"uiAmountString": "828.545484"
}
}
}
getTokenAccountsByDelegate
Returns all SPL Token accounts by approved Delegate.
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 pubkey of account delegate to query, as base-58 encoded string.<object>(required): either:mint(string): the pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; orprogramId(string): the pubkey of the Token program that owns the accounts, 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; optional): limits the returned account data using the providedoffset: <usize>andlength: <usize>fields; only available for "base58", "base64" or "base64+zstd" encodings.minContextSlot(number; optional): sets the minimum slot that the request can be evaluated at.
Returns
The result contains the value object with the following fields:
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(object): the Token state data associated with the account, either as encoded binary data or in JSON format{<program>: <state>}.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
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByDelegate",
"params": [
"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
{
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
},
{
"encoding": "jsonParsed"
}
]
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1114
},
"value": [
{
"account": {
"data": {
"program": "spl-token",
"parsed": {
"info": {
"tokenAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"delegate": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
"delegatedAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"state": "initialized",
"isNative": false,
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
"owner": "CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"
},
"type": "account"
},
"space": 165
},
"executable": false,
"lamports": 1726080,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"rentEpoch": 4
},
"pubkey": "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp"
}
]
},
"id": 1
}
getTokenAccountsByOwner
Returns all SPL Token accounts by token owner.
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 pubkey of account owner to query, as base-58 encoded string.<object>(required): either:mint(string): the pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; orprogramId(string): the pubkey of the Token program that owns the accounts, 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 he 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 contains the value object with the following fields:
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(object): the Token state data associated with the account, either as encoded binary data or in JSON format{<program>: <state>}.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 parameters
curl -X POST https://rpc.ankr.com/solana/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F",
{
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"
},
{
"encoding": "jsonParsed"
}
]
}'
Response parameters
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1114
},
"value": [
{
"account": {
"data": {
"program": "spl-token",
"parsed": {
"accountType": "account",
"info": {
"tokenAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"delegate": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
"delegatedAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"state": "initialized",
"isNative": false,
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
"owner": "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"
},
"type": "account"
},
"space": 165
},
"executable": false,
"lamports": 1726080,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"rentEpoch": 4
},
"pubkey": "C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx"
}
]
},
"id": 1
}