Sui Client

AndroidiOSNodeJSJVMmacOSLinux

Build Sui applications in Kotlin with Ksui, a type-safe Multiplatform SDK. You write once and run on Android, iOS, JVM, Node.js, macOS, and Linux. You use it for wallets, dApps, and backend services.

Key Features

  • Target multiple platforms from one codebase: Android, iOS, JVM, Node.js, macOS, and Linux.
  • Get compile-time safety with strong Kotlin types for all Sui models and operations.
  • Run asynchronous code with Kotlin coroutines.
  • Build Programmable Transaction Blocks with a concise DSL.
  • Choose transport: GraphQL (via the ksui artifact) or gRPC (via the ksui-grpc artifact).

Installation

Add the artifact that matches your needs.

  1. Add the snapshot repository when using pre-release versions:

    Code
    repositories { mavenCentral() maven("https://central.sonatype.com/repository/maven-snapshots") }
  2. Declare the dependency. Start with the main GraphQL client in most apps:

    Code
    // commonMain for KMP implementation("xyz.mcxross.ksui:ksui:2.2.9-SNAPSHOT")

    Or for a non-KMP JVM project:

    Code
    implementation("xyz.mcxross.ksui:ksui-jvm:2.2.9-SNAPSHOT")

Depend on ksui-core alone when you only need models, accounts, PTB building, and signing with no network client.

Add ksui-grpc when you want the gRPC transport:

Code
implementation("xyz.mcxross.ksui:ksui-grpc:2.2.9-SNAPSHOT")

Quick Start

Start with accounts and a client. The examples below use the GraphQL client.

Accounts

Create or import accounts from core:

Code
import xyz.mcxross.ksui.core.account.Account val newAccount = Account.create() val account = Account.import("suiprivkey1qq...") // or from mnemonic words val account = Account.import(listOf("abandon", "salad", "art", "..."))

Create the client

Instantiate the main entry point for GraphQL:

Code
import xyz.mcxross.ksui.Sui import xyz.mcxross.ksui.core.model.* val sui = Sui() // or target a network explicitly val sui = Sui(SuiConfig(settings = SuiSettings(network = Network.TESTNET)))

Query chain data

Code
val balance = sui.getBalance(account.address) val epoch = sui.getCurrentEpoch() val committee = sui.getCommitteeInfo()

Build a PTB

Use the ptb DSL to describe commands:

Code
import xyz.mcxross.ksui.core.ptb.ptb import xyz.mcxross.ksui.core.ptb.Argument val ptb = ptb { val coins = splitCoins { coin = Argument.GasCoin into = listOf(pure(1_000_000UL)) } transferObjects { objects = coins to = address("0x...") } }

When you pass string object IDs that require on-chain version and owner data, use the resolver-aware builder:

Code
import xyz.mcxross.ksui.ptb.ptb // suspend version from the ksui module val resolvedPtb = ptb(sui) { val obj = `object`("0x67a6...") // resolves automatically moveCall { target = "0x...::module::func"; arguments = listOf(obj) } }

Sign and execute

Code
import xyz.mcxross.ksui.core.model.ExecuteTransactionBlockResponseOptions val result = sui.signAndExecuteTransactionBlock( signer = account, ptb = ptb, options = ExecuteTransactionBlockResponseOptions(showEffects = true) ) val digest = result?.executeTransaction?.effects?.transaction?.digest if (digest != null) { sui.waitForTransaction(digest) }

Use the gRPC client

Use SuiGrpcClient when you prefer the gRPC transport or need streaming:

Code
import xyz.mcxross.ksui.grpc.SuiGrpcClient val client = SuiGrpcClient.fromConfig( SuiConfig(settings = SuiSettings(network = Network.TESTNET)) ) val epoch = client.getEpoch() val tx = client.getTransaction(digest) client.subscribeCheckpoints()

Build and sign transactions with the same core ptb, TransactionDataComposer, and Account types, then call executeTransaction with bytes and signatures.

Modules

Keep dependencies minimal:

  • xyz.mcxross.ksui:ksui-core — models, accounts, crypto, PTB builder, signing. No network calls.
  • xyz.mcxross.ksui:ksui — full GraphQL client with Sui entry point (recommended default).
  • xyz.mcxross.ksui:ksui-grpc — gRPC client with SuiGrpcClient.

Platform variants (-android, -jvm) exist for non-KMP setups.

Resources