Antd.Client (antd v0.4.1)

Copy Markdown View Source

REST client for the antd daemon.

All public functions take a %Antd.Client{} as the first argument and return {:ok, result} or {:error, exception}. Bang variants (e.g. health!/1) raise on error.

Naming convention

Private = unqualified verb (the DataMap is returned to the caller; it is NOT stored on the network). Public = _public suffix (the DataMap is additionally stored on-network and the call returns the resulting address).

  • data_put / data_get — private
  • data_put_public / data_get_public — public
  • file_put / file_get — private
  • file_put_public / file_get_public — public
  • chunk_put / chunk_get — no public/private split

Payment mode

Put and cost methods that touch the network accept an optional :payment_mode keyword argument — an atom (:auto, :merkle, :single) from Antd.PaymentMode. The atom is serialized to the wire string at the request boundary. :auto is the default.

Pointers

pointer_* functions read and write pointers: owner-signed, mutable references whose owner keys the daemon holds. Every write (pointer_create, pointer_update, pointer_transfer, pointer_finalize) pays, and every attempt pays again, so this client never retries them and callers should not either. Reads are free to retry. Counters are integers parsed strictly from the daemon's decimal strings.

Summary

Functions

Creates a client using port discovery.

Builds a .ant manifest from DataMaps and public addresses already in hand (POST /v1/manifests/build). Nothing is uploaded or paid for.

Retrieves a chunk by address.

Like chunk_get/2 but raises on error.

Stores a raw chunk on the network.

Like chunk_put/2 but raises on error.

Pre-upload cost breakdown for the given bytes.

Retrieves private data using a caller-held DataMap (hex).

Like data_get/2 but raises on error.

Retrieves public data by address.

Stores private encrypted data on the network.

Stores public data on the network.

Streams private data for a caller-held DataMap (hex) with constant memory.

Like data_stream/2 but raises on error.

Streams public data by address with constant memory.

data_stream/2 with interleaved fetch-progress frames so the caller can drive a determinate download progress bar. Opts into NDJSON framing (Accept: application/x-ndjson); enumerating the returned stream yields Antd.DownloadFrame structs — each a plaintext chunk (:data) or a Antd.DownloadProgress update (:progress).

Decodes .ant bytes (a raw binary) via POST /v1/manifests/decode. Returns an Antd.DecodedManifest; a malformed manifest is an Antd.BadRequestError.

Decodes an ant:// manifest link, a file link or a bare 64-hex address via POST /v1/manifests/decode. A file link or address reads as one public entry with no path and source: "file_link". Takes the same :resolve option as decode_manifest/3.

Estimates the cost of uploading a file.

Downloads a private file from a caller-held DataMap into dest_path.

Downloads a public file from the network to a local path.

Uploads a file privately. Returns the caller-held DataMap (hex) in the result — the DataMap is NOT stored on-network.

Uploads a local file publicly.

Submits a prepared chunk to the network after external payment via POST /v1/chunks/finalize.

Finalizes a merkle-batch upload after selecting a winning pool.

Finalizes an upload after an external signer has submitted payment transactions.

Checks the antd daemon status.

Like health/1 but raises on error.

Follows the transfers of the pointer at address to the pointer whose owner now decides what it resolves to (GET /v1/pointers/{address}/controller).

Creates the pointer at owner, pointing at target, paid by the daemon wallet (POST /v1/pointers). owner is the pointer's address; the daemon must hold its key (pointer_keys/1).

Asks the whole close group where the pointer at address stands (GET /v1/pointers/{address}/finality). Check it before relying on a transfer: only status: :final (Antd.PointerFinality.final?/1) means it is beyond dispute.

Stores a prepared pointer write once its external signer has paid (POST /v1/pointers/finalize). tx_hashes maps each quote_hash from the prepare's payments to its payForQuotes() transaction hash.

Reads the pointer at address (GET /v1/pointers/{address}). Returns Antd.NotFoundError if there is none.

Like pointer_get/2 but raises on error.

