Query account states, balances, token holdings, and program-specific storage data.
getProgramAccounts
Get program accounts owned by a specific program ID.
Scans of large programs such as the Token program are fetched from the datasource. The public default datasource rejects them with 403 Forbidden, so start Surfpool with a private RPC URL (surfpool start --rpc-url <URL>) to run this sample, or query a program with fewer accounts.
Parameters
The public key of the program, as a base-58 encoded string.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The data slice configuration. Show properties Hide properties
The length of the data slice.
The offset of the data slice.
The encoding for the account data.
Filters to apply to the program accounts. Each filter is a base58-encoded string representing an address or a specific filter type.
The minimum context slot for the account info.
Whether to sort the results.
Whether to include the context in the response.
Result
getProgramAccounts - Returns program-owned accounts Show properties Hide properties
Show properties Hide properties
Whether this account contains executable code
Account balance in lamports
Program that owns this account
Epoch at which this account will next owe rent
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
"commitment": "confirmed",
"encoding": "base64",
"dataSlice": {
"offset": 0,
"length": 0
},
"filters": [
{
"dataSize": 165
}
],
"withContext": true
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254448 ,
"apiVersion" : "4.2.1"
},
"value" : [
{
"pubkey" : "Ah241PLYdGWy2heWX42XfEWg8XtCvXDxtzTEfp3abgak" ,
"account" : {
"lamports" : 2039280 ,
"data" : [
"" ,
"base64"
],
"owner" : "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ,
"executable" : false ,
"rentEpoch" : 0 ,
"space" : 165
}
}
]
}
}
getLargestAccounts
Returns the 20 largest accounts by lamport balance.
Parameters
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The filter to apply to the largest accounts.
Result
Show properties Hide properties
Show properties Hide properties
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getLargestAccounts",
"params": [
{
"commitment": "confirmed",
"filter": "circulating"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254448 ,
"apiVersion" : "4.2.1"
},
"value" : [
{
"address" : "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM" ,
"lamports" : 999999999999
},
{
"address" : "GmaDrppBC7P5ARKV8g3djiwP89vz1jLK23V2GBjuAEGB" ,
"lamports" : 5000000000
}
]
}
}
getSupply
Returns information about the current token supply.
Parameters
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
excludeNonCirculatingAccountsList Whether to exclude non-circulating accounts.
Result
Show properties Hide properties
Show properties Hide properties
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getSupply",
"params": [
{
"commitment": "confirmed",
"excludeNonCirculatingAccountsList": true
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254622 ,
"apiVersion" : "4.2.1"
},
"value" : {
"total" : 0 ,
"circulating" : 0 ,
"nonCirculating" : 0 ,
"nonCirculatingAccounts" : []
}
}
}
getTokenLargestAccounts
Returns the largest accounts for a given token mint.
Parameters
The public key of the token mint, as a base-58 encoded string.
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
Result
Show properties Hide properties
Show properties Hide properties
Human readable amount as float
Human readable amount as string
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenLargestAccounts",
"params": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{
"commitment": "confirmed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254448 ,
"apiVersion" : "4.2.1"
},
"value" : [
{
"address" : "Ah241PLYdGWy2heWX42XfEWg8XtCvXDxtzTEfp3abgak" ,
"amount" : "1000000000" ,
"decimals" : 6 ,
"uiAmount" : 1000 ,
"uiAmountString" : "1000"
}
]
}
}
getTokenAccountsByOwner
Returns all SPL Token accounts by owner.
Run the surfnet_setTokenAccount sample first to create a USDC token account for this owner; otherwise the list is empty.
Parameters
The public key of the account owner, as a base-58 encoded string.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The data slice configuration. Show properties Hide properties
The length of the data slice.
The offset of the data slice.
The encoding for the account data.
The minimum context slot for the account info.
Result
Show properties Hide properties
Show properties Hide properties
Show properties Hide properties
Whether this account contains executable code
Account balance in lamports
Program that owns this account
Epoch at which this account will next owe rent
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
{
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
},
{
"commitment": "confirmed",
"encoding": "jsonParsed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254702 ,
"apiVersion" : "4.2.1"
},
"value" : [
{
"pubkey" : "Ah241PLYdGWy2heWX42XfEWg8XtCvXDxtzTEfp3abgak" ,
"account" : {
"lamports" : 2039280 ,
"data" : {
"program" : "spl-token" ,
"parsed" : {
"type" : "account" ,
"info" : {
"mint" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" ,
"owner" : "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" ,
"tokenAmount" : {
"uiAmount" : 1000 ,
"decimals" : 6 ,
"amount" : "1000000000" ,
"uiAmountString" : "1000"
},
"state" : "initialized" ,
"isNative" : false
}
},
"space" : 165
},
"owner" : "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ,
"executable" : false ,
"rentEpoch" : 0 ,
"space" : 165
}
}
]
}
}
getTokenAccountsByDelegate
Returns all SPL Token accounts by delegate.
Returns accounts whose delegate is the given address; the list is empty unless you have delegated a token account to it (see surfnet_setTokenAccount).
Parameters
The public key of the delegate, as a base-58 encoded string.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The data slice configuration. Show properties Hide properties
The length of the data slice.
The offset of the data slice.
The encoding for the account data.
The minimum context slot for the account info.
Result
Show properties Hide properties
Show properties Hide properties
Show properties Hide properties
Whether this account contains executable code
Account balance in lamports
Program that owns this account
Epoch at which this account will next owe rent
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByDelegate",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
{
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
},
{
"commitment": "confirmed",
"encoding": "jsonParsed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254448 ,
"apiVersion" : "4.2.1"
},
"value" : []
}
}
getAccountInfo
Returns detailed information about an account given its public key.
Parameters
The public key of the account to query, as a base-58 encoded string.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The data slice configuration. Show properties Hide properties
The length of the data slice.
The offset of the data slice.
The encoding for the account data.
The minimum context slot for the account info.
Result
Show properties Hide properties
Show properties Hide properties
Whether this account contains executable code
Account balance in lamports
Program that owns this account
Epoch at which this account will next owe rent
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
{
"commitment": "confirmed",
"encoding": "base64"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254783 ,
"apiVersion" : "4.2.1"
},
"value" : {
"lamports" : 2000000 ,
"data" : [
"" ,
"base64"
],
"owner" : "11111111111111111111111111111111" ,
"executable" : false ,
"rentEpoch" : 0 ,
"space" : 0
}
}
}
getBlockCommitment
Returns commitment levels for a given block (slot).
Parameters
The slot to query for block commitment.
Result
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockCommitment",
"params": [
0
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"commitment" : [
0 ,
0 ,
0
],
"totalStake" : 0
}
}
getMultipleAccounts
Returns account information for multiple public keys in a single call.
Parameters
An array of public keys to query, as base-58 encoded strings.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The data slice configuration. Show properties Hide properties
The length of the data slice.
The offset of the data slice.
The encoding for the account data.
The minimum context slot for the account info.
Result
Show properties Hide properties
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
"GmaDrppBC7P5ARKV8g3djiwP89vz1jLK23V2GBjuAEGB"
],
{
"commitment": "confirmed",
"encoding": "base64"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254783 ,
"apiVersion" : "4.2.1"
},
"value" : [
{
"lamports" : 2000000 ,
"data" : [
"" ,
"base64"
],
"owner" : "11111111111111111111111111111111" ,
"executable" : false ,
"rentEpoch" : 0 ,
"space" : 0
},
{
"lamports" : 5000000000 ,
"data" : [
"" ,
"base64"
],
"owner" : "11111111111111111111111111111111" ,
"executable" : false ,
"rentEpoch" : 0 ,
"space" : 0
}
]
}
}
getTokenAccountBalance
Returns the balance of a token account, given its public key.
The sample token account is the USDC account that surfnet_setTokenAccount creates for 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri; run that request first, otherwise the account is not found.
Parameters
The public key of the token account to query, as a base-58 encoded string.
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
Result
Show properties Hide properties
Show properties Hide properties
Human readable amount as float
Human readable amount as string
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountBalance",
"params": [
"Ah241PLYdGWy2heWX42XfEWg8XtCvXDxtzTEfp3abgak",
{
"commitment": "confirmed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254784 ,
"apiVersion" : "4.2.1"
},
"value" : {
"uiAmount" : 1000 ,
"decimals" : 6 ,
"amount" : "1000000000" ,
"uiAmountString" : "1000"
}
}
}
getTokenSupply
Returns the total supply of a token, given its mint address.
Parameters
The public key of the token mint, as a base-58 encoded string.
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
Result
Show properties Hide properties
Show properties Hide properties
Human readable amount as float
Human readable amount as string
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenSupply",
"params": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{
"commitment": "confirmed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254784 ,
"apiVersion" : "4.2.1"
},
"value" : {
"uiAmount" : 7707412496.102412 ,
"decimals" : 6 ,
"amount" : "7707412496102412" ,
"uiAmountString" : "7707412496.102412"
}
}
}
getBalance
Returns the balance for a given address.
Parameters
The public key of the account to query, as a base-58 encoded string.
Configuration object for the query. Show properties Hide properties
The commitment describes how finalized a block is at that point in time. Options are ‘processed’, ‘confirmed’, or ‘finalized’
The minimum context slot for the context.
Result
Show properties Hide properties
curl http://127.0.0.1:8899 -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
{
"commitment": "confirmed"
}
]
}
'
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"context" : {
"slot" : 457254783 ,
"apiVersion" : "4.2.1"
},
"value" : 2000000
}
}