In-process Kotlin bindings for Autonomi, generated
from the ant-sdk FFI crate
via UniFFI. Ships as a regular
Android Archive (.aar) with native libraries for the three Android ABIs
Google Play requires + ChromeOS. Talks directly to the network — no daemon
process required.
The SDK is published to a Maven repository hosted on GitHub Pages
(ant-maven). Add the repo, then
the dependency.
In settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://withautonomi.github.io/ant-maven/")
}
}In your app module's build.gradle.kts:
dependencies {
implementation("com.autonomi:ant-android:0.0.3")
// JNA (to call into libant_ffi.so) and kotlinx-coroutines-core are
// pulled in transitively from the POM — no need to declare them.
}That's it — the .so native libraries are inside the AAR; nothing to build
locally.
| ABI | Notes |
|---|---|
arm64-v8a |
Modern Android devices — required by Google Play. |
armeabi-v7a |
Older 32-bit ARM devices — required by Google Play. |
x86_64 |
Android emulator on Intel hosts + ChromeOS. |
x86 (32-bit Intel) is deprecated and not shipped.
Minimum compileSdk: 34. Minimum minSdk: 24 (Android 7.0).
Everything starts from a Client. Pick the constructor that matches how you
pay for uploads:
| Your goal | Constructor | You provide |
|---|---|---|
| Download / read public data only | Client.connect(peers) |
bootstrap peers |
| Upload, the app holds the key | Client.connectWithWallet(peers, privateKey, rpcUrl, paymentTokenAddress, paymentVaultAddress) |
key + EVM config |
| Upload, the user's wallet signs (WalletConnect) | Client.connectForExternalSigner(peers, rpcUrl, paymentTokenAddress, paymentVaultAddress) |
EVM config (no key) — see below |
| Local testing against a devnet | Client.connectLocal() or Client.connectFromDevnetManifest(path) |
a running devnet |
Every method is a suspend fun — call from a coroutine. A failure surfaces as
a typed ClientException.
import uniffi.ant_ffi.Client
import kotlinx.coroutines.runBlocking
runBlocking {
val client = Client.connectLocal()
val put = client.chunkPut("hello autonomi".toByteArray())
val bytes = client.chunkGet(put.address)
println("stored at ${put.address}")
}val client = Client.connectWithWallet(
peers = listOf(/* network bootstrap multiaddrs */),
privateKey = "0x…",
rpcUrl = "https://…",
paymentTokenAddress = "0x…", // ANT token
paymentVaultAddress = "0x…", // payment vault
)
// Public: the data map is stored on the network; retrieve by address.
val pub = client.dataPutPublic(payload, "auto")
val back = client.dataGetPublic(pub.address)
// Private: you keep the returned hex data map; it's the only way back in.
val priv = client.dataPutPrivate(payload, "auto")
val secret = client.dataGetPrivate(priv.dataMap)try {
client.dataGetPublic(addr)
} catch (e: ClientException.NotFound) {
// address isn't on the network
} catch (e: ClientException.NetworkError) {
// transient — safe to retry
} catch (e: ClientException.PaymentError) {
// …
}connectForExternalSigner never holds a key. You prepareDataUpload /
prepareFileUpload, sign the returned payment on-chain with the user's wallet
(e.g. via WalletConnect), then finalizeUpload. The full three-step flow,
calldata shapes, and the IPaymentVault ABI are documented in
ant-sdk/docs/external-signer-flow.md.
See ant-mobile-android
for a complete working reference (WalletConnect wiring, both wave and merkle
payment paths, live progress).
Note: the SDK models uniffi
suspend fns with kotlinx-coroutines. ForDispatchers.Mainin a UI app you may also wantimplementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:…"), which is not transitive from the SDK.
paymentMode(dataPutPublic/dataPutPrivate/fileUploadPublic):"auto"(default — picks the cheapest batching for the size),"single", or"merkle".visibility(prepareDataUpload/prepareFileUpload):"public"(retrieve by address) or"private"(retrieve with the hex data map you keep).- Addresses & data maps are hex strings. Chunk/data payloads cross the FFI
as
ByteArray.
Releases are cut in lockstep with ant-sdk:
a tag vX.Y.Z in ant-sdk triggers a matching vX.Y.Z release here, published
to ant-maven.
Dual-licensed under either MIT or Apache 2.0, at your option.