GraphQL Client
The Sui instance in the Kotlin SDK is a GraphQL client under the hood. It offers a robust and user-friendly interface for querying Sui network data, including Transactions, Checkpoints, Objects, and Events, from a data indexer operator. If no custom operator is specified, it defaults to the mainnet GraphQL endpoint maintained by Mysten Labs.
The Sui() instance is the entry point for data retrieval.
Create our client instance:
Call the appropriate coins method on the client
Coins Data
The Sui class includes an abstraction called Coin, which provides access to the coin-related API.
Account Balance
Fetch the balance of a specific coin type for a given address.
Total Supply
Fetch the total supply for a given coin type.
Move Data
The Sui class includes an abstraction called Move, which provides access to the move-related API.
Normalized Move Function
Fetch the normalized (desugared and with types expanded) representation of a Move function.
Move Function Argument Types
Fetch the argument types for a specific Move function.
And more...
Get Account Balance
Once you've an account, you can either retrieve the balance for a specific coin type or for all coin types.
For a specific coin type:
This defaults to the 0x2::sui::SUI coin type, or you can pass a particular coin type argument to the type parameter as shown below:
You can also simply retrieve all coin type balances as follows:
Get Account Objects
You can also retrieve objects owned by a given account address:
Get Account Coins
Account Coins retrieval also follows the same pattern
Get Account Stakes
You can fetch stakes for an account as follows:
Resolve Account Name Service Names
Request Test Tokens
If your Sui() client is configured for testnet, you can request test tokens from a faucet as follows:
Response Handling
Information regarding response handling can be found here
Reference
You can find a complete list of available methods and usage in the SDK reference