-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllms-full.txt
More file actions
1320 lines (959 loc) · 42.3 KB
/
llms-full.txt
File metadata and controls
1320 lines (959 loc) · 42.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# antd SDK — Complete API Reference
> JavaScript/TypeScript, Python, C#, Kotlin, Swift, Go, Java, Rust, C++, Ruby, PHP, Dart, Lua, Elixir, and Zig SDKs for the Autonomi network via the antd daemon. The daemon manages wallet, payments, and network connectivity. Clients connect over REST (default port 8082) or gRPC (default port 50051). All SDKs support automatic port discovery.
## Port Discovery
All SDKs can automatically discover a running antd daemon. On startup, antd writes a `daemon.port` file containing the REST port (line 1) and gRPC port (line 2) to a platform-specific location:
- **Windows:** `%APPDATA%\ant\daemon.port`
- **Linux:** `$XDG_DATA_HOME/ant/daemon.port` (or `~/.local/share/ant/daemon.port`)
- **macOS:** `~/Library/Application Support/ant/daemon.port`
Every SDK provides auto-discover constructors that read this file and connect automatically, falling back to the default ports if no file is found:
| Language | REST Auto-Discover | gRPC Auto-Discover |
|----------|-------------------|-------------------|
| Python | `RestClient.auto_discover()` | `GrpcClient.auto_discover()` |
| Go | `antd.NewClientAutoDiscover()` | `antd.NewGrpcClientAutoDiscover()` |
| TypeScript | `RestClient.autoDiscover()` | N/A |
| C# | `AntdRestClient.AutoDiscover()` | `AntdGrpcClient.AutoDiscover()` |
| Java | `AntdClient.autoDiscover()` | `GrpcAntdClient.autoDiscover()` |
| Rust | `Client::auto_discover()` | `GrpcClient::auto_discover()` |
| Kotlin | `AntdRestClient.autoDiscover()` | `AntdGrpcClient.autoDiscover()` |
| C++ | `Client::auto_discover()` | `GrpcClient::auto_discover()` |
| Dart | `AntdClient.autoDiscover()` | `GrpcAntdClient.autoDiscover()` |
| Elixir | `Antd.Client.auto_discover()` | `Antd.GrpcClient.auto_discover()` |
| Ruby | `Antd::Client.auto_discover` | `Antd::GrpcClient.auto_discover` |
| Swift | `DaemonDiscovery.autoDiscover()` | `DaemonDiscovery.autoDiscoverGrpc()` |
| PHP | `AntdClient::autoDiscover()` | N/A |
| Lua | `Client.auto_discover()` | N/A |
| Zig | `Client.autoDiscover(allocator)` | N/A |
This is especially useful when antd is spawned with `--rest-port 0` (OS assigns a free port), as in managed mode.
## Quick Start
```python
from antd import AntdClient
client = AntdClient() # REST, localhost:8082
client = AntdClient(transport="grpc") # gRPC, localhost:50051
client = AntdClient(base_url="http://remote:8082")
# Store and retrieve data (payment_mode defaults to "auto")
result = client.data_put_public(b"hello world")
print(result.address, result.cost)
data = client.data_get_public(result.address) # b"hello world"
# Explicit payment mode for large uploads
result = client.data_put_public(large_data, payment_mode="merkle")
```
```typescript
import { createClient } from "antd";
const client = createClient(); // REST, localhost:8082
const client = createClient({ baseUrl: "http://remote:8082" });
const result = await client.dataPutPublic(Buffer.from("hello"));
const data = await client.dataGetPublic(result.address);
```
```csharp
using Antd.Sdk;
var client = AntdClientFactory.CreateRest(); // REST, localhost:8082
var client = AntdClientFactory.CreateGrpc(); // gRPC, localhost:50051
var result = await client.DataPutPublicAsync(Encoding.UTF8.GetBytes("hello"));
var data = await client.DataGetPublicAsync(result.Address);
```
```kotlin
import com.autonomi.sdk.*
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
val client = AntdClient.createRest() // REST, localhost:8082
val client = AntdClient.createGrpc() // gRPC, localhost:50051
val result = client.dataPutPublic("hello".toByteArray())
val data = client.dataGetPublic(result.address)
}
```
```swift
// Swift (macOS only — iOS apps should use the FFI bindings)
import AntdSdk
let client = try AntdClient.createRest() // REST, localhost:8082
let client = try AntdClient.createGrpc() // gRPC, localhost:50051
let result = try await client.dataPutPublic("hello".data(using: .utf8)!)
let data = try await client.dataGetPublic(address: result.address)
```
```go
// Go
import antd "github.com/WithAutonomi/ant-sdk/antd-go"
client := antd.NewClient(antd.DefaultBaseURL) // REST, localhost:8082
ctx := context.Background()
result, _ := client.DataPutPublic(ctx, []byte("hello"))
data, _ := client.DataGetPublic(ctx, result.Address)
```
```java
// Java — Gradle: implementation("com.autonomi:antd-java:0.1.0")
// Maven: <dependency><groupId>com.autonomi</groupId><artifactId>antd-java</artifactId><version>0.1.0</version></dependency>
import com.autonomi.antd.AntdClient;
try (AntdClient client = AntdClient.create()) { // REST, localhost:8082
PutResult result = client.dataPutPublic("hello".getBytes());
byte[] data = client.dataGetPublic(result.address());
}
```
```rust
// Rust — cargo add antd-client
use antd_client::Client;
#[tokio::main]
async fn main() -> Result<(), antd_client::AntdError> {
let client = Client::new("http://localhost:8082"); // REST, localhost:8082
let result = client.data_put_public(b"hello").await?;
let data = client.data_get_public(&result.address).await?;
Ok(())
}
```
```cpp
// C++ — CMake FetchContent from GitHub
#include <antd/antd.hpp>
antd::Client client; // REST, localhost:8082
antd::Client client("http://remote:8082");
auto result = client.dataPutPublic("hello");
auto data = client.dataGetPublic(result.address);
```
```ruby
# Ruby — gem install antd
require "antd"
client = Antd::Client.new # REST, localhost:8082
client = Antd::Client.new(base_url: "http://remote:8082")
result = client.data_put_public("hello")
data = client.data_get_public(result.address)
```
```php
// PHP — composer require autonomi/antd
<?php
use Autonomi\AntdClient;
$client = AntdClient::create(); // REST, localhost:8082
$client = AntdClient::create("http://remote:8082");
$result = $client->dataPutPublic("hello");
$data = $client->dataGetPublic($result->address);
```
```dart
// Dart — dart pub add antd
import 'package:antd/antd.dart';
final client = AntdClient(); // REST, localhost:8082
final client = AntdClient(baseUrl: 'http://remote:8082');
final result = await client.dataPutPublic('hello'.codeUnits);
final data = await client.dataGetPublic(result.address);
```
```lua
-- Lua — luarocks install antd
local antd = require("antd")
local client = antd.Client.new() -- REST, localhost:8082
local client = antd.Client.new({base_url = "http://remote:8082"})
local result = client:data_put_public("hello")
local data = client:data_get_public(result.address)
```
```elixir
# Elixir — {:antd, "~> 0.1"} in mix.exs deps
client = Antd.Client.new() # REST, localhost:8082
client = Antd.Client.new(base_url: "http://remote:8082")
{:ok, result} = Antd.Client.data_put_public(client, "hello")
{:ok, data} = Antd.Client.data_get_public(client, result.address)
```
```zig
// Zig — add dependency in build.zig.zon
const antd = @import("antd");
var client = try antd.Client.init(.{}); // REST, localhost:8082
defer client.deinit();
const result = try client.dataPutPublic("hello");
const data = try client.dataGetPublic(result.address);
```
---
## REST API — All Endpoints
### Health
#### `GET /health`
Returns daemon health and network name.
Response: `{"status": "ok", "network": "local"}`
### Data
#### `POST /v1/data/public`
Store public (unencrypted) data on the network.
Request: `{"data": "<base64>", "payment_mode": "auto"}` (payment_mode is optional, defaults to "auto")
Response: `{"cost": "<atto_tokens>", "address": "<hex>"}`
#### `GET /v1/data/public/{addr}`
Retrieve public data by hex address.
Response: `{"data": "<base64>"}`
#### `GET /v1/data/public/{addr}/stream`
Stream public data as chunked response. Same path params as above.
#### `POST /v1/data/private`
Store private (encrypted) data. Returns a data map instead of address.
Request: `{"data": "<base64>", "payment_mode": "auto"}` (payment_mode is optional, defaults to "auto")
Response: `{"cost": "<atto_tokens>", "data_map": "<hex>"}`
#### `GET /v1/data/private`
Retrieve private data using data map.
Query params: `data_map=<hex>`
Response: `{"data": "<base64>"}`
#### `POST /v1/data/cost`
Estimate cost to store data.
Request: `{"data": "<base64>"}`
Response: `{"cost": "<atto_tokens>"}`
### Chunks
#### `POST /v1/chunks`
Store a raw chunk.
Request: `{"data": "<base64>"}`
Response: `{"cost": "<atto_tokens>", "address": "<hex>"}`
#### `GET /v1/chunks/{addr}`
Retrieve a raw chunk by hex address.
Response: `{"data": "<base64>"}`
### Files
Upload and download files/directories from the local filesystem.
#### `POST /v1/files/upload/public`
Upload a local file.
Request: `{"path": "/absolute/path/to/file", "payment_mode": "auto"}` (payment_mode is optional, defaults to "auto")
Response: `{"cost": "<atto_tokens>", "address": "<hex>"}`
#### `POST /v1/files/download/public`
Download a file to a local path.
Request: `{"address": "<hex>", "dest_path": "/absolute/path"}`
#### `POST /v1/dirs/upload/public`
Upload a local directory (recursively).
Request: `{"path": "/absolute/path/to/dir", "payment_mode": "auto"}` (payment_mode is optional, defaults to "auto")
Response: `{"cost": "<atto_tokens>", "address": "<hex>"}`
#### `POST /v1/dirs/download/public`
Download a directory to a local path.
Request: `{"address": "<hex>", "dest_path": "/absolute/path"}`
#### `POST /v1/cost/file`
Estimate file upload cost.
Request: `{"path": "/path/to/file", "is_public": true}`
Response: `{"cost": "<atto_tokens>"}`
#### `GET /v1/wallet/address`
Get the wallet's public address.
Response: `{"address": "0x..."}`
Returns 400 if no wallet is configured.
#### `GET /v1/wallet/balance`
Get the wallet's token and gas balances.
Response: `{"balance": "<atto_tokens>", "gas_balance": "<atto_tokens>"}`
Returns 400 if no wallet is configured.
#### `POST /v1/wallet/approve`
Approve the wallet to spend tokens on payment contracts (one-time operation before any storage).
Request: `{}` (empty body)
Response: `{"approved": true}`
Returns 400 if no wallet is configured.
#### `POST /v1/data/prepare`
Prepare a data upload for external signing (two-phase upload). Instead of antd paying
from its built-in wallet, this returns payment details for an external signer.
Request: `{"data": "base64-encoded-bytes"}`
The response includes a `payment_type` discriminator that determines the payment flow:
**Wave-batch response** (< 64 chunks — call `payForQuotes()`, finalize with `tx_hashes`):
```json
{
"upload_id": "hex-string",
"payment_type": "wave_batch",
"payments": [
{ "quote_hash": "0x...", "rewards_address": "0x...", "amount": "123" }
],
"total_amount": "456",
"payment_vault_address": "0x...",
"payment_token_address": "0x...",
"rpc_url": "http://..."
}
```
**Merkle response** (>= 64 chunks — call `payForMerkleTree()`, finalize with `winner_pool_hash`):
```json
{
"upload_id": "hex-string",
"payment_type": "merkle",
"depth": 5,
"pool_commitments": [
{
"pool_hash": "0x...",
"candidates": [
{ "rewards_address": "0x...", "amount": "1000" }
]
}
],
"merkle_payment_timestamp": 1712150400,
"payment_vault_address": "0x...",
"total_amount": "0",
"payment_token_address": "0x...",
"rpc_url": "http://..."
}
```
#### `POST /v1/upload/prepare`
Prepare a file upload for external signing. Same response format as `/v1/data/prepare`.
Request: `{"path": "/path/to/file"}`
#### `POST /v1/upload/finalize`
Finalize an upload after an external signer has submitted payment on-chain.
Provide either `tx_hashes` (wave_batch) or `winner_pool_hash` (merkle).
Wave-batch request: `{"upload_id": "hex", "tx_hashes": {"0xquotehash": "0xtxhash", ...}}`
Merkle request: `{"upload_id": "hex", "winner_pool_hash": "0x..."}`
Response: `{"data_map": "hex", "address": "hex", "chunks_stored": 5}`
---
## gRPC API — All Services
Default target: `localhost:50051`. Package: `antd.v1`.
### HealthService (health.proto)
- `Check(HealthCheckRequest) → HealthCheckResponse` — returns status and network name
### DataService (data.proto)
- `GetPublic(GetPublicDataRequest{address}) → GetPublicDataResponse{data: bytes}`
- `PutPublic(PutPublicDataRequest{data: bytes}) → PutPublicDataResponse{cost, address}`
- `StreamPublic(StreamPublicDataRequest{address}) → stream DataChunk{data: bytes}`
- `GetPrivate(GetPrivateDataRequest{data_map}) → GetPrivateDataResponse{data: bytes}`
- `PutPrivate(PutPrivateDataRequest{data: bytes}) → PutPrivateDataResponse{cost, data_map}`
- `GetCost(DataCostRequest{data: bytes}) → Cost{atto_tokens}`
### ChunkService (chunks.proto)
- `Get(GetChunkRequest{address}) → GetChunkResponse{data: bytes}`
- `Put(PutChunkRequest{data: bytes}) → PutChunkResponse{cost, address}`
### FileService (files.proto)
- `UploadPublic(UploadFileRequest{path}) → UploadPublicResponse{cost, address}`
- `DownloadPublic(DownloadPublicRequest{address, dest_path}) → DownloadResponse{}`
- `DirUploadPublic(UploadFileRequest{path}) → UploadPublicResponse{cost, address}`
- `DirDownloadPublic(DownloadPublicRequest{address, dest_path}) → DownloadResponse{}`
- `GetFileCost(FileCostRequest{path, is_public}) → Cost{atto_tokens}`
### EventService (events.proto)
- `Subscribe(SubscribeRequest{}) → stream ClientEventProto{kind, records_paid, records_already_paid, tokens_spent}`
### SDKs with gRPC support
Go, Python, C#, Kotlin, Swift, Rust, Java, C++, Dart, Ruby, Elixir (11 of 15 SDKs).
JS/TS, PHP, Lua, and Zig are REST-only.
---
## Model Types
### Common (both SDKs)
| Type | Fields | Description |
|------|--------|-------------|
| HealthStatus | ok: bool, network: string | Health check result |
| PutResult | cost: string, address: string | Result from any create/put operation |
---
## Payment Modes
All data and file upload operations accept an optional `payment_mode` parameter that controls how storage payments are batched:
| Mode | Behavior |
|------|----------|
| `"auto"` (default) | Uses merkle batch payments for uploads of 64+ chunks, single payments otherwise. Best for general use. |
| `"merkle"` | Forces merkle batch payments regardless of chunk count (minimum 2 chunks). Saves gas on larger uploads. |
| `"single"` | Forces per-chunk payments. Useful for small data or debugging. |
This applies to all PUT endpoints (`data_put_public`, `data_put_private`, `file_upload_public`, `dir_upload_public`) across all SDKs. The parameter is always optional and defaults to `"auto"`.
**REST:** Include `"payment_mode": "merkle"` in the JSON request body.
**SDK examples:**
```python
# Python
result = client.data_put_public(data, payment_mode="merkle")
```
```go
// Go
result, err := client.DataPutPublic(ctx, data, antd.WithPaymentMode("merkle"))
```
```typescript
// TypeScript
const result = await client.dataPutPublic(data, { paymentMode: "merkle" });
```
---
## JS/TS SDK Method Signatures
```typescript
import { createClient } from "antd";
const client = createClient(); // REST, localhost:8082
const client = createClient({ baseUrl: "http://remote:8082" }); // custom URL
const client = createClient({ timeout: 60_000 }); // custom timeout (ms)
// Health
client.health(): Promise<HealthStatus>
// Data
client.dataPutPublic(data: Buffer): Promise<PutResult>
client.dataGetPublic(address: string): Promise<Buffer>
client.dataPutPrivate(data: Buffer): Promise<PutResult> // .address is the data_map
client.dataGetPrivate(dataMap: string): Promise<Buffer>
client.dataCost(data: Buffer): Promise<string>
// Chunks
client.chunkPut(data: Buffer): Promise<PutResult>
client.chunkGet(address: string): Promise<Buffer>
// Files
client.fileUploadPublic(path: string): Promise<PutResult>
client.fileDownloadPublic(address: string, destPath: string): Promise<void>
client.dirUploadPublic(path: string): Promise<PutResult>
client.dirDownloadPublic(address: string, destPath: string): Promise<void>
client.fileCost(path: string, isPublic?: boolean): Promise<string>
// Wallet
client.walletAddress(): Promise<WalletAddress>
client.walletBalance(): Promise<WalletBalance>
client.walletApprove(): Promise<boolean>
```
---
## Python SDK Method Signatures
```python
from antd import AntdClient, AsyncAntdClient
client = AntdClient(transport="rest", base_url="http://localhost:8082")
client = AntdClient(transport="grpc", target="localhost:50051")
# Health
client.health() → HealthStatus
# Data
client.data_put_public(data: bytes) → PutResult
client.data_get_public(address: str) → bytes
client.data_put_private(data: bytes) → PutResult # .address is the data_map
client.data_get_private(data_map: str) → bytes
client.data_cost(data: bytes) → str
# Chunks
client.chunk_put(data: bytes) → PutResult
client.chunk_get(address: str) → bytes
# Files
client.file_upload_public(path: str) → PutResult
client.file_download_public(address: str, dest_path: str) → None
client.dir_upload_public(path: str) → PutResult
client.dir_download_public(address: str, dest_path: str) → None
client.file_cost(path: str, is_public: bool = True) → str
# Wallet
client.wallet_address() → WalletAddress
client.wallet_balance() → WalletBalance
client.wallet_approve() → bool
```
---
## C# SDK Method Signatures
```csharp
using Antd.Sdk;
IAntdClient client = AntdClientFactory.CreateRest(); // localhost:8082
IAntdClient client = AntdClientFactory.CreateGrpc(); // localhost:50051
// Health
Task<HealthStatus> HealthAsync();
// Data
Task<PutResult> DataPutPublicAsync(byte[] data);
Task<byte[]> DataGetPublicAsync(string address);
Task<PutResult> DataPutPrivateAsync(byte[] data);
Task<byte[]> DataGetPrivateAsync(string dataMap);
Task<string> DataCostAsync(byte[] data);
// Chunks
Task<PutResult> ChunkPutAsync(byte[] data);
Task<byte[]> ChunkGetAsync(string address);
// Files
Task<PutResult> FileUploadPublicAsync(string path);
Task FileDownloadPublicAsync(string address, string destPath);
Task<PutResult> DirUploadPublicAsync(string path);
Task DirDownloadPublicAsync(string address, string destPath);
Task<string> FileCostAsync(string path, bool isPublic = true);
// Wallet
Task<WalletAddress> WalletAddressAsync();
Task<WalletBalance> WalletBalanceAsync();
Task<bool> WalletApproveAsync();
```
---
## Kotlin SDK Method Signatures
```kotlin
import com.autonomi.sdk.*
val client = AntdClient.createRest() // localhost:8082
val client = AntdClient.createGrpc() // localhost:50051
// Health
suspend fun health(): HealthStatus
// Data
suspend fun dataPutPublic(data: ByteArray): PutResult
suspend fun dataGetPublic(address: String): ByteArray
suspend fun dataPutPrivate(data: ByteArray): PutResult
suspend fun dataGetPrivate(dataMap: String): ByteArray
suspend fun dataCost(data: ByteArray): String
// Chunks
suspend fun chunkPut(data: ByteArray): PutResult
suspend fun chunkGet(address: String): ByteArray
// Files
suspend fun fileUploadPublic(path: String): PutResult
suspend fun fileDownloadPublic(address: String, destPath: String)
suspend fun dirUploadPublic(path: String): PutResult
suspend fun dirDownloadPublic(address: String, destPath: String)
suspend fun fileCost(path: String, isPublic: Boolean = true): String
// Wallet
suspend fun walletAddress(): WalletAddress
suspend fun walletBalance(): WalletBalance
suspend fun walletApprove(): Boolean
```
---
## Swift SDK Method Signatures
> REST/gRPC transport requires macOS. For iOS, use the FFI bindings.
```swift
import AntdSdk
let client = try AntdClient.createRest() // localhost:8082
let client = try AntdClient.createGrpc() // localhost:50051
// Health
func health() async throws -> HealthStatus
// Data
func dataPutPublic(_ data: Data) async throws -> PutResult
func dataGetPublic(address: String) async throws -> Data
func dataPutPrivate(_ data: Data) async throws -> PutResult
func dataGetPrivate(dataMap: String) async throws -> Data
func dataCost(_ data: Data) async throws -> String
// Chunks
func chunkPut(_ data: Data) async throws -> PutResult
func chunkGet(address: String) async throws -> Data
// Files
func fileUploadPublic(path: String) async throws -> PutResult
func fileDownloadPublic(address: String, destPath: String) async throws
func dirUploadPublic(path: String) async throws -> PutResult
func dirDownloadPublic(address: String, destPath: String) async throws
func fileCost(path: String, isPublic: Bool) async throws -> String
// Wallet
func walletAddress() async throws -> WalletAddress
func walletBalance() async throws -> WalletBalance
func walletApprove() async throws -> Bool
```
---
## Go SDK Method Signatures
```go
import antd "github.com/WithAutonomi/ant-sdk/antd-go"
client := antd.NewClient(antd.DefaultBaseURL) // localhost:8082
// Health
func (c *Client) Health(ctx context.Context) (*HealthStatus, error)
// Data
func (c *Client) DataPutPublic(ctx context.Context, data []byte) (*PutResult, error)
func (c *Client) DataGetPublic(ctx context.Context, address string) ([]byte, error)
func (c *Client) DataPutPrivate(ctx context.Context, data []byte) (*PutResult, error)
func (c *Client) DataGetPrivate(ctx context.Context, dataMap string) ([]byte, error)
func (c *Client) DataCost(ctx context.Context, data []byte) (string, error)
// Chunks
func (c *Client) ChunkPut(ctx context.Context, data []byte) (*PutResult, error)
func (c *Client) ChunkGet(ctx context.Context, address string) ([]byte, error)
// Files
func (c *Client) FileUploadPublic(ctx context.Context, path string) (*PutResult, error)
func (c *Client) FileDownloadPublic(ctx context.Context, address string, destPath string) error
func (c *Client) DirUploadPublic(ctx context.Context, path string) (*PutResult, error)
func (c *Client) DirDownloadPublic(ctx context.Context, address string, destPath string) error
func (c *Client) FileCost(ctx context.Context, path string, isPublic bool) (string, error)
// Wallet
func (c *Client) WalletAddress(ctx context.Context) (*WalletAddress, error)
func (c *Client) WalletBalance(ctx context.Context) (*WalletBalance, error)
func (c *Client) WalletApprove(ctx context.Context) error
```
---
## Java SDK Method Signatures
```java
// Gradle: implementation("com.autonomi:antd-java:0.1.0")
// Maven: <dependency><groupId>com.autonomi</groupId><artifactId>antd-java</artifactId><version>0.1.0</version></dependency>
import com.autonomi.antd.AntdClient;
AntdClient client = AntdClient.create(); // REST, localhost:8082
AntdClient client = AntdClient.create("http://remote:8082");
// Health
HealthStatus health() throws AntdException
// Data
PutResult dataPutPublic(byte[] data) throws AntdException
byte[] dataGetPublic(String address) throws AntdException
PutResult dataPutPrivate(byte[] data) throws AntdException // .address() is the data_map
byte[] dataGetPrivate(String dataMap) throws AntdException
String dataCost(byte[] data) throws AntdException
// Chunks
PutResult chunkPut(byte[] data) throws AntdException
byte[] chunkGet(String address) throws AntdException
// Files
PutResult fileUploadPublic(String path) throws AntdException
void fileDownloadPublic(String address, String destPath) throws AntdException
PutResult dirUploadPublic(String path) throws AntdException
void dirDownloadPublic(String address, String destPath) throws AntdException
String fileCost(String path, boolean isPublic) throws AntdException
// Wallet
WalletAddress walletAddress() throws AntdException
WalletBalance walletBalance() throws AntdException
boolean walletApprove() throws AntdException
// AntdClient implements AutoCloseable — use try-with-resources
```
---
## Rust SDK Method Signatures
```rust
// cargo add antd-client
use antd_client::{Client, PutResult, HealthStatus, AntdError};
let client = Client::new("http://localhost:8082"); // REST, localhost:8082
// Health
async fn health(&self) -> Result<HealthStatus, AntdError>
// Data
async fn data_put_public(&self, data: &[u8]) -> Result<PutResult, AntdError>
async fn data_get_public(&self, address: &str) -> Result<Vec<u8>, AntdError>
async fn data_put_private(&self, data: &[u8]) -> Result<PutResult, AntdError> // .address is the data_map
async fn data_get_private(&self, data_map: &str) -> Result<Vec<u8>, AntdError>
async fn data_cost(&self, data: &[u8]) -> Result<String, AntdError>
// Chunks
async fn chunk_put(&self, data: &[u8]) -> Result<PutResult, AntdError>
async fn chunk_get(&self, address: &str) -> Result<Vec<u8>, AntdError>
// Files
async fn file_upload_public(&self, path: &str) -> Result<PutResult, AntdError>
async fn file_download_public(&self, address: &str, dest_path: &str) -> Result<(), AntdError>
async fn dir_upload_public(&self, path: &str) -> Result<PutResult, AntdError>
async fn dir_download_public(&self, address: &str, dest_path: &str) -> Result<(), AntdError>
async fn file_cost(&self, path: &str, is_public: bool) -> Result<String, AntdError>
// Wallet
async fn wallet_address(&self) -> Result<WalletAddress, AntdError>
async fn wallet_balance(&self) -> Result<WalletBalance, AntdError>
async fn wallet_approve(&self) -> Result<bool, AntdError>
// AntdError variants: BadRequest, Payment, NotFound, AlreadyExists, Fork, TooLarge, Internal, Network
```
---
## C++ SDK Method Signatures
```cpp
// CMake FetchContent from GitHub
#include <antd/antd.hpp>
antd::Client client; // REST, localhost:8082
antd::Client client("http://remote:8082");
// Health
antd::HealthStatus health() // throws antd::AntdError
// Data
antd::PutResult dataPutPublic(const std::vector<uint8_t>& data)
std::vector<uint8_t> dataGetPublic(const std::string& address)
antd::PutResult dataPutPrivate(const std::vector<uint8_t>& data) // .address is the data_map
std::vector<uint8_t> dataGetPrivate(const std::string& dataMap)
std::string dataCost(const std::vector<uint8_t>& data)
// Chunks
antd::PutResult chunkPut(const std::vector<uint8_t>& data)
std::vector<uint8_t> chunkGet(const std::string& address)
// Files
antd::PutResult fileUploadPublic(const std::string& path)
void fileDownloadPublic(const std::string& address, const std::string& destPath)
antd::PutResult dirUploadPublic(const std::string& path)
void dirDownloadPublic(const std::string& address, const std::string& destPath)
std::string fileCost(const std::string& path, bool isPublic = true)
// Wallet
antd::WalletAddress walletAddress()
antd::WalletBalance walletBalance()
bool walletApprove()
// All methods throw antd::AntdError or subclasses: BadRequestError, PaymentError, NotFoundError,
// AlreadyExistsError, ForkError, TooLargeError, InternalError, NetworkError
```
---
## Ruby SDK Method Signatures
```ruby
require "antd"
client = Antd::Client.new # localhost:8082
client = Antd::Client.new(base_url: "http://remote:8082")
# Health
client.health → HealthStatus
# Data
client.data_put_public(data) → PutResult
client.data_get_public(address) → String
client.data_put_private(data) → PutResult # .address is the data_map
client.data_get_private(data_map) → String
client.data_cost(data) → String
# Chunks
client.chunk_put(data) → PutResult
client.chunk_get(address) → String
# Files
client.file_upload_public(path) → PutResult
client.file_download_public(address, dest_path) → nil
client.dir_upload_public(path) → PutResult
client.dir_download_public(address, dest_path) → nil
client.file_cost(path, is_public: true) → String
# Wallet
client.wallet_address → WalletAddress
client.wallet_balance → WalletBalance
client.wallet_approve → Boolean
```
---
## PHP SDK Method Signatures
```php
use Autonomi\AntdClient;
$client = AntdClient::create(); // localhost:8082
$client = AntdClient::create("http://remote:8082");
// Health
$client->health(): HealthStatus
// Data
$client->dataPutPublic(string $data): PutResult
$client->dataGetPublic(string $address): string
$client->dataPutPrivate(string $data): PutResult // ->address is the data_map
$client->dataGetPrivate(string $dataMap): string
$client->dataCost(string $data): string
// Chunks
$client->chunkPut(string $data): PutResult
$client->chunkGet(string $address): string
// Files
$client->fileUploadPublic(string $path): PutResult
$client->fileDownloadPublic(string $address, string $destPath): void
$client->dirUploadPublic(string $path): PutResult
$client->dirDownloadPublic(string $address, string $destPath): void
$client->fileCost(string $path, bool $isPublic = true): string
// Wallet
$client->walletAddress(): array{address: string}
$client->walletBalance(): array{balance: string, gas_balance: string}
$client->walletApprove(): bool
```
---
## Dart SDK Method Signatures
```dart
import 'package:antd/antd.dart';
final client = AntdClient(); // localhost:8082
final client = AntdClient(baseUrl: 'http://remote:8082');
// Health
Future<HealthStatus> health()
// Data
Future<PutResult> dataPutPublic(List<int> data)
Future<List<int>> dataGetPublic(String address)
Future<PutResult> dataPutPrivate(List<int> data) // .address is the data_map
Future<List<int>> dataGetPrivate(String dataMap)
Future<String> dataCost(List<int> data)
// Chunks
Future<PutResult> chunkPut(List<int> data)
Future<List<int>> chunkGet(String address)
// Files
Future<PutResult> fileUploadPublic(String path)
Future<void> fileDownloadPublic(String address, String destPath)
Future<PutResult> dirUploadPublic(String path)
Future<void> dirDownloadPublic(String address, String destPath)
Future<String> fileCost(String path, {bool isPublic = true})
// Wallet
Future<WalletAddress> walletAddress()
Future<WalletBalance> walletBalance()
Future<bool> walletApprove()
```
---
## Lua SDK Method Signatures
```lua
local antd = require("antd")
local client = antd.Client.new() -- localhost:8082
local client = antd.Client.new({base_url = "http://remote:8082"})
-- Health
client:health() → HealthStatus
-- Data
client:data_put_public(data) → PutResult
client:data_get_public(address) → string
client:data_put_private(data) → PutResult -- .address is the data_map
client:data_get_private(data_map) → string
client:data_cost(data) → string
-- Chunks
client:chunk_put(data) → PutResult
client:chunk_get(address) → string
-- Files
client:file_upload_public(path) → PutResult
client:file_download_public(address, dest_path) → nil
client:dir_upload_public(path) → PutResult
client:dir_download_public(address, dest_path) → nil
client:file_cost(path, is_public) → string
-- Wallet
client:wallet_address() → {address=string}
client:wallet_balance() → {balance=string, gas_balance=string}
client:wallet_approve() → boolean
```
---
## Elixir SDK Method Signatures
```elixir
client = Antd.Client.new() # localhost:8082
client = Antd.Client.new(base_url: "http://remote:8082")
# Health
Antd.Client.health(client) :: {:ok, HealthStatus.t()} | {:error, term()}
# Data
Antd.Client.data_put_public(client, data) :: {:ok, PutResult.t()} | {:error, term()}
Antd.Client.data_get_public(client, address) :: {:ok, binary()} | {:error, term()}
Antd.Client.data_put_private(client, data) :: {:ok, PutResult.t()} | {:error, term()}
Antd.Client.data_get_private(client, data_map) :: {:ok, binary()} | {:error, term()}
Antd.Client.data_cost(client, data) :: {:ok, String.t()} | {:error, term()}
# Chunks
Antd.Client.chunk_put(client, data) :: {:ok, PutResult.t()} | {:error, term()}
Antd.Client.chunk_get(client, address) :: {:ok, binary()} | {:error, term()}
# Files
Antd.Client.file_upload_public(client, path) :: {:ok, PutResult.t()} | {:error, term()}
Antd.Client.file_download_public(client, address, dest_path) :: :ok | {:error, term()}
Antd.Client.dir_upload_public(client, path) :: {:ok, PutResult.t()} | {:error, term()}
Antd.Client.dir_download_public(client, address, dest_path) :: :ok | {:error, term()}
Antd.Client.file_cost(client, path, is_public \\ true) :: {:ok, String.t()} | {:error, term()}