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 single-batch helpers, while finalize_upload_merkle completes a prepared upload from one winning pool hash. An upload larger than a single Merkle tree (256 fresh chunks, roughly 1 GiB) spans several batches: prepare_merkle_batches_external returns the batches to pay, and finalize_upload_merkle_multi completes the upload from a Vec of per-batch winner-hash entries aligned to those batches — one entry per batch, in order, with None marking a batch the signer did not pay. At least one batch must be paid, or the call returns a payment error; the chunks of an unpaid batch surface through the partial-upload error once the paid batches store. Progress-aware variants such as file_prepare_upload_with_progress, finalize_upload_with_progress, finalize_upload_merkle_with_progress, and finalize_upload_merkle_multi_with_progress are also available when you need UI feedback during long-running uploads.
Key types
ant_core::data::Client
Main network client
ant_core::data::ClientConfig
Quote, Merkle batch store (merkle_store_timeout_secs, 270 s default), and chunk retrieve (chunk_get_timeout_secs) timeouts; concurrency limits; loopback policy. Non-Merkle chunk PUT response timeout is set by an internal STORE_RESPONSE_TIMEOUT constant, not via this struct.
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:
Related pages
Last updated