JavaScript

The JavaScript SDK is the REST client package for antd.

Install

npm install antd

Connect to the daemon

import { RestClient, createClient } from "antd";

// Default REST client
const client = createClient();

// Explicit constructor
const directClient = new RestClient({ baseUrl: "http://localhost:8082" });

// Custom URL or timeout
const remoteClient = createClient({ baseUrl: "http://custom-host:9090", timeout: 60000 });

// Auto-discover from daemon.port
const { client: discoveredClient, url } = RestClient.autoDiscover();
console.log(url);

Store and retrieve data

For upload examples in this section, start antd in a write-enabled mode first. On the default network, that means wallet plus EVM payment configuration. On a local devnet, ant dev start provisions that for you.

Type mappings

Autonomi type
JavaScript type

HealthStatus

{ ok: boolean, network: string }

PutResult

{ cost: string, address: string }

FileUploadResult

{ address: string, storageCostAtto: string, gasCostWei: string, chunksStored: number, paymentModeUsed: string }

WalletAddress

{ address: string }

WalletBalance

{ balance: string, gasBalance: string }

PrepareUploadResult

object with uploadId, paymentType, totalAmount, paymentVaultAddress, paymentTokenAddress, rpcUrl, plus payments for wave-batch uploads or depth, poolCommitments, and merklePaymentTimestamp for Merkle uploads

FinalizeUploadResult

{ address: string, chunksStored: number }

Raw data

Buffer

Error handling

Full API reference

For all available daemon endpoints, see the REST API.

Last updated