@ar.io/sdk 1.2.0-alpha.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +914 -70
- package/bundles/web.bundle.min.js +76 -76
- package/lib/cjs/common/ant-ao.js +11 -4
- package/lib/cjs/common/contracts/ao-process.js +16 -5
- package/lib/cjs/common/io.js +95 -100
- package/lib/cjs/constants.js +7 -4
- package/lib/cjs/utils/graphql/processes.js +87 -7
- package/lib/cjs/utils/index.js +1 -0
- package/lib/cjs/utils/json.js +28 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant-ao.js +11 -4
- package/lib/esm/common/contracts/ao-process.js +16 -5
- package/lib/esm/common/io.js +95 -100
- package/lib/esm/constants.js +6 -3
- package/lib/esm/utils/graphql/processes.js +85 -6
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/json.js +24 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant-ao.d.ts +2 -1
- package/lib/types/common/io.d.ts +11 -4
- package/lib/types/constants.d.ts +4 -2
- package/lib/types/io.d.ts +29 -3
- package/lib/types/utils/graphql/processes.d.ts +30 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/json.d.ts +17 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -15,22 +15,22 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
15
15
|
- [Typescript](#typescript)
|
|
16
16
|
- [IOToken & mIOToken](#iotoken--miotoken)
|
|
17
17
|
- [Converting IO to mIO](#converting-io-to-mio)
|
|
18
|
-
- [
|
|
18
|
+
- [IO Process](#io-process)
|
|
19
19
|
|
|
20
|
-
- [APIs](#apis)
|
|
20
|
+
- [IO APIs](#apis)
|
|
21
21
|
- [`init({ signer })`](#init-signer-)
|
|
22
|
-
- [`
|
|
23
|
-
- [`getBalance({ address
|
|
24
|
-
- [`getBalances(
|
|
25
|
-
- [`getGateway({ address
|
|
26
|
-
- [`getGateways(
|
|
27
|
-
- [`getArNSRecord({
|
|
28
|
-
- [`getArNSRecords(
|
|
29
|
-
- [`getObservations({
|
|
30
|
-
- [`getDistributions({
|
|
31
|
-
- [`getEpoch({
|
|
32
|
-
- [`getCurrentEpoch(
|
|
33
|
-
- [`getPrescribedObservers({
|
|
22
|
+
- [`getInfo()`](#getinfo)
|
|
23
|
+
- [`getBalance({ address })`](#getbalance-address-)
|
|
24
|
+
- [`getBalances()`](#getbalances)
|
|
25
|
+
- [`getGateway({ address })`](#getgateway-address-)
|
|
26
|
+
- [`getGateways()`](#getgateways)
|
|
27
|
+
- [`getArNSRecord({ name })`](#getarnsrecord-name-)
|
|
28
|
+
- [`getArNSRecords()`](#getarnsrecords)
|
|
29
|
+
- [`getObservations({ epochIndex })`](#getobservations-epochindex-)
|
|
30
|
+
- [`getDistributions({ epochIndex })`](#getdistributions-epochindex-)
|
|
31
|
+
- [`getEpoch({ epochIndex })`](#getepoch-epochindex-)
|
|
32
|
+
- [`getCurrentEpoch()`](#getcurrentepoch)
|
|
33
|
+
- [`getPrescribedObservers({ epochIndex })`](#getprescribedobservers-epochindex-)
|
|
34
34
|
- [`joinNetwork(params)`](#joinnetworkparams)
|
|
35
35
|
- [`updateGatewaySettings(gatewaySettings)`](#updategatewaysettingsgatewaysettings)
|
|
36
36
|
- [`increaseDelegateStake({ target, qty })`](#increasedelegatestake-target-qty-)
|
|
@@ -39,20 +39,20 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
39
39
|
- [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
|
|
40
40
|
- [`saveObservations({ reportTxId, failedGateways })`](#saveobservations-reporttxid-failedgateways-)
|
|
41
41
|
- [`transfer({ target, qty, denomination })`](#transfer-target-qty-denomination-)
|
|
42
|
-
- [
|
|
42
|
+
- [Configuration](#custom-configuration)
|
|
43
43
|
|
|
44
44
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
45
|
-
- [APIs](#apis
|
|
46
|
-
- [`init({ signer
|
|
47
|
-
- [`
|
|
48
|
-
- [`getOwner(
|
|
49
|
-
- [`getControllers(
|
|
50
|
-
- [`getRecords(
|
|
45
|
+
- [ANT APIs](#ant-apis)
|
|
46
|
+
- [`init({ signer})`](#init-signer-)
|
|
47
|
+
- [`getInfo()`](#getinfo)
|
|
48
|
+
- [`getOwner()`](#getowner)
|
|
49
|
+
- [`getControllers()`](#getcontrollers)
|
|
50
|
+
- [`getRecords()`](#getrecords)
|
|
51
51
|
- [`transfer({ target })`](#transfer-target-)
|
|
52
52
|
- [`setController({ controller })`](#setcontroller-controller-)
|
|
53
53
|
- [`removeController({ controller })`](#removecontroller-controller-)
|
|
54
|
-
- [`setRecord({
|
|
55
|
-
- [`removeRecord({
|
|
54
|
+
- [`setRecord({ undername, transactionId, ttlSeconds })`](#setrecord-undername-transactionid-ttlseconds-)
|
|
55
|
+
- [`removeRecord({ undername })`](#removerecord-undername-)
|
|
56
56
|
- [`setName({ name })`](#setname-name-)
|
|
57
57
|
- [`setTicker({ ticker })`](#setticker-ticker-)
|
|
58
58
|
- [Configuration](#configuration)
|
|
@@ -85,8 +85,8 @@ yarn add @ar.io/sdk
|
|
|
85
85
|
```typescript
|
|
86
86
|
import { IO } from '@ar.io/sdk';
|
|
87
87
|
|
|
88
|
-
const
|
|
89
|
-
const gateways = await
|
|
88
|
+
const io = IO.init();
|
|
89
|
+
const gateways = await io.getGateways();
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
<details>
|
|
@@ -139,12 +139,12 @@ The SDK is provided in both CommonJS and ESM formats and is compatible with bund
|
|
|
139
139
|
#### Bundlers (Webpack, Rollup, ESbuild, etc.)
|
|
140
140
|
|
|
141
141
|
```javascript
|
|
142
|
-
import { IO } from '@ar.io/sdk';
|
|
142
|
+
import { IO } from '@ar.io/sdk/web';
|
|
143
143
|
|
|
144
144
|
// set up client
|
|
145
|
-
const
|
|
145
|
+
const io = IO.init();
|
|
146
146
|
// fetch gateways
|
|
147
|
-
const gateways = await
|
|
147
|
+
const gateways = await io.getGateways();
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
> _**Note**: polyfills are only provided when using the named `@ar.io/sdk/web` export (which requires `moduleResolution: nodenext` in `tsconfig.json`). If you are using the default export within a Typescript project (e.g. `moduleResolution: node`), you will need to provide your own polyfills - specifically `crypto`, `fs` and `buffer`. Refer to [examples/webpack] and [examples/vite] for references in how to properly provide those polyfills. For other project configurations, refer to your bundler's documentation for more information on how to provide the necessary polyfills._
|
|
@@ -156,9 +156,9 @@ const gateways = await arIO.getGateways();
|
|
|
156
156
|
import { IO } from 'https://unpkg.com/@ar.io/sdk';
|
|
157
157
|
|
|
158
158
|
// set up client
|
|
159
|
-
const
|
|
159
|
+
const io = IO.init();
|
|
160
160
|
// fetch gateways
|
|
161
|
-
const gateways = await
|
|
161
|
+
const gateways = await io.getGateways();
|
|
162
162
|
</script>
|
|
163
163
|
```
|
|
164
164
|
|
|
@@ -170,9 +170,9 @@ const gateways = await arIO.getGateways();
|
|
|
170
170
|
import { IO } from '@ar.io/sdk/node';
|
|
171
171
|
|
|
172
172
|
// set up client
|
|
173
|
-
const
|
|
173
|
+
const io = IO.init();
|
|
174
174
|
// fetch gateways
|
|
175
|
-
const gateways = await
|
|
175
|
+
const gateways = await io.getGateways();
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
#### CJS
|
|
@@ -181,9 +181,9 @@ const gateways = await arIO.getGateways();
|
|
|
181
181
|
import { IO } from '@ar.io/sdk';
|
|
182
182
|
|
|
183
183
|
// set up client
|
|
184
|
-
const
|
|
184
|
+
const io = IO.init();
|
|
185
185
|
// fetch gateways
|
|
186
|
-
const gateways = await
|
|
186
|
+
const gateways = await io.getGateways();
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
### Typescript
|
|
@@ -192,7 +192,7 @@ The SDK provides TypeScript types. When you import the SDK in a TypeScript proje
|
|
|
192
192
|
|
|
193
193
|
## IOToken & mIOToken
|
|
194
194
|
|
|
195
|
-
The
|
|
195
|
+
The IO process stores all values as mIO (milli-IO) to avoid floating-point arithmetic issues. The SDK provides an `IOToken` and `mIOToken` classes to handle the conversion between IO and mIO, along with rounding logic for precision.
|
|
196
196
|
|
|
197
197
|
**All process interactions expect values in mIO. If numbers are provided as inputs, they are assumed to be in raw mIO values.**
|
|
198
198
|
|
|
@@ -210,7 +210,7 @@ const ioValue = new mIOToken(mIOValue).toIO();
|
|
|
210
210
|
console.log(ioValue); // 1 (IO)
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
##
|
|
213
|
+
## IO Process
|
|
214
214
|
|
|
215
215
|
### APIs
|
|
216
216
|
|
|
@@ -219,75 +219,916 @@ console.log(ioValue); // 1 (IO)
|
|
|
219
219
|
Factory function to that creates a read-only or writeable client. By providing a `signer` additional write APIs that require signing, like `joinNetwork` and `delegateStake` are available. By default, a read-only client is returned and no write APIs are available.
|
|
220
220
|
|
|
221
221
|
```typescript
|
|
222
|
-
// read-only client
|
|
223
|
-
const
|
|
222
|
+
// read-only client
|
|
223
|
+
const io = IO.init()
|
|
224
|
+
|
|
225
|
+
// read-write client for browser environments
|
|
226
|
+
const io = IO.init({ signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({}))});
|
|
227
|
+
|
|
228
|
+
// read-write client for node environments
|
|
229
|
+
const io = IO.init({ signer: new ArweaveSigner(JWK) });
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### `getInfo()`
|
|
234
|
+
|
|
235
|
+
Retrieves the information of the IO process.
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const io = IO.init();
|
|
239
|
+
const info = await io.getInfo();
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
<details>
|
|
243
|
+
<summary>Output</summary>
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"name": "Testnet IO",
|
|
248
|
+
"ticker": "tIO",
|
|
249
|
+
"owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
250
|
+
"denomination": "IO"
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
</details>
|
|
255
|
+
|
|
256
|
+
#### `getBalance({ address })`
|
|
257
|
+
|
|
258
|
+
Retrieves the balance of the specified wallet address.
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
const io = IO.init();
|
|
262
|
+
// the balance will be returned in mIO as a value
|
|
263
|
+
const balance = await io
|
|
264
|
+
.getBalance({
|
|
265
|
+
address: 'INSERT_WALLET_ADDRESS',
|
|
266
|
+
})
|
|
267
|
+
.then((balance) => new mIOToken().toIO());
|
|
268
|
+
|
|
269
|
+
console.log(balance.valueOf());
|
|
270
|
+
```
|
|
224
271
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
port: 443,
|
|
228
|
-
protocol: 'https'
|
|
229
|
-
})
|
|
230
|
-
// for browser environments
|
|
231
|
-
const browserSigner = new ArConnectSigner(window.arweaveWallet, arweave);
|
|
232
|
-
const arIOWriteable = IO.init({ signer: browserSigner});
|
|
272
|
+
<details>
|
|
273
|
+
<summary>Output</summary>
|
|
233
274
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
275
|
+
```json
|
|
276
|
+
// value in IO
|
|
277
|
+
1_000_000
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
</details>
|
|
237
281
|
|
|
282
|
+
#### `getBalances()`
|
|
283
|
+
|
|
284
|
+
Retrieves the balances of the IO process in `mIO`
|
|
285
|
+
|
|
286
|
+
<!--
|
|
287
|
+
// ALM - A part of me wonders whether streaming JSON might be beneficial in the future
|
|
288
|
+
// and if providing streaming versions of these APIs will scale nicely longer term, e.g.
|
|
289
|
+
// io.streamBalances({ sortingCriteria: BALANCE_DESC });
|
|
290
|
+
-->
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
const io = IO.init();
|
|
294
|
+
const balances = await io.getBalances();
|
|
238
295
|
```
|
|
239
296
|
|
|
240
|
-
|
|
297
|
+
<details>
|
|
298
|
+
<summary>Output</summary>
|
|
241
299
|
|
|
242
|
-
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"-4xgjroXENKYhTWqrBo57HQwvDL51mMvSxJy6Y2Z_sA": 5000000000, // value in mIO
|
|
303
|
+
"-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck": 5000000000, // value in mIO
|
|
304
|
+
"-9JU3W8g9nOAB1OrJQ8FxkaWCpv5slBET2HppTItbmk": 5000000000 // value in mIO
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
#### `getGateway({ address })`
|
|
311
|
+
|
|
312
|
+
Retrieves a gateway's info by its staking wallet address.
|
|
243
313
|
|
|
244
314
|
```typescript
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
315
|
+
const io = IO.init();
|
|
316
|
+
const gateway = await io.getGateway({
|
|
317
|
+
address: 'INSERT_GATEWAY_ADDRESS',
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
<details>
|
|
322
|
+
<summary>Output</summary>
|
|
323
|
+
|
|
324
|
+
```json
|
|
325
|
+
{
|
|
326
|
+
"end": 0,
|
|
327
|
+
"observerWallet": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
328
|
+
"operatorStake": 250000000000, // value in mIO
|
|
329
|
+
"settings": {
|
|
330
|
+
"fqdn": "ar-io.dev",
|
|
331
|
+
"label": "AR.IO Test",
|
|
332
|
+
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
|
|
333
|
+
"port": 443,
|
|
334
|
+
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
335
|
+
"protocol": "https"
|
|
336
|
+
},
|
|
337
|
+
"start": 1256694,
|
|
338
|
+
"stats": {
|
|
339
|
+
"failedConsecutiveEpochs": 0,
|
|
340
|
+
"passedEpochCount": 30,
|
|
341
|
+
"submittedEpochCount": 30,
|
|
342
|
+
"totalEpochParticipationCount": 31,
|
|
343
|
+
"totalEpochsPrescribedCount": 31
|
|
344
|
+
},
|
|
345
|
+
"status": "joined",
|
|
346
|
+
"vaults": {}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
</details>
|
|
351
|
+
|
|
352
|
+
#### `getGateways()`
|
|
353
|
+
|
|
354
|
+
Retrieves the registered gateways of the IO process.
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
const io = IO.init();
|
|
358
|
+
const gateways = await io.getGateways();
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
<details>
|
|
362
|
+
<summary>Output</summary>
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ": {
|
|
367
|
+
"end": 0,
|
|
368
|
+
"observerWallet": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
369
|
+
"operatorStake": 250000000000, // value in mIO
|
|
370
|
+
"settings": {
|
|
371
|
+
"fqdn": "ar-io.dev",
|
|
372
|
+
"label": "AR.IO Test",
|
|
373
|
+
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
|
|
374
|
+
"port": 443,
|
|
375
|
+
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
376
|
+
"protocol": "https"
|
|
377
|
+
},
|
|
378
|
+
"start": 1256694,
|
|
379
|
+
"stats": {
|
|
380
|
+
"failedConsecutiveEpochs": 0,
|
|
381
|
+
"passedEpochCount": 30,
|
|
382
|
+
"submittedEpochCount": 30,
|
|
383
|
+
"totalEpochParticipationCount": 31,
|
|
384
|
+
"totalEpochsPrescribedCount": 31
|
|
385
|
+
},
|
|
386
|
+
"status": "joined",
|
|
387
|
+
"vaults": {}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
</details>
|
|
393
|
+
|
|
394
|
+
#### `getArNSRecord({ name })`
|
|
395
|
+
|
|
396
|
+
Retrieves the record info of the specified ArNS name.
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
const io = IO.init();
|
|
400
|
+
const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
<details>
|
|
404
|
+
<summary>Output</summary>
|
|
405
|
+
|
|
406
|
+
```json
|
|
407
|
+
{
|
|
408
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
409
|
+
"endTimestamp": 1711122739,
|
|
410
|
+
"startTimestamp": 1694101828,
|
|
411
|
+
"type": "lease",
|
|
412
|
+
"undernames": 100
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
</details>
|
|
417
|
+
|
|
418
|
+
#### `getArNSRecords()`
|
|
419
|
+
|
|
420
|
+
Retrieves all registered ArNS records of the IO process.
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
const io = IO.init();
|
|
424
|
+
const records = await io.getArNSRecords();
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
<details>
|
|
428
|
+
<summary>Output</summary>
|
|
429
|
+
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"ardrive": {
|
|
433
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
434
|
+
"endTimestamp": 1711122739,
|
|
435
|
+
"startTimestamp": 1694101828,
|
|
436
|
+
"type": "lease",
|
|
437
|
+
"undernames": 100
|
|
438
|
+
},
|
|
439
|
+
"ar-io": {
|
|
440
|
+
"processId": "eNey-H9RB9uCdoJUvPULb35qhZVXZcEXv8xds4aHhkQ",
|
|
441
|
+
"purchasePrice": 75541282285, // value in mIO
|
|
442
|
+
"startTimestamp": 1706747215,
|
|
443
|
+
"type": "permabuy",
|
|
444
|
+
"undernames": 10
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
</details>
|
|
450
|
+
|
|
451
|
+
#### `getObservations({ epochIndex })`
|
|
452
|
+
|
|
453
|
+
Returns the epoch-indexed observation list.
|
|
454
|
+
|
|
455
|
+
```typescript
|
|
456
|
+
const io = IO.init();
|
|
457
|
+
const observations = await io.getObservations();
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
<details>
|
|
461
|
+
<summary>Output</summary>
|
|
462
|
+
|
|
463
|
+
```json
|
|
464
|
+
{
|
|
465
|
+
"0": {
|
|
466
|
+
"failureSummaries": {
|
|
467
|
+
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
468
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA",
|
|
469
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA"
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
"reports": {
|
|
473
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": "B6UUjKWjjEWDBvDSMXWNmymfwvgR9EN27z5FTkEVlX4",
|
|
474
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA": "7tKsiQ2fxv0D8ZVN_QEv29fZ8hwFIgHoEDrpeEG0DIs",
|
|
475
|
+
"osZP4D9cqeDvbVFBaEfjIxwc1QLIvRxUBRAxDIX9je8": "aatgznEvC_UPcxp1v0uw_RqydhIfKm4wtt1KCpONBB0",
|
|
476
|
+
"qZ90I67XG68BYIAFVNfm9PUdM7v1XtFTn7u-EOZFAtk": "Bd8SmFK9-ktJRmwIungS8ur6JM-JtpxrvMtjt5JkB1M"
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
</details>
|
|
483
|
+
|
|
484
|
+
#### `getDistributions({ epochIndex })`
|
|
485
|
+
|
|
486
|
+
Returns the current rewards distribution information.
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const io = IO.init();
|
|
490
|
+
const distributions = await io.getDistributions();
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
<details>
|
|
494
|
+
<summary>Output</summary>
|
|
495
|
+
|
|
496
|
+
```json
|
|
497
|
+
{
|
|
498
|
+
"epochEndHeight": 1382379,
|
|
499
|
+
"epochPeriod": 43,
|
|
500
|
+
"epochStartHeight": 1381660,
|
|
501
|
+
"epochZeroStartHeight": 1350700,
|
|
502
|
+
"nextDistributionHeight": 1382394
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
</details>
|
|
507
|
+
|
|
508
|
+
#### `getEpoch({ epochIndex })`
|
|
509
|
+
|
|
510
|
+
Returns the epoch data for the specified block height.
|
|
511
|
+
|
|
512
|
+
```typescript
|
|
513
|
+
const io = IO.init();
|
|
514
|
+
const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
<details>
|
|
518
|
+
<summary>Output</summary>
|
|
519
|
+
|
|
520
|
+
```json
|
|
521
|
+
{
|
|
522
|
+
"epochIndex": 0,
|
|
523
|
+
"startTimestamp": 1694101828,
|
|
524
|
+
"endTimestamp": 1711122739,
|
|
525
|
+
"startHeight": 1350700,
|
|
526
|
+
"distributionTimestamp": 1711122739,
|
|
527
|
+
"observations": {
|
|
528
|
+
"failureSummaries": {
|
|
529
|
+
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
530
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA"
|
|
531
|
+
]
|
|
532
|
+
},
|
|
533
|
+
"reports": {
|
|
534
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": "B6UUjKWjjEWDBvDSMXWNmymfwvgR9EN27z5FTkEVlX4"
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
"prescribedNames": ["ardrive", "ar-io", "arweave", "fwd", "ao"],
|
|
538
|
+
"prescribedObservers": [
|
|
539
|
+
{
|
|
540
|
+
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
541
|
+
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
542
|
+
"stake": 10000000000, // value in mIO
|
|
543
|
+
"start": 1292450,
|
|
544
|
+
"stakeWeight": 1,
|
|
545
|
+
"tenureWeight": 0.4494598765432099,
|
|
546
|
+
"gatewayRewardRatioWeight": 1,
|
|
547
|
+
"observerRewardRatioWeight": 1,
|
|
548
|
+
"compositeWeight": 0.4494598765432099,
|
|
549
|
+
"normalizedCompositeWeight": 0.002057032496835938
|
|
550
|
+
}
|
|
551
|
+
],
|
|
552
|
+
"distributions": {
|
|
553
|
+
"distributedTimestamp": 1711122739,
|
|
554
|
+
"totalEligibleRewards": 100000000,
|
|
555
|
+
"rewards": {
|
|
556
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
</details>
|
|
563
|
+
|
|
564
|
+
#### `getCurrentEpoch()`
|
|
565
|
+
|
|
566
|
+
Returns the current epoch data.
|
|
567
|
+
|
|
568
|
+
```typescript
|
|
569
|
+
const io = IO.init();
|
|
570
|
+
const epoch = await io.getCurrentEpoch();
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
<details>
|
|
574
|
+
<summary>Output</summary>
|
|
575
|
+
|
|
576
|
+
```json
|
|
577
|
+
{
|
|
578
|
+
"epochIndex": 0,
|
|
579
|
+
"startTimestamp": 1694101828,
|
|
580
|
+
"endTimestamp": 1711122739,
|
|
581
|
+
"startHeight": 1350700,
|
|
582
|
+
"distributionTimestamp": 1711122739,
|
|
583
|
+
"observations": {
|
|
584
|
+
"failureSummaries": {
|
|
585
|
+
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
586
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA"
|
|
587
|
+
]
|
|
588
|
+
},
|
|
589
|
+
"reports": {
|
|
590
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": "B6UUjKWjjEWDBvDSMXWNmymfwvgR9EN27z5FTkEVlX4"
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
"prescribedNames": ["ardrive", "ar-io", "arweave", "fwd", "ao"],
|
|
594
|
+
"prescribedObservers": [
|
|
595
|
+
{
|
|
596
|
+
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
597
|
+
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
598
|
+
"stake": 10000000000, // value in mIO
|
|
599
|
+
"start": 1292450,
|
|
600
|
+
"stakeWeight": 1,
|
|
601
|
+
"tenureWeight": 0.4494598765432099,
|
|
602
|
+
"gatewayRewardRatioWeight": 1,
|
|
603
|
+
"observerRewardRatioWeight": 1,
|
|
604
|
+
"compositeWeight": 0.4494598765432099,
|
|
605
|
+
"normalizedCompositeWeight": 0.002057032496835938
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
"distributions": {
|
|
609
|
+
"distributedTimestamp": 1711122739,
|
|
610
|
+
"totalEligibleRewards": 100000000,
|
|
611
|
+
"rewards": {
|
|
612
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
</details>
|
|
619
|
+
|
|
620
|
+
#### `getPrescribedObservers({ epochIndex })`
|
|
621
|
+
|
|
622
|
+
Retrieves the prescribed observers of the IO process. To fetch prescribed observers for a previous epoch set the `epochIndex` to the desired epoch index.
|
|
623
|
+
|
|
624
|
+
```typescript
|
|
625
|
+
const io = IO.init();
|
|
626
|
+
const observers = await io.getPrescribedObservers({ epochIndex: 0 });
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
<details>
|
|
630
|
+
<summary>Output</summary>
|
|
631
|
+
|
|
632
|
+
```json
|
|
633
|
+
[
|
|
634
|
+
{
|
|
635
|
+
"gatewayAddress": "BpQlyhREz4lNGS-y3rSS1WxADfxPpAuing9Lgfdrj2U",
|
|
636
|
+
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
637
|
+
"stake": 10000000000, // value in mIO
|
|
638
|
+
"start": 1296976,
|
|
639
|
+
"stakeWeight": 1,
|
|
640
|
+
"tenureWeight": 0.41453703703703704,
|
|
641
|
+
"gatewayRewardRatioWeight": 1,
|
|
642
|
+
"observerRewardRatioWeight": 1,
|
|
643
|
+
"compositeWeight": 0.41453703703703704,
|
|
644
|
+
"normalizedCompositeWeight": 0.0018972019546783507
|
|
645
|
+
}
|
|
646
|
+
]
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
</details>
|
|
650
|
+
|
|
651
|
+
#### `getTokenCost({ intent, ...args })`
|
|
652
|
+
|
|
653
|
+
Calculates the price in mIO to perform the interaction in question, eg a 'Buy-record' interaction, where args are the specific params for that interaction.
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
const price = await io
|
|
657
|
+
.getTokenCost({
|
|
658
|
+
intent: 'Buy-Record',
|
|
659
|
+
name: 'ar-io',
|
|
660
|
+
type: 'permabuy',
|
|
661
|
+
})
|
|
662
|
+
.then((p) => new mIOToken(p).toIO());
|
|
663
|
+
// Price is returned as mio, convert to IO and log it out
|
|
664
|
+
console.log({ price: price.valueOf() });
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
<details>
|
|
668
|
+
<summary>Output</summary>
|
|
669
|
+
|
|
670
|
+
```json
|
|
671
|
+
{ "price": 1642.62 }
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
</details>
|
|
675
|
+
|
|
676
|
+
#### `joinNetwork(params)`
|
|
677
|
+
|
|
678
|
+
Joins a gateway to the ar.io network via its associated wallet.
|
|
679
|
+
|
|
680
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
681
|
+
|
|
682
|
+
```typescript
|
|
683
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
684
|
+
const { id: txId } = await io.joinNetwork(
|
|
685
|
+
{
|
|
686
|
+
qty: new IOToken(10_000).toMIO(), // minimum operator stake allowed
|
|
687
|
+
autoStake: true, // auto-stake operator rewards to the gateway
|
|
688
|
+
allowDelegatedStaking: true, // allows delegated staking
|
|
689
|
+
minDelegatedStake: new IOToken(100).toMIO(), // minimum delegated stake allowed
|
|
690
|
+
delegateRewardShareRatio: 10, // percentage of rewards to share with delegates (e.g. 10%)
|
|
691
|
+
label: 'john smith', // min 1, max 64 characters
|
|
692
|
+
note: 'The example gateway', // max 256 characters
|
|
693
|
+
properties: 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44', // Arweave transaction ID containing additional properties of the Gateway
|
|
694
|
+
observerWallet: '0VE0wIhDy90WiQoV3U2PeY44FH1aVetOoulPGqgYukj', // wallet address of the observer, must match OBSERVER_WALLET on the observer
|
|
695
|
+
fqdn: 'example.com', // fully qualified domain name - note: you must own the domain and set the OBSERVER_WALLET on your gateway to match `observerWallet`
|
|
696
|
+
port: 443, // port number
|
|
697
|
+
protocol: 'https', // only 'https' is supported
|
|
698
|
+
},
|
|
699
|
+
// optional additional tags
|
|
700
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
701
|
+
);
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
#### `updateGatewaySettings(gatewaySettings)`
|
|
705
|
+
|
|
706
|
+
Writes new gateway settings to the callers gateway configuration.
|
|
707
|
+
|
|
708
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
709
|
+
|
|
710
|
+
```typescript
|
|
711
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
712
|
+
const { id: txId } = await io.updateGatewaySettings(
|
|
713
|
+
{
|
|
714
|
+
// any other settings you want to update
|
|
715
|
+
minDelegatedStake: new IOToken(100).toMIO(),
|
|
716
|
+
},
|
|
717
|
+
// optional additional tags
|
|
718
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
719
|
+
);
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
#### `increaseDelegateStake({ target, qty })`
|
|
723
|
+
|
|
724
|
+
Increases the callers stake on the target gateway.
|
|
725
|
+
|
|
726
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
727
|
+
|
|
728
|
+
```typescript
|
|
729
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
730
|
+
const { id: txId } = await io.increaseDelegateStake(
|
|
731
|
+
{
|
|
732
|
+
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
733
|
+
qty: new IOToken(100).toMIO(),
|
|
734
|
+
},
|
|
735
|
+
// optional additional tags
|
|
736
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
737
|
+
);
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
#### `decreaseDelegateStake({ target, qty })`
|
|
741
|
+
|
|
742
|
+
Decreases the callers stake on the target gateway.
|
|
743
|
+
|
|
744
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
745
|
+
|
|
746
|
+
```typescript
|
|
747
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
748
|
+
const { id: txId } = await io.decreaseDelegateStake(
|
|
749
|
+
{
|
|
750
|
+
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
751
|
+
qty: new IOToken(100).toMIO(),
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
|
|
755
|
+
},
|
|
756
|
+
);
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
#### `increaseOperatorStake({ qty })`
|
|
760
|
+
|
|
761
|
+
Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
|
|
762
|
+
|
|
763
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
764
|
+
|
|
765
|
+
```typescript
|
|
766
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
767
|
+
const { id: txId } = await io.increaseOperatorStake(
|
|
768
|
+
{
|
|
769
|
+
qty: new IOToken(100).toMIO(),
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
|
|
773
|
+
},
|
|
774
|
+
);
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
#### `decreaseOperatorStake({ qty })`
|
|
778
|
+
|
|
779
|
+
Decreases the callers operator stake. Must be executed with a wallet registered as a gateway operator. Requires `signer` to be provided on `IO.init` to sign the transaction.
|
|
780
|
+
|
|
781
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
782
|
+
|
|
783
|
+
```typescript
|
|
784
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
785
|
+
const { id: txId } = await io.decreaseOperatorStake(
|
|
786
|
+
{
|
|
787
|
+
qty: new IOToken(100).toMIO(),
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
|
|
791
|
+
},
|
|
792
|
+
);
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
#### `saveObservations({ reportTxId, failedGateways })`
|
|
796
|
+
|
|
797
|
+
Saves the observations of the current epoch. Requires `signer` to be provided on `IO.init` to sign the transaction.
|
|
798
|
+
|
|
799
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
800
|
+
|
|
801
|
+
```typescript
|
|
802
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
803
|
+
const { id: txId } = await io.saveObservations(
|
|
804
|
+
{
|
|
805
|
+
reportTxId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
806
|
+
failedGateways: ['t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3'],
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
|
|
810
|
+
},
|
|
811
|
+
);
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
#### `transfer({ target, qty, denomination })`
|
|
815
|
+
|
|
816
|
+
Transfers `IO` or `mIO` depending on the `denomination` selected, defaulting as `IO`, to the designated `target` recipient address. Requires `signer` to be provided on `IO.init` to sign the transaction.
|
|
817
|
+
|
|
818
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
819
|
+
|
|
820
|
+
```typescript
|
|
821
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
822
|
+
const { id: txId } = await io.transfer(
|
|
823
|
+
{
|
|
824
|
+
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
825
|
+
qty: new IOToken(1000).toMIO(),
|
|
826
|
+
denomination: 'IO',
|
|
827
|
+
},
|
|
828
|
+
// optional additional tags
|
|
829
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
830
|
+
);
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
#### `increaseUndernameLimit({ name, qty })`
|
|
834
|
+
|
|
835
|
+
Increases the undername support of a domain up to a maximum of 10k. Domains, by default, support up to 10 undernames.
|
|
836
|
+
|
|
837
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
838
|
+
|
|
839
|
+
```typescript
|
|
840
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
841
|
+
const { id: txId } = await io.increaseUndernameLimit(
|
|
842
|
+
{
|
|
843
|
+
name: 'ar-io',
|
|
844
|
+
qty: 420,
|
|
845
|
+
},
|
|
846
|
+
// optional additional tags
|
|
847
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
848
|
+
);
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
#### `extendLease({ name, years })`
|
|
852
|
+
|
|
853
|
+
Extends the lease of a registered ArNS domain, with an extension of 1-5 years depending on grace period status. Permanently registered domains cannot be extended.
|
|
854
|
+
|
|
855
|
+
```typescript
|
|
856
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
857
|
+
const { id: txId } = await io.extendLease(
|
|
858
|
+
{
|
|
859
|
+
name: 'ar-io',
|
|
860
|
+
years: 1,
|
|
861
|
+
},
|
|
862
|
+
// optional additional tags
|
|
863
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
864
|
+
);
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
### Configuration
|
|
868
|
+
|
|
869
|
+
The IO client class exposes APIs relevant to the ar.io process. It can be configured to use any AO Process ID that adheres to the [IO Network Spec]. By default, it will use the current [IO testnet process]. Refer to [AO Connect] for more information on how to configure an IO process to use specific AO infrastructure.
|
|
870
|
+
|
|
871
|
+
```typescript
|
|
872
|
+
// provide a custom ao infrastructure and process id
|
|
873
|
+
const io = IO.init({
|
|
874
|
+
process: new AoProcess({
|
|
875
|
+
processId: 'IO_PROCESS_ID'
|
|
876
|
+
ao: connect({
|
|
877
|
+
MU_URL: 'https://mu-testnet.xyz',
|
|
878
|
+
CU_URL: 'https://cu-testnet.xyz',
|
|
879
|
+
GRAPHQL_URL: 'https://arweave.net/graphql',
|
|
880
|
+
GATEWAY_URL: 'https://arweave.net',
|
|
881
|
+
})
|
|
882
|
+
})
|
|
248
883
|
});
|
|
249
884
|
```
|
|
250
885
|
|
|
251
886
|
## Arweave Name Tokens (ANT's)
|
|
252
887
|
|
|
253
|
-
The ANT
|
|
888
|
+
The ANT client class exposes APIs relevant to compliant Arweave Name Token processes. It can be configured to use any process ID that adheres to the ANT process spec. You must provide either a custom process data provider or a processId to the ANT class constructor to use.
|
|
254
889
|
|
|
255
|
-
### APIs
|
|
890
|
+
### ANT APIs
|
|
256
891
|
|
|
257
|
-
#### `init({ signer
|
|
892
|
+
#### `init({ signer )`
|
|
258
893
|
|
|
259
894
|
Factory function to that creates a read-only or writeable client. By providing a `signer` additional write APIs that require signing, like `setRecord` and `transfer` are available. By default, a read-only client is returned and no write APIs are available.
|
|
260
895
|
|
|
261
896
|
```typescript
|
|
262
|
-
const arweave = Arweave.init({
|
|
263
|
-
host: 'ar-io.dev',
|
|
264
|
-
port: 443,
|
|
265
|
-
protocol: 'https'
|
|
266
|
-
})
|
|
267
897
|
// in a browser environment with ArConnect
|
|
268
|
-
const browserSigner = new ArConnectSigner(window.arweaveWallet, arweave);
|
|
269
898
|
const ant = ANT.init({
|
|
270
|
-
signer:
|
|
899
|
+
signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({})),
|
|
271
900
|
processId: 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
272
901
|
});
|
|
273
902
|
|
|
274
903
|
// in a node environment
|
|
275
|
-
const nodeSigner = new ArweaveSigner(JWK);
|
|
276
904
|
const ant = ANT.init({
|
|
277
|
-
signer:
|
|
905
|
+
signer: new ArweaveSigner(JWK),
|
|
278
906
|
processId: 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
279
907
|
});
|
|
280
908
|
|
|
281
909
|
```
|
|
282
910
|
|
|
911
|
+
#### `getInfo()`
|
|
912
|
+
|
|
913
|
+
Retrieves the information of the ANT process.
|
|
914
|
+
|
|
915
|
+
```typescript
|
|
916
|
+
const info = await ant.getInfo();
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
<details>
|
|
920
|
+
<summary>Output</summary>
|
|
921
|
+
|
|
922
|
+
```json
|
|
923
|
+
{
|
|
924
|
+
"name": "Ardrive",
|
|
925
|
+
"ticker": "ANT-ARDRIVE",
|
|
926
|
+
"owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ"
|
|
927
|
+
}
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
</details>
|
|
931
|
+
|
|
932
|
+
#### `getOwner()`
|
|
933
|
+
|
|
934
|
+
Returns the owner of the configured ANT process.
|
|
935
|
+
|
|
936
|
+
```typescript
|
|
937
|
+
const owner = await ant.getOwner();
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
<details>
|
|
941
|
+
<summary>Output</summary>
|
|
942
|
+
|
|
943
|
+
```json
|
|
944
|
+
"ccp3blG__gKUvG3hsGC2u06aDmqv4CuhuDJGOIg0jw4"
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
</details>
|
|
948
|
+
|
|
949
|
+
#### `getControllers()`
|
|
950
|
+
|
|
951
|
+
Returns the controllers of the configured ANT process.
|
|
952
|
+
|
|
953
|
+
```typescript
|
|
954
|
+
const controllers = await ant.getControllers();
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
<details>
|
|
958
|
+
<summary>Output</summary>
|
|
959
|
+
|
|
960
|
+
```json
|
|
961
|
+
["ccp3blG__gKUvG3hsGC2u06aDmqv4CuhuDJGOIg0jw4"]
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
</details>
|
|
965
|
+
|
|
966
|
+
#### `getRecords()`
|
|
967
|
+
|
|
968
|
+
Returns all records on the configured ANT process, including the required `@` record that resolve connected ArNS names.
|
|
969
|
+
|
|
970
|
+
```typescript
|
|
971
|
+
const records = await ant.getRecords();
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
<details>
|
|
975
|
+
<summary>Output</summary>
|
|
976
|
+
|
|
977
|
+
```json
|
|
978
|
+
{
|
|
979
|
+
"@": {
|
|
980
|
+
"transactionId": "nOXJjj_vk0Dc1yCgdWD8kti_1iHruGzLQLNNBHVpN0Y",
|
|
981
|
+
"ttlSeconds": 3600
|
|
982
|
+
},
|
|
983
|
+
"cn": {
|
|
984
|
+
"transactionId": "_HquerT6pfGFXrVxRxQTkJ7PV5RciZCqvMjLtUY0C1k",
|
|
985
|
+
"ttlSeconds": 3300
|
|
986
|
+
},
|
|
987
|
+
"dapp": {
|
|
988
|
+
"transactionId": "hxlxVgAG0K4o3fVD9T6Q4VBWpPmMZwMWgRh1kcuh3WU",
|
|
989
|
+
"ttlSeconds": 3600
|
|
990
|
+
},
|
|
991
|
+
"logo": {
|
|
992
|
+
"transactionId": "KKmRbIfrc7wiLcG0zvY1etlO0NBx1926dSCksxCIN3A",
|
|
993
|
+
"ttlSeconds": 3600
|
|
994
|
+
},
|
|
995
|
+
"og": {
|
|
996
|
+
"transactionId": "YzD_Pm5VAfYpMD3zQCgMUcKKuleGhEH7axlrnrDCKBo",
|
|
997
|
+
"ttlSeconds": 3600
|
|
998
|
+
},
|
|
999
|
+
"og_dapp": {
|
|
1000
|
+
"transactionId": "5iR4wBu4KUV1pUz1YpYE1ARXSRHUT5G2ptMuoN2JDlI",
|
|
1001
|
+
"ttlSeconds": 3600
|
|
1002
|
+
},
|
|
1003
|
+
"og_logo": {
|
|
1004
|
+
"transactionId": "TB2wJyKrPnkAW79DAwlJYwpgdHKpijEJWQfcwX715Co",
|
|
1005
|
+
"ttlSeconds": 3600
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
</details>
|
|
1011
|
+
|
|
1012
|
+
#### `transfer({ target })`
|
|
1013
|
+
|
|
1014
|
+
Transfers ownership of the ANT to a new target address. Target MUST be an Arweave address.
|
|
1015
|
+
|
|
1016
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1017
|
+
|
|
1018
|
+
```typescript
|
|
1019
|
+
const { id: txId } = await ant.transfer(
|
|
1020
|
+
{ target: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
1021
|
+
// optional additional tags
|
|
1022
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1023
|
+
);
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
#### `setController({ controller })`
|
|
1027
|
+
|
|
1028
|
+
Adds a new controller to the list of approved controllers on the ANT. Controllers can set records and change the ticker and name of the ANT process.
|
|
1029
|
+
|
|
1030
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1031
|
+
|
|
1032
|
+
```typescript
|
|
1033
|
+
const { id: txId } = await ant.setController(
|
|
1034
|
+
{ controller: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
1035
|
+
// optional additional tags
|
|
1036
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1037
|
+
);
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
#### `removeController({ controller })`
|
|
1041
|
+
|
|
1042
|
+
Removes a controller from the list of approved controllers on the ANT.
|
|
1043
|
+
|
|
1044
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1045
|
+
|
|
1046
|
+
```typescript
|
|
1047
|
+
const { id: txId } = await ant.removeController(
|
|
1048
|
+
{ controller: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
1049
|
+
// optional additional tags
|
|
1050
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1051
|
+
);
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
#### `setRecord({ undername, transactionId, ttlSeconds })`
|
|
1055
|
+
|
|
1056
|
+
Updates or creates a record in the ANT process.
|
|
1057
|
+
|
|
1058
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1059
|
+
|
|
1060
|
+
> Records, or `undernames` are configured with the `transactionId` - the arweave transaction id the record resolves - and `ttlSeconds`, the Time To Live in the cache of client applications.
|
|
1061
|
+
|
|
1062
|
+
```typescript
|
|
1063
|
+
const { id: txId } = await ant.setRecord(
|
|
1064
|
+
{
|
|
1065
|
+
undername: '@',
|
|
1066
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
1067
|
+
ttlSeconds: 3600
|
|
1068
|
+
},
|
|
1069
|
+
// optional additional tags
|
|
1070
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1071
|
+
);
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
#### `removeRecord({ undername })`
|
|
1075
|
+
|
|
1076
|
+
Removes a record from the ANT process.
|
|
1077
|
+
|
|
1078
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1079
|
+
|
|
1080
|
+
```typescript
|
|
1081
|
+
const { id: txId } = await ant.removeRecord(
|
|
1082
|
+
{ undername: 'remove-domemain' },
|
|
1083
|
+
// optional additional tags
|
|
1084
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1085
|
+
);
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
#### `setName({ name })`
|
|
1089
|
+
|
|
1090
|
+
Sets the name of the ANT process.
|
|
1091
|
+
|
|
1092
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1093
|
+
|
|
1094
|
+
```typescript
|
|
1095
|
+
const { id: txId } = await ant.setName(
|
|
1096
|
+
{ name: 'My ANT' },
|
|
1097
|
+
// optional additional tags
|
|
1098
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1099
|
+
);
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
#### `setTicker({ ticker })`
|
|
1103
|
+
|
|
1104
|
+
Sets the ticker of the ANT process.
|
|
1105
|
+
|
|
1106
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1107
|
+
|
|
1108
|
+
```typescript
|
|
1109
|
+
const { id: txId } = await ant.setTicker(
|
|
1110
|
+
{ ticker: 'ANT-NEW-TICKER' },
|
|
1111
|
+
// optional tags
|
|
1112
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1113
|
+
);
|
|
1114
|
+
```
|
|
1115
|
+
|
|
283
1116
|
### Configuration
|
|
284
1117
|
|
|
285
|
-
ANT clients can be configured to use custom process
|
|
1118
|
+
ANT clients can be configured to use custom AO process. Refer to [AO Connect] for more information on how to configure the AO process to use specific AO infrastructure.
|
|
286
1119
|
|
|
287
1120
|
```typescript
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
|
|
1121
|
+
|
|
1122
|
+
const ant = ANT.init({
|
|
1123
|
+
process: new AoProcess({
|
|
1124
|
+
processId: 'ANT_PROCESS_ID'
|
|
1125
|
+
ao: connect({
|
|
1126
|
+
MU_URL: 'https://mu-testnet.xyz',
|
|
1127
|
+
CU_URL: 'https://cu-testnet.xyz',
|
|
1128
|
+
GRAPHQL_URL: 'https://arweave.net/graphql',
|
|
1129
|
+
GATEWAY_URL: 'https://arweave.net',
|
|
1130
|
+
})
|
|
1131
|
+
})
|
|
291
1132
|
});
|
|
292
1133
|
```
|
|
293
1134
|
|
|
@@ -336,3 +1177,6 @@ For more information on how to contribute, please see [CONTRIBUTING.md].
|
|
|
336
1177
|
[examples/webpack]: ./examples/webpack
|
|
337
1178
|
[examples/vite]: ./examples/vite
|
|
338
1179
|
[CONTRIBUTING.md]: ./CONTRIBUTING.md
|
|
1180
|
+
[AO Connect]: https://github.com/permaweb/ao/tree/main/connect
|
|
1181
|
+
[IO testnet process]: https://www.ao.link/#/entity/agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA
|
|
1182
|
+
[IO Network spec]: https://github.com/ar-io/ar-io-network-process?tab=readme-ov-file#contract-spec
|