Go
Use the Go SDK to store and retrieve data through a local daemon, a background service called antd. The client supports REST and gRPC and is available as a public Go module.
Install
Use Go 1.25 or later. Create a module and add the client to it:
mkdir antd-go-example
cd antd-go-example
go mod init example.com/antd-quickstart
go get github.com/WithAutonomi/ant-sdk/antd-goExamples on this page use module v0.14.0 with antd 0.14.
Connect to antd
Follow Start the Local Daemon to run antd before connecting.
package main
import (
"context"
"fmt"
"log"
antd "github.com/WithAutonomi/ant-sdk/antd-go"
)
func main() {
client := antd.NewClient(antd.DefaultBaseURL)
ctx := context.Background()
health, err := client.Health(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(health.OK)
discoveredClient, url := antd.NewClientAutoDiscover()
_ = discoveredClient
fmt.Println(url)
}Expected output:
The SDK also includes a GrpcClient for the antd gRPC endpoint.
Store and retrieve data
For upload examples in this section, start antd in a write-enabled mode first. 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
HealthStatus
antd.HealthStatus
PutResult
antd.PutResult for chunk writes
DataPutPublicResult
antd.DataPutPublicResult
DataPutResult
antd.DataPutResult
FilePutPublicResult
antd.FilePutPublicResult
FilePutResult
antd.FilePutResult
PaymentMode
antd.PaymentMode
UploadCostEstimate
antd.UploadCostEstimate
WalletAddress
antd.WalletAddress
WalletBalance
antd.WalletBalance
PrepareUploadResult
antd.PrepareUploadResult
FinalizeUploadResult
antd.FinalizeUploadResult
PrepareChunkResult
antd.PrepareChunkResult
Raw data
[]byte
PrepareChunkResult is returned by PrepareChunkUpload. When AlreadyStored is true, only Address and AlreadyStored are populated and there is no payment to make or finalize call to issue. Otherwise, UploadID, Payments, and TotalAmount describe the external-signer payment required before calling FinalizeChunkUpload.
Error handling
An address with no stored data returns *antd.NotFoundError. Match typed errors with errors.As.
Output when the valid address is not stored:
External-signer finalize methods return *antd.PartialUploadError 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