GetBalance
gRPC
RPC Method
sui.rpc.v2.StateService/GetBalanceRetrieves the balance of a specific coin type for the specified address.
Proto files required
Running the examples below requires the official Sui proto files. Download the proto files, then set the example's -import-path relative to the proto root (the -proto path in the examples is relative to the proto root).
TransportgRPC
Request and response messages are identical for both transports. Only the wire protocol, headers, and client library differ.
- Protocol
- Native gRPC over HTTP/2 with TLS. Suited to server-side clients and grpcurl.
- Content-Type
application/grpc- Headers
x-api-key- Streaming
- Server, client, and bidirectional streaming are all supported.
- Errors
- grpc-status and grpc-message are delivered as HTTP/2 trailers.
Request Message
ownerstringrequired
Required. The owner's Sui address.coin_typestringrequired
Required. The type name for the coin (e.g., 0x2::sui::SUI).Response Message
Balance information for the requested coin type.
coin_typestring
Coin type.balanceinteger
Total balance.address_balanceinteger
Address balance portion.coin_balanceinteger
Coin<T> balance portion.grpcurl
grpcurl \-import-path . \-proto sui/rpc/v2/state_service.proto \-H 'X-API-KEY: nodit-demo' \-d '{"coin_type": "0x2::sui::SUI"}' \sui-mainnet.nodit.io:443 \sui.rpc.v2.StateService/GetBalance