Skip to content
🎉 Welcome to the new Aptos Docs! Click here to submit feedback!
Build
Kotlin SDK

Kaptos

Kaptos, a Kotlin Multiplatform lib, is a Multiplatform SDK for connecting, exploring, and interacting with the Aptos blockchain across multiple platforms. It offers a uniform API for requesting data, sending transactions, and more; making cross-platform application development with shared business logic easy. The SDK provides asynchronous Aptos clients for seamless blockchain interactions.

Android BadgeiOS BadgetvOS BadgewatchOS BadgeNodeJS BadgeJVM BadgeLinux BadgemacOS BadgeWindows Badge

Static Badge

Features

  • Type-safe: The SDK is fully type-safe and provides a rich set of types for all operations.
  • Expressive: Kaptos provides a simple and expressive DSL-style API for building transactions.
  • Multiplatform: Write cross-platform applications with shared business logic.
  • Consistent API: All operations bare a uniform and consistent API across all platforms.
  • BCS Support: The SDK defaults to BCS for serialization and deserialization of transactions.
  • Asynchronous: All blockchain operations are asynchronous.
  • Configurable: The SDK provides highly configurable clients for all platforms.
💡

Kaptos is currently under development, please give feedback here

Installation

commonMain.dependencies {
  implementation("xyz.mcxross.kaptos:kaptos:<version>")
}

Perform a Transaction

Below is an example of how you can perform a transaction using the Kotlin SDK. The snippet demonstrates how to build a transaction to transfer APT. We then sign and submit the transaction to the blockchain in a single step.

  val txn =
    aptos.buildTransaction.simple(
      sender = aliceAccount.accountAddress,
      data =
        inputEntryFunctionData {
          function = "0x1::coin::transfer"
          typeArguments = typeArguments {
            +TypeTagStruct(type = "0x1::aptos_coin::AptosCoin".toStructTag())
          }
          functionArguments = functionArguments {
            +MoveString(bobAccountAddress.value)
            +U64(SEND_AMOUNT)
          }
        },
    )

  // Sign and submit the transaction
  val commitedTransaction = aptos.signAndSubmitTransaction(aliceAccount, txn)

  val executedTransaction =
    aptos.waitForTransaction(HexInput.fromString(commitedTransaction.expect("Transaction failed").hash))

Examples

For more examples on how and what you can do with the Kotlin SDK, check out the following: