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

Ruby

Use the Ruby SDK to store and retrieve data through a local daemon, a background service called antd. The client uses REST by default, with an optional gRPC client.

Install

Use Ruby 3.1 or later. Install the antd gem from RubyGems:

gem install antd

In a Bundler project, run bundle add antd instead. Examples on this page use the antd gem 0.2 with antd 0.14.

For gRPC, also install the optional runtime dependency:

gem install grpc --version '~> 1.60'

Connect to antd

Follow Start the Local Daemon to run antd before connecting.

require "antd"

begin
  client = Antd::Client.new(base_url: "http://localhost:8082")
  health = client.health
  puts "antd version: #{health.version}"
rescue Antd::AntdError => e
  abort "antd request failed: #{e.message}"
end

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
Ruby type

HealthStatus

model object with ok and network

PutResult

model object with cost and address

Raw data

String

Error handling

An address with no stored data raises Antd::NotFoundError, a subclass of Antd::AntdError.

Output when the valid address is not stored:

External-signer finalize methods raise Antd::PartialUploadError, a subclass of Antd::NetworkError, when some chunks remain unstored; it carries chunks_stored, chunks_failed, total_chunks, retryable, and retention_known. 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