Skip to content
Alchemy Logo

Sui gRPC quickstart

This guide walks you through making your first Sui gRPC call.

NetworkEndpoint
Mainnetsui-mainnet.g.alchemy.com:443
Testnetsui-testnet.g.alchemy.com:443

Authentication uses a Bearer token in the request header:

-H "Authorization: Bearer <YOUR_API_KEY>"

Start with a GetServiceInfo call to verify your connection and check the current chain state.

grpcurl \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -import-path proto \
  -proto sui/rpc/v2/ledger_service.proto \
  -d '{}' \
  sui-mainnet.g.alchemy.com:443 \
  sui.rpc.v2.LedgerService/GetServiceInfo

Expected response:

{
  "chain": "mainnet",
  "chainId": "35834a8a",
  "checkpointHeight": "12345678",
  "epoch": "500",
  "server": "alchemy"
}

Query a Sui object by its ID using GetObject. Use read_mask to request specific fields.

grpcurl \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -import-path proto \
  -proto sui/rpc/v2/ledger_service.proto \
  -d '{
    "object_id": "0x5",
    "read_mask": {"paths": ["object_id", "version", "digest", "owner"]}
  }' \
  sui-mainnet.g.alchemy.com:443 \
  sui.rpc.v2.LedgerService/GetObject

Fetch a transaction by its digest.

grpcurl \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -import-path proto \
  -proto sui/rpc/v2/ledger_service.proto \
  -d '{
    "digest": "YOUR_TX_DIGEST"
  }' \
  sui-mainnet.g.alchemy.com:443 \
  sui.rpc.v2.LedgerService/GetTransaction

Query the SUI balance for an address.

grpcurl \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -import-path proto \
  -proto sui/rpc/v2/state_service.proto \
  -d '{
    "owner": "0xYOUR_ADDRESS",
    "coin_type": "0x2::sui::SUI"
  }' \
  sui-mainnet.g.alchemy.com:443 \
  sui.rpc.v2.StateService/GetBalance

Was this page helpful?