For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dart

Use the Dart SDK to store and retrieve data through a local daemon, a background service called antd. The client supports REST and gRPC.

Install

Use Dart 3.0 or later, but earlier than Dart 4.0. Create a project and add the antd_client package from pub.dev:

dart create autonomi_example
cd autonomi_example
dart pub add antd_client

dart pub add records antd_client as a hosted dependency in pubspec.yaml and resolves it. The pub.dev package named antd is unrelated. Save each example as bin/autonomi_example.dart, replacing the generated file, and run it with dart run. Examples on this page use antd_client 0.2 with antd 0.14.

Connect to antd

Follow Start the Local Daemon to run antd before connecting.

import 'package:antd_client/antd_client.dart';

Future<void> main() async {
  final client = AntdClient(baseUrl: 'http://localhost:8082');
  try {
    final health = await client.health();
    print('antd version: ${health.version}');
  } on AntdError catch (error) {
    print('antd request failed: $error');
  } finally {
    client.close();
  }
}

Expected output:

Store and retrieve data

Start antd in a write-enabled mode before you upload. The public Autonomi Network requires wallet and Ethereum Virtual Machine (EVM) payment configuration. A local development network created with ant dev start includes that configuration.

Expected output:

Type mappings

Autonomi type
Dart type

HealthStatus

Dart model type

PutResult

Dart model type

Raw data

Uint8List

Error handling

An address with no stored data throws NotFoundError, a subclass of AntdError.

Output when the valid address is not stored:

External-signer finalize methods throw PartialUploadError, a subclass of NetworkError, when some chunks remain unstored; it carries chunksStored, chunksFailed, totalChunks, retryable, and retentionKnown. When retryable is true, repeating the same finalize call with the same upload ID stores the remainder without paying again; see the external-signer guide for the other cases.

Full API reference

For all available antd endpoints, see the REST API.

Last updated