Download the PHP package autonomi/antd without Composer
On this page you can find all versions of the php package autonomi/antd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download autonomi/antd
More information about autonomi/antd
Files in autonomi/antd
Package antd
Short Description PHP SDK for the antd daemon — the gateway to the Autonomi decentralized network.
License MIT Apache-2.0
Homepage https://github.com/WithAutonomi/ant-sdk/tree/main/antd-php
Informations about the package antd
antd-php
PHP SDK for the antd daemon — the gateway to the Autonomi decentralized network.
Source of truth: this SDK is developed in the ant-sdk monorepo.
WithAutonomi/antd-phpis a read-only mirror of that directory, kept in sync by CI so Packagist can index it. Open issues and pull requests againstant-sdk; anything pushed to the mirror is overwritten.
Installation
Quick Start
Prerequisites
The antd daemon must be running. Start it with:
Configuration
API Reference
Health
| Method | Description |
|---|---|
health() |
Check daemon status |
Data (Immutable)
| Method | Description |
|---|---|
dataPutPublic(string $data, string $paymentMode = 'auto') |
Store public data — returns DataPutPublicResult (DataMap stored on-network) |
dataGetPublic(string $address) |
Retrieve public data by address |
dataPut(string $data, string $paymentMode = 'auto') |
Store encrypted private data — returns DataPutResult (DataMap returned to caller) |
dataGet(string $dataMap) |
Retrieve private data using a caller-held DataMap |
dataCost(string $data, string $paymentMode = 'auto') |
Estimate storage cost — returns UploadCostEstimate with size, chunks, gas, payment mode |
Chunks
| Method | Description |
|---|---|
chunkPut(string $data) |
Store a raw chunk |
chunkGet(string $address) |
Retrieve a chunk |
Files
| Method | Description |
|---|---|
filePut(string $path, string $paymentMode = 'auto') |
Upload a file privately — returns FilePutResult (DataMap returned to caller) |
fileGet(string $dataMap, string $destPath) |
Download a private file using a caller-held DataMap |
filePutPublic(string $path, string $paymentMode = 'auto') |
Upload a file publicly — returns FilePutPublicResult (DataMap stored on-network) |
fileGetPublic(string $address, string $destPath) |
Download a public file by address |
fileCost(string $path, bool $isPublic, string $paymentMode = 'auto') |
Estimate upload cost — returns UploadCostEstimate with size, chunks, gas, payment mode |
Async Usage
Every method has an Async variant that returns a GuzzleHttp\Promise\PromiseInterface instead of blocking. This lets you fire off multiple requests concurrently and wait for results when you need them.
Basic promise usage
Chaining with then() / otherwise()
Concurrent requests
Settling without throwing
Error Handling
All errors extend AntdError (which extends \RuntimeException) and can be caught by type:
| Error Type | HTTP Status | When |
|---|---|---|
BadRequestError |
400 | Invalid parameters |
PaymentError |
402 | Insufficient funds |
NotFoundError |
404 | Resource not found |
AlreadyExistsError |
409 | Resource exists |
ForkError |
409 | Version conflict |
TooLargeError |
413 | Payload too large |
InternalError |
500 | Server error |
NetworkError |
502 | Network unreachable |
PartialUploadError |
502 | A finalize stored only part of the upload (code: "PARTIAL_UPLOAD"; extends NetworkError) |
Partial uploads
An external-signer finalize (finalizeUpload, finalizeChunkUpload) can fail after the
payment settled: some chunks store, others miss quorum after the daemon's own retries. The
SDK throws PartialUploadError with chunksStored / chunksFailed / totalChunks and two
flags, retryable and retentionKnown (retryable implies retentionKnown). The on-chain
payment persists and the stored chunks stay on the network; what to do next depends on the
flags:
retryable(antd ≥ 0.14.0): the daemon kept the paid attempt under the sameupload_id. Call the same finalize method again with the sameupload_idand tx hashes to store the remainder against the same payment — no re-prepare, no second signature, no double payment. Bound that loop: a persistent failure throws on every call, so cap the attempts and treat achunksFailedthat stops shrinking as stuck.retentionKnown && !retryable: the daemon confirmed nothing was retained (a daemon-wallet upload, or a merkle finalize with deliberately unpaid batches). Re-prepare the same content — already-stored chunks are skipped.!retentionKnown: retention is unknown. The daemon may still hold the paid attempt (it records the resume handle before it returns the error), so stop automatic recovery, keep theupload_idand the original tx hashes, and reconcile before re-preparing or paying again. Never pay again on this signal alone. Daemons older than 0.14.0 never sendretryable, so their partial uploads read as unknown.
The body is read strictly: a count comes only from a non-negative JSON integer (anything else
reads 0), retryable is true only for the JSON boolean true, retentionKnown is true
only when retryable is a JSON boolean (missing, null or any other type reads as unknown),
and a code other than the string "PARTIAL_UPLOAD" keeps the plain NetworkError. A
malformed error body never escapes as a PHP TypeError; the message falls back to the raw body
when error is not a string.
PartialUploadError extends NetworkError, so a pre-existing catch (NetworkError $e) still
catches it; catch the subclass first when you need the counts. The full contract is in
docs/external-signer-flow.md
under "6. Retry a partial store".
Examples
See the examples/ directory:
01-connect.php— Health check02-data.php— Public data storage and retrieval03-chunks.php— Raw chunk operations04-files.php— File and directory upload/download06-private-data.php— Private encrypted data07-external-signer.php— External-signer flow with a bounded partial-upload retry
Versioning and releases
Releases are cut from the monorepo: a php-vX.Y.Z tag on ant-sdk is verified,
split, and pushed to the mirror as vX.Y.Z, which Packagist picks up as the
package version. There is no version field in composer.json — Composer
derives it from the mirror's tags.
License
Dual-licensed under either the Apache-2.0 license, at your option.