Aptos Client

AndroidiOStvOSwatchOSNodeJSJVMmacOSLinuxWindows

Integrate with the Aptos blockchain using Kaptos, a type-safe Kotlin Multiplatform SDK. You write your code once and target Android, iOS, JVM, Node.js, macOS, Linux, and Windows.

Kaptos provides Aptos as the main client entry point, Account for key management, and helpers for transactions and queries.

Installation

Add the dependency. Snapshots are available from the Sonatype snapshots repository.

  1. Add the artifact (current version 0.2.0):

    Code
    // commonMain for KMP implementation("xyz.mcxross.kaptos:kaptos:0.2.0")

    Platform variants:

    Code
    implementation("xyz.mcxross.kaptos:kaptos-android:0.2.0") implementation("xyz.mcxross.kaptos:kaptos-jvm:0.2.0")
  2. For snapshot builds:

    Code
    repositories { maven("https://central.sonatype.com/repository/maven-snapshots") }

Quick Start

Create an Aptos client with AptosConfig and work with accounts and transactions.

Code
import xyz.mcxross.kaptos.Aptos import xyz.mcxross.kaptos.account.Account import xyz.mcxross.kaptos.model.AptosConfig import xyz.mcxross.kaptos.model.AptosSettings import xyz.mcxross.kaptos.model.Network fun main() { val aptos = Aptos( AptosConfig(AptosSettings(network = Network.DEVNET)) ) val alice = Account.generate() val bob = Account.generate() // Fund on devnet/testnet aptos.fundAccount(alice.accountAddress, 100_000_000) aptos.fundAccount(bob.accountAddress, 100_000_000) // Simple transfer using the built-in helper val txn = aptos.transferCoinTransaction( alice.accountAddress, bob.accountAddress, 1_000_000UL ) val signed = aptos.sign(alice, txn) val submitted = aptos.submitTransaction.simple(txn, signed) val result = aptos.waitForTransaction(submitted.hash) println(result) }

Accounts

Code
import xyz.mcxross.kaptos.account.Account import xyz.mcxross.kaptos.core.crypto.Ed25519PrivateKey val account = Account.generate() // From private key val privateKey = Ed25519PrivateKey("...") val account = Account.from(privateKey)

Configuration

Code
val aptos = Aptos( AptosConfig( AptosSettings( network = Network.TESTNET, // fullNode = "...", // faucet = "..." ) ) )

Reference & Resources