Lists the pointers this daemon holds owner keys for (GET /v1/pointers/keys), as their addresses. Only these can be written through this daemon.

Like pointer_keys/1 but raises on error.

Has the daemon sign op on the pointer at owner with its loaded key and quote it for an external signer (POST /v1/pointers/prepare). Pay the result's payments with payForQuotes(), then call pointer_finalize/3. Needs no daemon wallet.

Follows a chain of pointers from address to the target at its end (GET /v1/pointers/{address}/resolve), through forwardings and transfers alike. Returns Antd.NotFoundError if a pointer on the chain does not exist.

Hands the pointer at owner over to the pointer at recipient, for good, paid by the daemon wallet (POST /v1/pointers/transfer). Readers of the address are redirected to the recipient's pointer, which only its owner can move. Irreversible once stored.

Points the pointer at owner at target, paid by the daemon wallet (POST /v1/pointers/update). A pointer that does not exist yet is created at counter 0.

Prepares a single chunk for external-signer publish via POST /v1/chunks/prepare.

Prepares an in-memory data upload for external signing.

Prepares a file upload for external signing.

Convenience wrapper: prepare a public file upload for external signing.

Returns the wallet address configured on the daemon.

Like wallet_address/1 but raises on error.

Approves the wallet to spend tokens on payment contracts (one-time operation).

Like wallet_approve/1 but raises on error.

Returns the wallet balance and gas balance.

Like wallet_balance/1 but raises on error.

Types

t()

@type t() :: %Antd.Client{base_url: String.t(), timeout: integer()}

Functions

auto_discover(opts \\ [])

@spec auto_discover(keyword()) :: {t(), String.t()}

Creates a client using port discovery.

Reads the daemon.port file to find the REST port. Falls back to the default base URL if the port file is not found.

Options

  • :timeout - HTTP request timeout in milliseconds (default: 300_000)

Examples

{client, url} = Antd.Client.auto_discover()
{client, url} = Antd.Client.auto_discover(timeout: 30_000)

build_manifest(client, entries, opts \\ [])

@spec build_manifest(t(), [Antd.ManifestEntryInput.t()], keyword()) ::
  {:ok, Antd.BuiltManifest.t()} | {:error, Exception.t()}

Builds a .ant manifest from DataMaps and public addresses already in hand (POST /v1/manifests/build). Nothing is uploaded or paid for.

entries is a list of Antd.ManifestEntryInput, each with exactly one of data_map or address; one with both or neither is refused before anything is sent (Antd.BadRequestError, status_code 400, as from the daemon). An entry the daemon rejects (an invalid path, a malformed DataMap) is an Antd.BadRequestError whose message names entries[i].

Returns an Antd.BuiltManifest: the raw .ant bytes, the ant:// link (nil when it would not fit 1,500 bytes) and the entries in encoded order.

Options

  • :name — a suggested root directory name (one portable path component).
  • :torrent_info_hashes — BitTorrent info hashes of the same files: hex, 40 characters for v1 and/or 64 for v2.
  • :embed_roots — true (the default) resolves each shrunk DataMap's root, fetching its wrapper records, and embeds it when it is at most 64 KiB, so recipients skip that fetch (ADR-0006's policy). false embeds DataMaps exactly as given.

build_manifest!(client, entries, opts \\ [])

@spec build_manifest!(t(), [Antd.ManifestEntryInput.t()], keyword()) ::
  Antd.BuiltManifest.t()

Like build_manifest/3 but raises on error.

chunk_get(client, address)

@spec chunk_get(t(), String.t()) :: {:ok, binary()} | {:error, Exception.t()}

Retrieves a chunk by address.

chunk_get!(client, address)

@spec chunk_get!(t(), String.t()) :: binary()

Like chunk_get/2 but raises on error.

chunk_put(client, data)

@spec chunk_put(t(), binary()) :: {:ok, Antd.PutResult.t()} | {:error, Exception.t()}

Stores a raw chunk on the network.

chunk_put!(client, data)

@spec chunk_put!(t(), binary()) :: Antd.PutResult.t()

Like chunk_put/2 but raises on error.

data_cost(client, data, opts \\ [])

@spec data_cost(t(), binary(), keyword()) ::
  {:ok, Antd.UploadCostEstimate.t()} | {:error, Exception.t()}

Pre-upload cost breakdown for the given bytes.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

data_cost!(client, data, opts \\ [])

@spec data_cost!(t(), binary(), keyword()) :: Antd.UploadCostEstimate.t()

Like data_cost/3 but raises on error.

data_get(client, data_map)

@spec data_get(t(), String.t()) :: {:ok, binary()} | {:error, Exception.t()}

Retrieves private data using a caller-held DataMap (hex).

data_get!(client, data_map)

@spec data_get!(t(), String.t()) :: binary()

Like data_get/2 but raises on error.

data_get_public(client, address)

@spec data_get_public(t(), String.t()) :: {:ok, binary()} | {:error, Exception.t()}

Retrieves public data by address.

data_get_public!(client, address)

@spec data_get_public!(t(), String.t()) :: binary()

Like data_get_public/2 but raises on error.

data_put(client, data, opts \\ [])

@spec data_put(t(), binary(), keyword()) ::
  {:ok, Antd.DataPutResult.t()} | {:error, Exception.t()}

Stores private encrypted data on the network.

Returns an %Antd.DataPutResult{} whose :data_map is the caller-held hex DataMap; the DataMap is NOT stored on-network.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

data_put!(client, data, opts \\ [])

@spec data_put!(t(), binary(), keyword()) :: Antd.DataPutResult.t()

Like data_put/3 but raises on error.

data_put_public(client, data, opts \\ [])

@spec data_put_public(t(), binary(), keyword()) ::
  {:ok, Antd.DataPutPublicResult.t()} | {:error, Exception.t()}

Stores public data on the network.

The DataMap is stored on-network as an extra chunk; the returned :address is the shareable retrieval handle.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

data_put_public!(client, data, opts \\ [])

@spec data_put_public!(t(), binary(), keyword()) :: Antd.DataPutPublicResult.t()

Like data_put_public/3 but raises on error.

data_stream(client, data_map)

@spec data_stream(t(), String.t()) :: {:ok, Enumerable.t()} | {:error, Exception.t()}

Streams private data for a caller-held DataMap (hex) with constant memory.

Unlike data_get/2, which buffers the entire decrypted payload in memory, this returns a lazy Enumerable of raw binary chunks. The daemon decrypts on the fly via POST /v1/data/stream and the body is consumed one chunk at a time, so peak memory stays flat regardless of the object size.

The returned stream MUST be consumed in the same process that called data_stream/2 (a Req streaming constraint). Enumerating it yields binary chunks; concatenate or write them as they arrive, e.g.

{:ok, stream} = Antd.Client.data_stream(client, data_map)
Enum.into(stream, File.stream!("out.bin"))

Non-2xx responses are parsed from the JSON {"error": ...} body and returned as {:error, exception} (mirroring data_get/2).

data_stream!(client, data_map)

@spec data_stream!(t(), String.t()) :: Enumerable.t()

Like data_stream/2 but raises on error.

data_stream_public(client, address)

@spec data_stream_public(t(), String.t()) ::
  {:ok, Enumerable.t()} | {:error, Exception.t()}

Streams public data by address with constant memory.

Streaming counterpart to data_get_public/2. Fetches via GET /v1/data/public/{address}/stream and returns a lazy Enumerable of raw binary chunks; see data_stream/2 for the consumption contract (same-process requirement, error mapping).

data_stream_public!(client, address)

@spec data_stream_public!(t(), String.t()) :: Enumerable.t()

Like data_stream_public/2 but raises on error.

data_stream_public_with_progress(client, address)

@spec data_stream_public_with_progress(t(), String.t()) ::
  {:ok, Enumerable.t()} | {:error, Exception.t()}

data_stream_public/2 with interleaved fetch-progress frames. See data_stream_with_progress/2.

data_stream_public_with_progress!(client, address)

@spec data_stream_public_with_progress!(t(), String.t()) :: Enumerable.t()

Like data_stream_public_with_progress/2 but raises on error.

data_stream_with_progress(client, data_map)

@spec data_stream_with_progress(t(), String.t()) ::
  {:ok, Enumerable.t()} | {:error, Exception.t()}

data_stream/2 with interleaved fetch-progress frames so the caller can drive a determinate download progress bar. Opts into NDJSON framing (Accept: application/x-ndjson); enumerating the returned stream yields Antd.DownloadFrame structs — each a plaintext chunk (:data) or a Antd.DownloadProgress update (:progress).

{:ok, frames} = Antd.Client.data_stream_with_progress(client, data_map)
Enum.each(frames, fn
  %Antd.DownloadFrame{progress: %{} = p} -> render_bar(p.fetched, p.total)
  %Antd.DownloadFrame{data: bytes} -> IO.binwrite(bytes)
end)

data_stream_with_progress!(client, data_map)

@spec data_stream_with_progress!(t(), String.t()) :: Enumerable.t()

Like data_stream_with_progress/2 but raises on error.

decode_manifest(client, manifest, opts \\ [])

@spec decode_manifest(t(), binary(), keyword()) ::
  {:ok, Antd.DecodedManifest.t()} | {:error, Exception.t()}

Decodes .ant bytes (a raw binary) via POST /v1/manifests/decode. Returns an Antd.DecodedManifest; a malformed manifest is an Antd.BadRequestError.

Options

  • :resolve — true fetches each entry's DataMap (and wrapper records) to report exact_size and confirm the DataMap is on the network. Content chunks are not fetched, and one entry's failure is reported in its error, not as a failed call. Default false.

decode_manifest!(client, manifest, opts \\ [])

@spec decode_manifest!(t(), binary(), keyword()) :: Antd.DecodedManifest.t()

Like decode_manifest/3 but raises on error.

decode_manifest_link(client, link, opts \\ [])

@spec decode_manifest_link(t(), String.t(), keyword()) ::
  {:ok, Antd.DecodedManifest.t()} | {:error, Exception.t()}

Decodes an ant:// manifest link, a file link or a bare 64-hex address via POST /v1/manifests/decode. A file link or address reads as one public entry with no path and source: "file_link". Takes the same :resolve option as decode_manifest/3.

decode_manifest_link!(client, link, opts \\ [])

@spec decode_manifest_link!(t(), String.t(), keyword()) :: Antd.DecodedManifest.t()

Like decode_manifest_link/3 but raises on error.

file_cost(client, path, is_public, opts \\ [])

@spec file_cost(t(), String.t(), boolean(), keyword()) ::
  {:ok, Antd.UploadCostEstimate.t()} | {:error, Exception.t()}

Estimates the cost of uploading a file.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

file_cost!(client, path, is_public, opts \\ [])

@spec file_cost!(t(), String.t(), boolean(), keyword()) :: Antd.UploadCostEstimate.t()

Like file_cost/4 but raises on error.

file_get(client, data_map, dest_path)

@spec file_get(t(), String.t(), String.t()) :: :ok | {:error, Exception.t()}

Downloads a private file from a caller-held DataMap into dest_path.

The response body is empty on success — the file is written to dest_path.

file_get!(client, data_map, dest_path)

@spec file_get!(t(), String.t(), String.t()) :: :ok

Like file_get/3 but raises on error.

file_get_public(client, address, dest_path)

@spec file_get_public(t(), String.t(), String.t()) :: :ok | {:error, Exception.t()}

Downloads a public file from the network to a local path.

file_get_public!(client, address, dest_path)

@spec file_get_public!(t(), String.t(), String.t()) :: :ok

Like file_get_public/3 but raises on error.

file_put(client, path, opts \\ [])

@spec file_put(t(), String.t(), keyword()) ::
  {:ok, Antd.FilePutResult.t()} | {:error, Exception.t()}

Uploads a file privately. Returns the caller-held DataMap (hex) in the result — the DataMap is NOT stored on-network.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

file_put!(client, path, opts \\ [])

@spec file_put!(t(), String.t(), keyword()) :: Antd.FilePutResult.t()

Like file_put/3 but raises on error.

file_put_public(client, path, opts \\ [])

@spec file_put_public(t(), String.t(), keyword()) ::
  {:ok, Antd.FilePutPublicResult.t()} | {:error, Exception.t()}

Uploads a local file publicly.

The DataMap is stored on-network as an extra chunk; the returned :address is the shareable retrieval handle.

Options

  • :payment_mode — Antd.PaymentMode.t() (default :auto).

file_put_public!(client, path, opts \\ [])

@spec file_put_public!(t(), String.t(), keyword()) :: Antd.FilePutPublicResult.t()

Like file_put_public/3 but raises on error.

finalize_chunk_upload(client, upload_id, tx_hashes)

@spec finalize_chunk_upload(t(), String.t(), map()) ::
  {:ok, String.t()} | {:error, Exception.t()}

Submits a prepared chunk to the network after external payment via POST /v1/chunks/finalize.

tx_hashes maps each non-zero quote_hash returned by prepare_chunk_upload/2 to the tx_hash of the corresponding payForQuotes() transaction. Returns the hex-encoded network address of the stored chunk (matches :address from the prepare result).

Requires antd >= 0.7.0.

finalize_chunk_upload!(client, upload_id, tx_hashes)

@spec finalize_chunk_upload!(t(), String.t(), map()) :: String.t()

Like finalize_chunk_upload/3 but raises on error.

finalize_merkle_upload(client, upload_id, winner_pool_hash, opts \\ [])

@spec finalize_merkle_upload(t(), String.t(), String.t(), keyword()) ::
  {:ok, Antd.FinalizeUploadResult.t()} | {:error, Exception.t()}

Finalizes a merkle-batch upload after selecting a winning pool.

A partial store surfaces as {:error, %Antd.PartialUploadError{}} exactly as for finalize_upload/3, with the same three cases: retry the same call (bounded) while retryable is true; re-prepare the same content only when retention_known is true and retryable is false (for example a merkle finalize with deliberately unpaid batches); and when retention_known is false, stop, keep upload_id and winner_pool_hash, and reconcile before re-preparing or paying again.

finalize_merkle_upload!(client, upload_id, winner_pool_hash, opts \\ [])

@spec finalize_merkle_upload!(t(), String.t(), String.t(), keyword()) ::
  Antd.FinalizeUploadResult.t()

Like finalize_merkle_upload/4 but raises on error.

finalize_upload(client, upload_id, tx_hashes)

@spec finalize_upload(t(), String.t(), map()) ::
  {:ok, Antd.FinalizeUploadResult.t()} | {:error, Exception.t()}

Finalizes an upload after an external signer has submitted payment transactions.

