For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Solana — Methods (3/4)

API reference for Solana. All methods ->

Part 3 of 4: 1 · 2 · 3 · 4

getTokenLargestAccounts

Returns the 20 largest accounts of a particular SPL Token type.

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 Mint 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:

  • address (string): the address of the token account.
  • amount (string): the raw token account 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 token account balance, using mint-prescribed decimals [DEPRECATED].
  • uiAmountString (string): the token account 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": "getTokenLargestAccounts",
"params": ["So11111111111111111111111111111111111111112"]
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374624734
},
"value": [
{
"address": "35akt5uJn73ZN9FkGgBKpRwbW5scoqV7M1N59cwb4TKV",
"amount": "11109337918819635",
"decimals": 9,
"uiAmount": 11109337.918819636,
"uiAmountString": "11109337.918819635"
},
{
"address": "2ceB4kejtRYjPi2tC6KP9pvmRfcEtrukPT18rWV4yejb",
"amount": "1003836020391687",
"decimals": 9,
"uiAmount": 1003836.020391687,
"uiAmountString": "1003836.020391687"
}
]
},
"id": 1
}

getTokenSupply

Returns the total supply of an SPL Token type.

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 Mint 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 total token supply 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 total token supply, using mint-prescribed decimals [DEPRECATED].
  • uiAmountString (string): the total token supply 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": "getTokenSupply",
"params": ["So11111111111111111111111111111111111111112"]
}'

Response example

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 374624888
},
"value": {
"amount": "0",
"decimals": 9,
"uiAmount": 0.0,
"uiAmountString": "0"
}
}
}

getTransaction

Returns transaction details for a confirmed transaction.

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 transaction signature as base-58 encoded string.
    • <object> (optional): the configuration object containing the following optional fields:
      • encoding (string): encoding for each returned Transaction, either "json", "jsonParsed", "base58" (slow), "base64". If parameter not provided, the default encoding is "json". "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the transaction.message.instructions list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (accounts, data, and programIdIndex fields).
      • 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.
      • maxSupportedTransactionVersion (number): sets the max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned. If this parameter is omitted, only legacy transactions will be returned, and any versioned transaction will prompt the error.

Returns


  • null: if transaction is not found or not confirmed.
  • <object>: if transaction is confirmed, an object with the following fields:
    • slot (u64): the slot this transaction was processed in.
    • transaction (object|[string,encoding]): a transaction object, either in JSON format or encoded binary data, depending on encoding parameter.
    • blockTime (i64|null): the estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available.
    • meta (object|null): the transaction status metadata object:
      • err (object|null): Error if transaction failed, null if transaction succeeded. See the TransactionError definitions.
      • fee (u64): the fee this transaction was charged, as u64 integer.
      • preBalances (array): an array of u64 account balances from before the transaction was processed.
      • postBalances (array): an array of u64 account balances after the transaction was processed.
      • innerInstructions (array|null): the list of inner instructions or null if inner instruction recording was not enabled during this transaction.
      • preTokenBalances (array|undefined): the list of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction.
      • postTokenBalances (array|undefined): the list of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction.
      • logMessages (array|null): an array of string log messages or null if log message recording was not enabled during this transaction.
      • [DEPRECATED] status: <object>: the transaction status:
        • "Ok": <null>: the transaction was successful.
        • "Err": <ERR>: the transaction failed with TransactionError.
      • rewards (array|null): the transaction-level rewards, populated if rewards are requested; an array of JSON objects containing:
        • pubkey (string): the public key, as base-58 encoded string, of the account that received the reward.
        • lamports (i64): the number of reward lamports credited or debited by the account, as a i64.
        • postBalance (u64): the account balance in lamports after the reward was applied.
        • rewardType (string): the type of reward: currently only "rent", other types may be added in the future.
        • commission (u8|undefined): a vote account commission when the reward was credited, only present for voting and staking rewards.
      • loadedAddresses (object|undefined): the transaction addresses loaded from address lookup tables. Undefined if maxSupportedTransactionVersion is not set in request params.
        • writable (array[string]): the ordered list of base-58 encoded addresses for writable loaded accounts.
        • readonly (array[string]): the ordered list of base-58 encoded addresses for readonly loaded accounts.
      • returnData (object|undefined): the most-recent return data generated by an instruction in the transaction, with the following fields:
        • programId (string): the program that generated the return data, as base-58 encoded Pubkey.
        • data ([string, encoding]): the return data itself, as base-64 encoded binary data.
      • computeUnitsConsumed (u64|undefined): the number of compute units consumed by the transaction.
    • version ("legacy"|number|undefined): the transaction version. Undefined if maxSupportedTransactionVersion is not set in request params.

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": "getTransaction",
"params": [
"jS5UBJWbrxL9DM86LoGznZtqg8q8rP3xPmMv77s7F7qdCwQFg7cchxWHdRSw5X7Bmuvy6dTaejMcgjv2XJQ9dfD",
{
"encoding": "json",
"maxSupportedTransactionVersion": 0
}
]
}'

Response example 1

{
"jsonrpc": "2.0",
"result": {
"blockTime": 1744798149,
"meta": {
"computeUnitsConsumed": 4726,
"err": null,
"fee": 5000,
"innerInstructions": [],
"loadedAddresses": {
"readonly": [],
"writable": []
},
"logMessages": [
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4726 of 200000 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success"
],
"postBalances": [
35199803303,
2039280,
2039280,
934087680
],
"postTokenBalances": [
{
"accountIndex": 1,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "EkkpfzUdwwgeqWb25hWcSi2c5gquELLUB3Z2asr1Xroo",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "828545485",
"decimals": 6,
"uiAmount": 828.545485,
"uiAmountString": "828.545485"
}
},
{
"accountIndex": 2,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "DjGkZ6k5hMkaxMAboqc9MUrL8zq59Q8aQUuF6Fmr6DUD",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "1109995438",
"decimals": 6,
"uiAmount": 1109.995438,
"uiAmountString": "1109.995438"
}
}
],
"preBalances": [
35199808303,
2039280,
2039280,
934087680
],
"preTokenBalances": [
{
"accountIndex": 1,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "EkkpfzUdwwgeqWb25hWcSi2c5gquELLUB3Z2asr1Xroo",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "828545486",
"decimals": 6,
"uiAmount": 828.545486,
"uiAmountString": "828.545486"
}
},
{
"accountIndex": 2,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "DjGkZ6k5hMkaxMAboqc9MUrL8zq59Q8aQUuF6Fmr6DUD",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "1109995437",
"decimals": 6,
"uiAmount": 1109.995437,
"uiAmountString": "1109.995437"
}
}
],
"rewards": [],
"status": {
"Ok": null
}
},
"slot": 374619973,
"transaction": {
"message": {
"accountKeys": [
"EkkpfzUdwwgeqWb25hWcSi2c5gquELLUB3Z2asr1Xroo",
"7nxXxpEEsAFf5CSqapwjBjt65xnQUBAdug2pXS89YzmY",
"HdUKfS4QwKUQawoLXNyDdsut11mtoYRyntFrhhjdhgR1",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
],
"addressTableLookups": [],
"header": {
"numReadonlySignedAccounts": 0,
"numReadonlyUnsignedAccounts": 1,
"numRequiredSignatures": 1
},
"instructions": [
{
"accounts": [
1,
2,
0,
0
],
"data": "3DdGGhkhJbjm",
"programIdIndex": 3,
"stackHeight": null
}
],
"recentBlockhash": "5jKHQZzdu7kazYmicjPgwANsDwAqJnjWCYR1yjEVDZBL"
},
"signatures": [
"jS5UBJWbrxL9DM86LoGznZtqg8q8rP3xPmMv77s7F7qdCwQFg7cchxWHdRSw5X7Bmuvy6dTaejMcgjv2XJQ9dfD"
]
},
"version": 0
},
"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",
"id": 1,
"method": "getTransaction",
"params": [
"jS5UBJWbrxL9DM86LoGznZtqg8q8rP3xPmMv77s7F7qdCwQFg7cchxWHdRSw5X7Bmuvy6dTaejMcgjv2XJQ9dfD",
{
"encoding": "base64",
"maxSupportedTransactionVersion": 0
}
]
}'

Response example 2

{
"jsonrpc": "2.0",
"result": {
"blockTime": 1744798149,
"meta": {
"computeUnitsConsumed": 4726,
"err": null,
"fee": 5000,
"innerInstructions": [],
"loadedAddresses": {
"readonly": [],
"writable": []
},
"logMessages": [
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4726 of 200000 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success"
],
"postBalances": [
35199803303,
2039280,
2039280,
934087680
],
"postTokenBalances": [
{
"accountIndex": 1,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "EkkpfzUdwwgeqWb25hWcSi2c5gquELLUB3Z2asr1Xroo",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "828545485",
"decimals": 6,
"uiAmount": 828.545485,
"uiAmountString": "828.545485"
}
},
{
"accountIndex": 2,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "DjGkZ6k5hMkaxMAboqc9MUrL8zq59Q8aQUuF6Fmr6DUD",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "1109995438",
"decimals": 6,
"uiAmount": 1109.995438,
"uiAmountString": "1109.995438"
}
}
],
"preBalances": [
35199808303,
2039280,
2039280,
934087680
],
"preTokenBalances": [
{
"accountIndex": 1,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "EkkpfzUdwwgeqWb25hWcSi2c5gquELLUB3Z2asr1Xroo",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "828545486",
"decimals": 6,
"uiAmount": 828.545486,
"uiAmountString": "828.545486"
}
},
{
"accountIndex": 2,
"mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"owner": "DjGkZ6k5hMkaxMAboqc9MUrL8zq59Q8aQUuF6Fmr6DUD",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "1109995437",
"decimals": 6,
"uiAmount": 1109.995437,
"uiAmountString": "1109.995437"
}
}
],
"rewards": [],
"status": {
"Ok": null
}
},
"slot": 374619973,
"transaction": [
"ASSXkS4gFdRPjAgYMtI83mxAdkQQxNnrNjVo0/8n3PuyIfJiogZfy+QQZYpG/KbPbARMNWYYkgyNQtgHSfk+AgiAAQABBMxddFcL+KHOvfWKqE5HeL1iR4V7zrweiMVtVjfN1B7OZOwM3pq0f7lZsDDur9i+ue/ujyUjQwUnXvJRe7/+3hP3EsrzEUsyPOtXf0utjSb34dXGwknd9iobwU0NFQ5NrAbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpRkXQbtykq1Yx/ZUrutYrW1qb5/p2XC9uMes1kL5LbhcBAwQBAgAACQMBAAAAAAAAAAA=",
"base64"
],
"version": 0
},
"id": 1
}