Rust Library Reference

ant-core is the native Rust library for building directly on Autonomi without the daemon.

Install

Use ant-core as a local dependency from an ant-client checkout:

[dependencies]
ant-core = { path = "../ant-client/ant-core" }
bytes = "1"
tokio = { version = "1", features = ["full"] }

For same-machine devnets or local testnets, set ClientConfig { allow_loopback: true, ..ClientConfig::default() } before Client::connect. Keep the default false on public networks.

Connect to the network

use ant_core::data::{Client, ClientConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::connect(&["1.2.3.4:12000".parse()?], ClientConfig::default()).await?;
    let _ = client;
    Ok(())
}

To enable paid operations, attach a wallet:

Store and retrieve data

To make uploaded data publicly retrievable by address, store and later fetch the DataMap:

File operations

External signer flows

The native Rust library exposes both wave-batch and Merkle-batch external payment helpers.

For wave-batch uploads, data_prepare_upload, data_prepare_upload_with_visibility, file_prepare_upload, and finalize_upload prepare the upload, collect quotes, and later store the chunks after an external signer returns transaction hashes. Use data_prepare_upload_with_visibility(content, Visibility::Public) to bundle the DataMap chunk into the same payment batch and receive its network address in the FileUploadResult after finalize.

For Merkle batches, prepare_merkle_batch_external and finalize_merkle_batch expose the low-level batch helpers, while finalize_upload_merkle completes a prepared upload from the winning pool hash. Progress-aware variants such as file_prepare_upload_with_progress, finalize_upload_with_progress, and finalize_upload_merkle_with_progress are also available when you need UI feedback during long-running uploads.

Key types

Type
Description

ant_core::data::Client

Main network client

ant_core::data::ClientConfig

Separate quote and store timeouts, concurrency limits, and loopback policy

ant_core::data::PaymentMode

Auto, Merkle, or Single

ant_core::data::DataMap

Private retrieval map for uploaded data

ant_core::data::LocalDevnet

Local development helper

ant_core::data::Wallet

EVM wallet used for paid operations

ant_core::data::PreparedUpload

Two-phase upload state used by external-signer flows

ant_core::data::ExternalPaymentInfo

External payment details for prepared uploads

ant_core::data::PreparedMerkleBatch

Prepared Merkle batch data for external signing

ant_core::data::Visibility

Upload visibility: Private (DataMap returned to caller) or Public (DataMap bundled into payment batch and stored on-network)

External signer example

Error handling

Local development

The library also exports LocalDevnet for local development flows:

Enable the ant-core devnet feature before you use this section:

Last updated