跳转到内容

Kaptos - Kotlin SDK

此内容尚不支持你的语言。

Kaptos is a Kotlin Multiplatform SDK for interacting with the Aptos blockchain across various platforms. It offers a consistent API for data requests, transaction submissions, and more, facilitating cross-platform app development with shared business logic. The SDK includes asynchronous Aptos clients for smooth blockchain interactions.

Kaptos also provides platform-specific SDKs for JVM, Android, iOS, JS, Linux, macOS, and Windows.

AndroidiOStvOSwatchOSNode.jsJVMLinuxmacOSWindows
Maven CentralSnapshotSDK Reference
  • 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.
commonMain.dependencies {
implementation("xyz.mcxross.kaptos:kaptos:<version>")
}

Below is an example of how you can perform a transaction using the Kotlin SDK. The snippet demonstrates the latest lean API, where build, sign, and submit happen in one call.

val result = aptos.execute(signer = alice) {
function = "0x1::coin::transfer"
typeArgs("0x1::aptos_coin::AptosCoin")
args(bob.accountAddress, 1_000_000UL)
}

The SDK also provides pre-built methods for common transaction operations. For example, you can use the transferCoinTransaction method to generate a transfer transaction between two accounts as shown below:

val txn = aptos.transferCoinTransaction(
alice.accountAddress,
bob.accountAddress,
SEND_AMOUNT
)

You can then sign and submit this transaction.

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