# C\#

The C# SDK is an async .NET 8 client for `antd` with both REST and gRPC transports.

## Install

```bash
cd antd-csharp
dotnet build Antd.sln
```

## Connect to the daemon

```csharp
using Antd.Sdk;

using var client = AntdClient.CreateRest(baseUrl: "http://localhost:8082");
var health = await client.HealthAsync();
Console.WriteLine(health.Network);
```

## Store and retrieve data

```csharp
using System.Text;
using Antd.Sdk;

using var client = AntdClient.CreateRest();
var result = await client.DataPutPublicAsync(Encoding.UTF8.GetBytes("Hello, Autonomi!"));
Console.WriteLine(result.Address);

var data = await client.DataGetPublicAsync(result.Address);
Console.WriteLine(Encoding.UTF8.GetString(data));
```

## Type mappings

| Autonomi type  | C# type        |
| -------------- | -------------- |
| `HealthStatus` | `HealthStatus` |
| `PutResult`    | `PutResult`    |
| Raw data       | `byte[]`       |

## Error handling

```csharp
try
{
    var data = await client.DataGetPublicAsync("nonexistent");
}
catch (NotFoundException)
{
    Console.WriteLine("Data not found");
}
catch (PaymentException)
{
    Console.WriteLine("Insufficient funds");
}
catch (AntdException ex)
{
    Console.WriteLine(ex.Message);
}
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.autonomi.com/developers/sdk/install/reference/language-bindings/csharp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