A finalize that stored only part of the upload returns {:error, %Antd.PartialUploadError{}} (not the Antd.NetworkError a 502 used to map to; see Antd.PartialUploadError) carrying chunks_stored, chunks_failed, total_chunks, retryable and retention_known. The payment persists and the stored chunks stay on the network. Recovery has three cases:

  • retryable: true — the daemon kept the paid attempt under the same upload_id: call this function again with the same arguments to store the remainder against the same payment. Bound that loop (cap the attempts; a chunks_failed that stops shrinking means stuck).
  • retention_known: true, retryable: false — the daemon confirmed it kept nothing: re-prepare the same content (already-stored chunks are skipped, so the retry pays only for the remainder).
  • retention_known: false — retention is unknown (the body's retryable was missing or not a boolean, as with daemons older than 0.14.0) and the daemon may still hold the paid attempt. Stop automatic recovery, keep upload_id and tx_hashes, and reconcile before re-preparing or paying again.

See Antd.PartialUploadError, docs/external-signer-flow.md §6 and examples/07_external_signer.exs.

finalize_upload!(client, upload_id, tx_hashes)

@spec finalize_upload!(t(), String.t(), map()) :: Antd.FinalizeUploadResult.t()

Like finalize_upload/3 but raises on error.

health(client)

@spec health(t()) :: {:ok, Antd.HealthStatus.t()} | {:error, Exception.t()}

Checks the antd daemon status.

health!(client)

@spec health!(t()) :: Antd.HealthStatus.t()

Like health/1 but raises on error.

new(base_url \\ "http://localhost:8082", opts \\ [])

@spec new(String.t(), keyword()) :: t()

Creates a new client.

Options

  • :timeout - HTTP request timeout in milliseconds (default: 300_000)

Examples

client = Antd.Client.new()
client = Antd.Client.new("http://custom-host:9090")
client = Antd.Client.new("http://localhost:8082", timeout: 30_000)

pointer_controller(client, address)

@spec pointer_controller(t(), String.t()) ::
  {:ok, Antd.PointerController.t()} | {:error, Exception.t()}

Follows the transfers of the pointer at address to the pointer whose owner now decides what it resolves to (GET /v1/pointers/{address}/controller).

pointer_controller!(client, address)

@spec pointer_controller!(t(), String.t()) :: Antd.PointerController.t()

Like pointer_controller/2 but raises on error.

pointer_create(client, owner, target, opts \\ [])

@spec pointer_create(t(), String.t(), String.t(), keyword()) ::
  {:ok, Antd.PointerWriteResult.t()} | {:error, Exception.t()}

Creates the pointer at owner, pointing at target, paid by the daemon wallet (POST /v1/pointers). owner is the pointer's address; the daemon must hold its key (pointer_keys/1).

Returns Antd.AlreadyExistsError if the pointer exists, refused before anything is paid; use pointer_update/4. Each call pays: do not retry it automatically.

Options

pointer_create!(client, owner, target, opts \\ [])

@spec pointer_create!(t(), String.t(), String.t(), keyword()) ::
  Antd.PointerWriteResult.t()

Like pointer_create/4 but raises on error.

pointer_finality(client, address)

@spec pointer_finality(t(), String.t()) ::
  {:ok, Antd.PointerFinality.t()} | {:error, Exception.t()}

Asks the whole close group where the pointer at address stands (GET /v1/pointers/{address}/finality). Check it before relying on a transfer: only status: :final (Antd.PointerFinality.final?/1) means it is beyond dispute.

pointer_finality!(client, address)

@spec pointer_finality!(t(), String.t()) :: Antd.PointerFinality.t()

Like pointer_finality/2 but raises on error.

pointer_finalize(client, upload_id, tx_hashes)

@spec pointer_finalize(t(), String.t(), map()) ::
  {:ok, Antd.PointerFinalizeResult.t()} | {:error, Exception.t()}

Stores a prepared pointer write once its external signer has paid (POST /v1/pointers/finalize). tx_hashes maps each quote_hash from the prepare's payments to its payForQuotes() transaction hash.

A write that falls short after payment returns Antd.CloseGroupShortfallError with retryable: true: the daemon kept the paid state under the same upload_id, and calling this function again with the same upload_id stores it against the same payment (tx_hashes is then ignored). Bound that loop; the session expires with the daemon's one-hour pending TTL. This function never retries by itself. A finalize without the payment's hashes is Antd.BadRequestError and keeps the session, so it can be corrected.

pointer_finalize!(client, upload_id, tx_hashes)

@spec pointer_finalize!(t(), String.t(), map()) :: Antd.PointerFinalizeResult.t()

Like pointer_finalize/3 but raises on error.

pointer_get(client, address)

@spec pointer_get(t(), String.t()) ::
  {:ok, Antd.PointerRecord.t()} | {:error, Exception.t()}

Reads the pointer at address (GET /v1/pointers/{address}). Returns Antd.NotFoundError if there is none.

pointer_get!(client, address)

@spec pointer_get!(t(), String.t()) :: Antd.PointerRecord.t()

Like pointer_get/2 but raises on error.

pointer_keys(client)

@spec pointer_keys(t()) :: {:ok, [String.t()]} | {:error, Exception.t()}

Lists the pointers this daemon holds owner keys for (GET /v1/pointers/keys), as their addresses. Only these can be written through this daemon.

pointer_keys!(client)

@spec pointer_keys!(t()) :: [String.t()]

Like pointer_keys/1 but raises on error.

pointer_prepare(client, owner, op, opts \\ [])

@spec pointer_prepare(t(), String.t(), Antd.PointerOp.t(), keyword()) ::
  {:ok, Antd.PointerPrepareResult.t()} | {:error, Exception.t()}

Has the daemon sign op on the pointer at owner with its loaded key and quote it for an external signer (POST /v1/pointers/prepare). Pay the result's payments with payForQuotes(), then call pointer_finalize/3. Needs no daemon wallet.

op is an Antd.PointerOp.t/0: {:create, target}, {:update, target} (either with a Antd.PointerKind.t/0 as a third element) or {:transfer, recipient}. Every check the daemon-wallet functions make before paying is made here, before anything is quoted. While the prepared write awaits payment, other writes to the pointer return Antd.ConflictError until it is finalized or expires (one hour).

Options

  • :include_signed_quotes — when true, the result's signed_quotes carries each quote in full signed form.

pointer_prepare!(client, owner, op, opts \\ [])

@spec pointer_prepare!(t(), String.t(), Antd.PointerOp.t(), keyword()) ::
  Antd.PointerPrepareResult.t()

Like pointer_prepare/4 but raises on error.

pointer_resolve(client, address)

@spec pointer_resolve(t(), String.t()) ::
  {:ok, Antd.PointerTarget.t()} | {:error, Exception.t()}

Follows a chain of pointers from address to the target at its end (GET /v1/pointers/{address}/resolve), through forwardings and transfers alike. Returns Antd.NotFoundError if a pointer on the chain does not exist.

pointer_resolve!(client, address)

@spec pointer_resolve!(t(), String.t()) :: Antd.PointerTarget.t()

Like pointer_resolve/2 but raises on error.

pointer_transfer(client, owner, recipient)

@spec pointer_transfer(t(), String.t(), String.t()) ::
  {:ok, Antd.PointerTransferResult.t()} | {:error, Exception.t()}

Hands the pointer at owner over to the pointer at recipient, for good, paid by the daemon wallet (POST /v1/pointers/transfer). Readers of the address are redirected to the recipient's pointer, which only its owner can move. Irreversible once stored.

Refused before paying if recipient does not exist or leads back (Antd.BadRequestError), and usually if the pointer is already final (Antd.PointerFinalError). An Antd.CloseGroupShortfallError means too few of the close group answered or stored it. That can happen before paying (the transfer checks every peer first) or after, so check the pointer with pointer_finality/2 before paying again. Each call pays: do not retry it automatically.

The result's finality is the close group's view once the write landed, or nil with finality_error set when that check failed; the transfer is stored either way.

pointer_transfer!(client, owner, recipient)

@spec pointer_transfer!(t(), String.t(), String.t()) :: Antd.PointerTransferResult.t()

Like pointer_transfer/3 but raises on error.

pointer_update(client, owner, target, opts \\ [])

@spec pointer_update(t(), String.t(), String.t(), keyword()) ::
  {:ok, Antd.PointerWriteResult.t()} | {:error, Exception.t()}

Points the pointer at owner at target, paid by the daemon wallet (POST /v1/pointers/update). A pointer that does not exist yet is created at counter 0.

Returns Antd.PointerFinalError if the pointer has been transferred or frozen (usually refused before anything is paid; see Antd.PointerFinalError), and Antd.ConflictError if a prepared write to it awaits payment (refused before paying) or the update lost to a newer state while in flight (possibly after paying); read the pointer before writing again. Each call pays: do not retry it automatically. Takes the same :kind option as pointer_create/4.

pointer_update!(client, owner, target, opts \\ [])

@spec pointer_update!(t(), String.t(), String.t(), keyword()) ::
  Antd.PointerWriteResult.t()

Like pointer_update/4 but raises on error.

prepare_chunk_upload(client, data)

@spec prepare_chunk_upload(t(), binary()) ::
  {:ok, Antd.PrepareChunkResult.t()} | {:error, Exception.t()}

Prepares a single chunk for external-signer publish via POST /v1/chunks/prepare.

The daemon quotes the close group, stashes the prepared state under a fresh upload id, and returns either:

  • %Antd.PrepareChunkResult{already_stored: true, address: addr} — the chunk is already on-network; no payment or finalize is needed.
  • %Antd.PrepareChunkResult{already_stored: false, upload_id: ..., payments: [...], ...} — the wave-batch intent the external signer must satisfy before calling finalize_chunk_upload/3.

Unlike chunk_put/2, this endpoint does NOT require the daemon to have a wallet — all funds flow through the external signer. Requires antd

= 0.7.0.

prepare_chunk_upload!(client, data)

@spec prepare_chunk_upload!(t(), binary()) :: Antd.PrepareChunkResult.t()

Like prepare_chunk_upload/2 but raises on error.

prepare_data_upload(client, data, opts \\ [])

@spec prepare_data_upload(t(), binary(), keyword()) ::
  {:ok, Antd.PrepareUploadResult.t()} | {:error, Exception.t()}

Prepares an in-memory data upload for external signing.

Options

  • :visibility — see prepare_upload/3. Note that the daemon currently returns 501 for "public" on /v1/data/prepare; use prepare_upload_public/2 with a file path until upstream ant-client exposes data_prepare_upload_with_visibility.

prepare_data_upload!(client, data, opts \\ [])

@spec prepare_data_upload!(t(), binary(), keyword()) :: Antd.PrepareUploadResult.t()

Like prepare_data_upload/3 but raises on error.

prepare_upload(client, path, opts \\ [])

@spec prepare_upload(t(), String.t(), keyword()) ::
  {:ok, Antd.PrepareUploadResult.t()} | {:error, Exception.t()}

Prepares a file upload for external signing.

Options

  • :visibility — "public" bundles the DataMap chunk into the same external-signer payment batch so a single EVM transaction covers both the data chunks and the DataMap. After finalize_upload/3, data_map_address on the result is the shareable retrieval handle. "private" (or omitting the option) keeps the existing private-only behaviour and the field is sent only when set.

prepare_upload!(client, path, opts \\ [])

@spec prepare_upload!(t(), String.t(), keyword()) :: Antd.PrepareUploadResult.t()

Like prepare_upload/3 but raises on error.

prepare_upload_public(client, path)

@spec prepare_upload_public(t(), String.t()) ::
  {:ok, Antd.PrepareUploadResult.t()} | {:error, Exception.t()}

Convenience wrapper: prepare a public file upload for external signing.

Equivalent to prepare_upload(client, path, visibility: "public"). Requires antd >= 0.6.1.

prepare_upload_public!(client, path)

@spec prepare_upload_public!(t(), String.t()) :: Antd.PrepareUploadResult.t()

Like prepare_upload_public/2 but raises on error.

wallet_address(client)

@spec wallet_address(t()) :: {:ok, Antd.WalletAddress.t()} | {:error, Exception.t()}

Returns the wallet address configured on the daemon.

wallet_address!(client)

@spec wallet_address!(t()) :: Antd.WalletAddress.t()

Like wallet_address/1 but raises on error.

wallet_approve(client)

@spec wallet_approve(t()) :: {:ok, boolean()} | {:error, Exception.t()}

Approves the wallet to spend tokens on payment contracts (one-time operation).

wallet_approve!(client)

@spec wallet_approve!(t()) :: boolean()

Like wallet_approve/1 but raises on error.

wallet_balance(client)

@spec wallet_balance(t()) :: {:ok, Antd.WalletBalance.t()} | {:error, Exception.t()}

Returns the wallet balance and gas balance.

wallet_balance!(client)

@spec wallet_balance!(t()) :: Antd.WalletBalance.t()

Like wallet_balance/1 but raises on error.