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.
Supported platforms
Section titled “Supported platforms”Current version
Section titled “Current version”Features
Section titled “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.
Installation
Section titled “Installation”commonMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos:<version>")}jvmMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-jvm:<version>")}androidMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-android:<version>")}The SDK is compatible with iosArm64, iosX64, and iosSimulatorArm64. Depending on how your project is configured, you can add the following dependencies:
For iosArm64:
iosMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-iosArm64:<version>")}For iosX64:
iosMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-iosX64:<version>")}jsMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-js:<version>")}The SDK only supports Linux x64. To add the dependency, use the following:
linuxMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-linux:<version>")}The SDK only supports macOS x64, macOS arm64, and macOS arm64 simulator. To add the dependency, use the following:
For macOS x64:
macosMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-macosX64:<version>")}For macOS arm64:
macosMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-macosArm64:<version>")}The SDK only supports Windows x64. To add the dependency, use the following:
mingwMain.dependencies { implementation("xyz.mcxross.kaptos:kaptos-mingwX64:<version>")}Perform a Transaction
Section titled “Perform a Transaction”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.
Examples
Section titled “Examples”For more examples on how and what you can do with the Kotlin SDK, check out the following: