Kaptos
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.
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 = alice.accountAddress,
data =
entryFunctionData {
function = "0x1::coin::transfer"
typeArguments = typeArguments {
+TypeTagStruct(type = "0x1::aptos_coin::AptosCoin".toStructTag())
}
functionArguments = functionArguments {
+MoveString(bob.accountAddress.toString())
+U64(SEND_AMOUNT_UNITS.toULong())
}
},
)
// Sign and submit the transaction
val commitedTransaction = aptos.signAndSubmitTransaction(alice, 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: