For the complete documentation index, see llms.txt. This page is also available as Markdown.

StateService/ListBalances - SUI

Example code for the StateService/ListBalances gRPC method. Complete guide on how to use StateService/ListBalances gRPC method in GetBlock Web3 documentation.

Returns all coin balances for an address — every coin type the address holds, with the aggregated balance for each. Paginated via page_size and page_token.

Service: sui.rpc.v2.StateService Proto file: sui/rpc/v2/state_service.proto Full method path: sui.rpc.v2.StateService/ListBalances

Request Fields

Field
Type
Required
Description

owner

Address

Yes

32-byte address (hex 0x...)

page_size

uint32

No

Maximum balances per page (provider-specific cap, typically 50)

page_token

string

No

Pagination token from a previous response

Request Example

# Clone the official proto files first (one-time setup):
#   git clone https://github.com/MystenLabs/sui-apis.git && cd sui-apis

grpcurl \
  -import-path proto \
  -proto sui/rpc/v2/state_service.proto \
  -H "x-grpc-web: 1" \
  -d '{
    "owner": "0xb871a42470b59c7184033a688f883cf24eb5e66eae1db62319bab27adb30b873",
    "page_size": 50
}' \
  go.getblock.io:443/<ACCESS-TOKEN> \
  sui.rpc.v2.StateService/ListBalances

Response Example

Responses are encoded in Protocol Buffers binary format on the wire. The example below shows the protobuf JSON encoding for readability.

Response Fields

Field
Type
Description

balances

repeated CoinBalance

Per-coin-type balance entries

balances[].coin_type

string

Move coin type

balances[].balance

string

Total balance in the coin's smallest unit

next_page_token

string

Token to pass as page_token on the next call; empty when no more pages

Use Cases

  • Multi-asset wallet UI showing all coin holdings

  • Portfolio dashboards covering every token an address holds

  • Detecting unknown / spam coin transfers an address received

Error Handling

gRPC uses status codes rather than JSON-RPC numeric error codes. The most relevant for this method:

Status Code
Numeric
Cause

UNAUTHENTICATED

16

Missing or invalid <ACCESS-TOKEN> in the URL path

INVALID_ARGUMENT

3

Request fields are missing, malformed, or fail validation

UNAVAILABLE

14

Node is overloaded or temporarily unable to handle the request — retry with backoff

DEADLINE_EXCEEDED

4

Request did not complete within the timeout window

RESOURCE_EXHAUSTED

8

Rate limit exceeded for your plan

SDK Integration

Was this helpful?