suix_getAllBalances - Sui
Example code for the suix_getAllBalances JSON-RPC method. Complete guide on how to use suix_getAllBalances JSON-RPC in GetBlock Web3 documentation.
This method retrieves all coin balances for every token type owned by an address on the SUI network, returning aggregated balance information for each coin type in a single response.
Parameters
owner
string
Yes
The owner's SUI address to query all balances for
Must be a valid SUI address starting with "0x"
Request Example
curl --location --request POST https://go.getblock.io/<ACCESS-TOKEN>/ \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "suix_getAllBalances",
"params": [
"0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
],
"id": "getblock.io"
}'import requests
import json
url = "https://go.getblock.io/<ACCESS-TOKEN>/"
headers = {"Content-Type": "application/json"}
payload = {
"jsonrpc": "2.0",
"method": "suix_getAllBalances",
"params": [
"0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
],
"id": "getblock.io"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print("Result:", response.json().get("result"))
else:
print("Error:", response.status_code, response.text)Sample Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": [
{
"coinType": "0x2::sui::SUI",
"coinObjectCount": 15,
"totalBalance": "3000000000",
"lockedBalance": {}
},
{
"coinType": "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
"coinObjectCount": 3,
"totalBalance": "1500000000",
"lockedBalance": {}
}
]
}Response Parameters
jsonrpc
string
The JSON-RPC protocol version ("2.0")
id
string
Request identifier matching the request
result
array
Array of balance objects for each coin type
result[].coinType
string
The fully qualified coin type identifier
result[].coinObjectCount
integer
Number of coin objects for this type
result[].totalBalance
string
Total balance in the coin's smallest unit
result[].lockedBalance
object
Map of locked balance amounts
Use Cases
Portfolio Display: Display complete token holdings in wallet applications by fetching all balances in a single call, enabling comprehensive portfolio views without multiple API requests.
Multi-Token Analytics: Build analytics dashboards that track holdings across all token types, calculating total portfolio value by aggregating balances and market prices.
Account Overview: Provide users with a complete overview of their SUI account holdings, including native SUI and all custom tokens they own.
Error handling
Invalid Address Format
The SUI address is not properly formatted
Ensure the address is a valid 66-character hexadecimal string starting with '0x'
Empty Result
Address has no coin objects
Verify the address has received tokens
Network Error
Connection issues with the RPC endpoint
Check network connectivity and endpoint availability
SDK Integration
Last updated
Was this helpful?