@ar.io/sdk 1.2.0-alpha.20 → 1.2.0-alpha.21
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 +369 -314
- package/bundles/web.bundle.min.js +57 -57
- package/lib/cjs/utils/graphql/processes.js +2 -5
- package/lib/cjs/version.js +1 -1
- package/lib/esm/utils/graphql/processes.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/utils/graphql/processes.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -15,21 +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
|
-
- [`
|
|
24
|
-
- [`
|
|
25
|
-
- [`
|
|
26
|
-
- [`
|
|
27
|
-
- [`
|
|
28
|
-
- [`
|
|
29
|
-
- [`
|
|
30
|
-
- [`
|
|
31
|
-
- [`
|
|
32
|
-
- [`
|
|
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-)
|
|
33
34
|
- [`joinNetwork(params)`](#joinnetworkparams)
|
|
34
35
|
- [`updateGatewaySettings(gatewaySettings)`](#updategatewaysettingsgatewaysettings)
|
|
35
36
|
- [`increaseDelegateStake({ target, qty })`](#increasedelegatestake-target-qty-)
|
|
@@ -38,19 +39,20 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
38
39
|
- [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
|
|
39
40
|
- [`saveObservations({ reportTxId, failedGateways })`](#saveobservations-reporttxid-failedgateways-)
|
|
40
41
|
- [`transfer({ target, qty, denomination })`](#transfer-target-qty-denomination-)
|
|
41
|
-
- [
|
|
42
|
+
- [Configuration](#custom-configuration)
|
|
42
43
|
|
|
43
44
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
44
|
-
- [APIs](#apis
|
|
45
|
-
- [`init({ signer
|
|
46
|
-
- [`
|
|
47
|
-
- [`
|
|
48
|
-
- [`
|
|
45
|
+
- [ANT APIs](#ant-apis)
|
|
46
|
+
- [`init({ signer})`](#init-signer-)
|
|
47
|
+
- [`getInfo()`](#getinfo)
|
|
48
|
+
- [`getOwner()`](#getowner)
|
|
49
|
+
- [`getControllers()`](#getcontrollers)
|
|
50
|
+
- [`getRecords()`](#getrecords)
|
|
49
51
|
- [`transfer({ target })`](#transfer-target-)
|
|
50
52
|
- [`setController({ controller })`](#setcontroller-controller-)
|
|
51
53
|
- [`removeController({ controller })`](#removecontroller-controller-)
|
|
52
|
-
- [`setRecord({
|
|
53
|
-
- [`removeRecord({
|
|
54
|
+
- [`setRecord({ undername, transactionId, ttlSeconds })`](#setrecord-undername-transactionid-ttlseconds-)
|
|
55
|
+
- [`removeRecord({ undername })`](#removerecord-undername-)
|
|
54
56
|
- [`setName({ name })`](#setname-name-)
|
|
55
57
|
- [`setTicker({ ticker })`](#setticker-ticker-)
|
|
56
58
|
- [Configuration](#configuration)
|
|
@@ -83,8 +85,8 @@ yarn add @ar.io/sdk
|
|
|
83
85
|
```typescript
|
|
84
86
|
import { IO } from '@ar.io/sdk';
|
|
85
87
|
|
|
86
|
-
const
|
|
87
|
-
const gateways = await
|
|
88
|
+
const io = IO.init();
|
|
89
|
+
const gateways = await io.getGateways();
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
<details>
|
|
@@ -137,12 +139,12 @@ The SDK is provided in both CommonJS and ESM formats and is compatible with bund
|
|
|
137
139
|
#### Bundlers (Webpack, Rollup, ESbuild, etc.)
|
|
138
140
|
|
|
139
141
|
```javascript
|
|
140
|
-
import { IO } from '@ar.io/sdk';
|
|
142
|
+
import { IO } from '@ar.io/sdk/web';
|
|
141
143
|
|
|
142
144
|
// set up client
|
|
143
|
-
const
|
|
145
|
+
const io = IO.init();
|
|
144
146
|
// fetch gateways
|
|
145
|
-
const gateways = await
|
|
147
|
+
const gateways = await io.getGateways();
|
|
146
148
|
```
|
|
147
149
|
|
|
148
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._
|
|
@@ -154,9 +156,9 @@ const gateways = await arIO.getGateways();
|
|
|
154
156
|
import { IO } from 'https://unpkg.com/@ar.io/sdk';
|
|
155
157
|
|
|
156
158
|
// set up client
|
|
157
|
-
const
|
|
159
|
+
const io = IO.init();
|
|
158
160
|
// fetch gateways
|
|
159
|
-
const gateways = await
|
|
161
|
+
const gateways = await io.getGateways();
|
|
160
162
|
</script>
|
|
161
163
|
```
|
|
162
164
|
|
|
@@ -168,9 +170,9 @@ const gateways = await arIO.getGateways();
|
|
|
168
170
|
import { IO } from '@ar.io/sdk/node';
|
|
169
171
|
|
|
170
172
|
// set up client
|
|
171
|
-
const
|
|
173
|
+
const io = IO.init();
|
|
172
174
|
// fetch gateways
|
|
173
|
-
const gateways = await
|
|
175
|
+
const gateways = await io.getGateways();
|
|
174
176
|
```
|
|
175
177
|
|
|
176
178
|
#### CJS
|
|
@@ -179,9 +181,9 @@ const gateways = await arIO.getGateways();
|
|
|
179
181
|
import { IO } from '@ar.io/sdk';
|
|
180
182
|
|
|
181
183
|
// set up client
|
|
182
|
-
const
|
|
184
|
+
const io = IO.init();
|
|
183
185
|
// fetch gateways
|
|
184
|
-
const gateways = await
|
|
186
|
+
const gateways = await io.getGateways();
|
|
185
187
|
```
|
|
186
188
|
|
|
187
189
|
### Typescript
|
|
@@ -190,7 +192,7 @@ The SDK provides TypeScript types. When you import the SDK in a TypeScript proje
|
|
|
190
192
|
|
|
191
193
|
## IOToken & mIOToken
|
|
192
194
|
|
|
193
|
-
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.
|
|
194
196
|
|
|
195
197
|
**All process interactions expect values in mIO. If numbers are provided as inputs, they are assumed to be in raw mIO values.**
|
|
196
198
|
|
|
@@ -208,7 +210,7 @@ const ioValue = new mIOToken(mIOValue).toIO();
|
|
|
208
210
|
console.log(ioValue); // 1 (IO)
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
##
|
|
213
|
+
## IO Process
|
|
212
214
|
|
|
213
215
|
### APIs
|
|
214
216
|
|
|
@@ -217,32 +219,48 @@ console.log(ioValue); // 1 (IO)
|
|
|
217
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.
|
|
218
220
|
|
|
219
221
|
```typescript
|
|
220
|
-
// read-only client
|
|
221
|
-
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
|
+
```
|
|
222
232
|
|
|
223
|
-
|
|
224
|
-
host: 'ar-io.dev',
|
|
225
|
-
port: 443,
|
|
226
|
-
protocol: 'https'
|
|
227
|
-
})
|
|
228
|
-
// for browser environments
|
|
229
|
-
const browserSigner = new ArConnectSigner(window.arweaveWallet, arweave);
|
|
230
|
-
const arIOWriteable = IO.init({ signer: browserSigner});
|
|
233
|
+
#### `getInfo()`
|
|
231
234
|
|
|
232
|
-
|
|
233
|
-
const nodeSigner = new ArweaveSigner(JWK);
|
|
234
|
-
const arIOWriteable = IO.init({ signer: nodeSigner});
|
|
235
|
+
Retrieves the information of the IO process.
|
|
235
236
|
|
|
237
|
+
```typescript
|
|
238
|
+
const io = IO.init();
|
|
239
|
+
const info = await io.getInfo();
|
|
236
240
|
```
|
|
237
241
|
|
|
238
|
-
|
|
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 })`
|
|
239
257
|
|
|
240
258
|
Retrieves the balance of the specified wallet address.
|
|
241
259
|
|
|
242
260
|
```typescript
|
|
243
|
-
const
|
|
261
|
+
const io = IO.init();
|
|
244
262
|
// the balance will be returned in mIO as a value
|
|
245
|
-
const balance = await
|
|
263
|
+
const balance = await io
|
|
246
264
|
.getBalance({
|
|
247
265
|
address: 'INSERT_WALLET_ADDRESS',
|
|
248
266
|
})
|
|
@@ -261,19 +279,19 @@ console.log(balance.valueOf());
|
|
|
261
279
|
|
|
262
280
|
</details>
|
|
263
281
|
|
|
264
|
-
#### `getBalances(
|
|
282
|
+
#### `getBalances()`
|
|
265
283
|
|
|
266
|
-
Retrieves the balances of the
|
|
284
|
+
Retrieves the balances of the IO process in `mIO`
|
|
267
285
|
|
|
268
286
|
<!--
|
|
269
287
|
// ALM - A part of me wonders whether streaming JSON might be beneficial in the future
|
|
270
288
|
// and if providing streaming versions of these APIs will scale nicely longer term, e.g.
|
|
271
|
-
//
|
|
289
|
+
// io.streamBalances({ sortingCriteria: BALANCE_DESC });
|
|
272
290
|
-->
|
|
273
291
|
|
|
274
292
|
```typescript
|
|
275
|
-
const
|
|
276
|
-
const balances = await
|
|
293
|
+
const io = IO.init();
|
|
294
|
+
const balances = await io.getBalances();
|
|
277
295
|
```
|
|
278
296
|
|
|
279
297
|
<details>
|
|
@@ -289,13 +307,13 @@ const balances = await arIO.getBalances();
|
|
|
289
307
|
|
|
290
308
|
</details>
|
|
291
309
|
|
|
292
|
-
#### `getGateway({ address
|
|
310
|
+
#### `getGateway({ address })`
|
|
293
311
|
|
|
294
312
|
Retrieves a gateway's info by its staking wallet address.
|
|
295
313
|
|
|
296
314
|
```typescript
|
|
297
|
-
const
|
|
298
|
-
const gateway = await
|
|
315
|
+
const io = IO.init();
|
|
316
|
+
const gateway = await io.getGateway({
|
|
299
317
|
address: 'INSERT_GATEWAY_ADDRESS',
|
|
300
318
|
});
|
|
301
319
|
```
|
|
@@ -325,27 +343,19 @@ const gateway = await arIO.getGateway({
|
|
|
325
343
|
"totalEpochsPrescribedCount": 31
|
|
326
344
|
},
|
|
327
345
|
"status": "joined",
|
|
328
|
-
"vaults": {}
|
|
329
|
-
"weights": {
|
|
330
|
-
"stakeWeight": 25,
|
|
331
|
-
"tenureWeight": 0.9031327160493827,
|
|
332
|
-
"gatewayRewardRatioWeight": 0.96875,
|
|
333
|
-
"observerRewardRatioWeight": 0.96875,
|
|
334
|
-
"compositeWeight": 21.189222170982834,
|
|
335
|
-
"normalizedCompositeWeight": 0.27485583057217183
|
|
336
|
-
}
|
|
346
|
+
"vaults": {}
|
|
337
347
|
}
|
|
338
348
|
```
|
|
339
349
|
|
|
340
350
|
</details>
|
|
341
351
|
|
|
342
|
-
#### `getGateways(
|
|
352
|
+
#### `getGateways()`
|
|
343
353
|
|
|
344
|
-
Retrieves the registered gateways of the
|
|
354
|
+
Retrieves the registered gateways of the IO process.
|
|
345
355
|
|
|
346
356
|
```typescript
|
|
347
|
-
const
|
|
348
|
-
const gateways = await
|
|
357
|
+
const io = IO.init();
|
|
358
|
+
const gateways = await io.getGateways();
|
|
349
359
|
```
|
|
350
360
|
|
|
351
361
|
<details>
|
|
@@ -374,28 +384,20 @@ const gateways = await arIO.getGateways();
|
|
|
374
384
|
"totalEpochsPrescribedCount": 31
|
|
375
385
|
},
|
|
376
386
|
"status": "joined",
|
|
377
|
-
"vaults": {}
|
|
378
|
-
"weights": {
|
|
379
|
-
"stakeWeight": 25,
|
|
380
|
-
"tenureWeight": 0.9031327160493827,
|
|
381
|
-
"gatewayRewardRatioWeight": 0.96875,
|
|
382
|
-
"observerRewardRatioWeight": 0.96875,
|
|
383
|
-
"compositeWeight": 21.189222170982834,
|
|
384
|
-
"normalizedCompositeWeight": 0.27485583057217183
|
|
385
|
-
}
|
|
387
|
+
"vaults": {}
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
390
|
```
|
|
389
391
|
|
|
390
392
|
</details>
|
|
391
393
|
|
|
392
|
-
#### `getArNSRecord({
|
|
394
|
+
#### `getArNSRecord({ name })`
|
|
393
395
|
|
|
394
396
|
Retrieves the record info of the specified ArNS name.
|
|
395
397
|
|
|
396
398
|
```typescript
|
|
397
|
-
const
|
|
398
|
-
const record = await
|
|
399
|
+
const io = IO.init();
|
|
400
|
+
const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
399
401
|
```
|
|
400
402
|
|
|
401
403
|
<details>
|
|
@@ -413,13 +415,13 @@ const record = await arIO.getArNSRecord({ domain: 'ardrive' });
|
|
|
413
415
|
|
|
414
416
|
</details>
|
|
415
417
|
|
|
416
|
-
#### `getArNSRecords(
|
|
418
|
+
#### `getArNSRecords()`
|
|
417
419
|
|
|
418
|
-
Retrieves all registered ArNS records of the
|
|
420
|
+
Retrieves all registered ArNS records of the IO process.
|
|
419
421
|
|
|
420
422
|
```typescript
|
|
421
|
-
const
|
|
422
|
-
const records = await
|
|
423
|
+
const io = IO.init();
|
|
424
|
+
const records = await io.getArNSRecords();
|
|
423
425
|
```
|
|
424
426
|
|
|
425
427
|
<details>
|
|
@@ -446,13 +448,13 @@ const records = await arIO.getArNSRecords();
|
|
|
446
448
|
|
|
447
449
|
</details>
|
|
448
450
|
|
|
449
|
-
#### `getObservations({
|
|
451
|
+
#### `getObservations({ epochIndex })`
|
|
450
452
|
|
|
451
453
|
Returns the epoch-indexed observation list.
|
|
452
454
|
|
|
453
455
|
```typescript
|
|
454
|
-
const
|
|
455
|
-
const observations = await
|
|
456
|
+
const io = IO.init();
|
|
457
|
+
const observations = await io.getObservations();
|
|
456
458
|
```
|
|
457
459
|
|
|
458
460
|
<details>
|
|
@@ -460,7 +462,7 @@ const observations = await arIO.getObservations();
|
|
|
460
462
|
|
|
461
463
|
```json
|
|
462
464
|
{
|
|
463
|
-
"
|
|
465
|
+
"0": {
|
|
464
466
|
"failureSummaries": {
|
|
465
467
|
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
466
468
|
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA",
|
|
@@ -479,13 +481,13 @@ const observations = await arIO.getObservations();
|
|
|
479
481
|
|
|
480
482
|
</details>
|
|
481
483
|
|
|
482
|
-
#### `getDistributions({
|
|
484
|
+
#### `getDistributions({ epochIndex })`
|
|
483
485
|
|
|
484
|
-
Returns the current rewards distribution information.
|
|
486
|
+
Returns the current rewards distribution information.
|
|
485
487
|
|
|
486
488
|
```typescript
|
|
487
|
-
const
|
|
488
|
-
const distributions = await
|
|
489
|
+
const io = IO.init();
|
|
490
|
+
const distributions = await io.getDistributions();
|
|
489
491
|
```
|
|
490
492
|
|
|
491
493
|
<details>
|
|
@@ -503,13 +505,13 @@ const distributions = await arIO.getDistributions();
|
|
|
503
505
|
|
|
504
506
|
</details>
|
|
505
507
|
|
|
506
|
-
#### `getEpoch({
|
|
508
|
+
#### `getEpoch({ epochIndex })`
|
|
507
509
|
|
|
508
510
|
Returns the epoch data for the specified block height.
|
|
509
511
|
|
|
510
512
|
```typescript
|
|
511
|
-
const
|
|
512
|
-
const epoch = await
|
|
513
|
+
const io = IO.init();
|
|
514
|
+
const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
513
515
|
```
|
|
514
516
|
|
|
515
517
|
<details>
|
|
@@ -517,24 +519,55 @@ const epoch = await arIO.getEpoch({ blockHeight: 1382230 });
|
|
|
517
519
|
|
|
518
520
|
```json
|
|
519
521
|
{
|
|
520
|
-
"
|
|
521
|
-
"
|
|
522
|
-
"
|
|
523
|
-
"
|
|
524
|
-
"
|
|
525
|
-
"
|
|
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
|
+
}
|
|
526
559
|
}
|
|
527
560
|
```
|
|
528
561
|
|
|
529
562
|
</details>
|
|
530
563
|
|
|
531
|
-
#### `getCurrentEpoch(
|
|
564
|
+
#### `getCurrentEpoch()`
|
|
532
565
|
|
|
533
566
|
Returns the current epoch data.
|
|
534
567
|
|
|
535
568
|
```typescript
|
|
536
|
-
const
|
|
537
|
-
const epoch = await
|
|
569
|
+
const io = IO.init();
|
|
570
|
+
const epoch = await io.getCurrentEpoch();
|
|
538
571
|
```
|
|
539
572
|
|
|
540
573
|
<details>
|
|
@@ -542,23 +575,55 @@ const epoch = await arIO.getCurrentEpoch();
|
|
|
542
575
|
|
|
543
576
|
```json
|
|
544
577
|
{
|
|
545
|
-
"
|
|
546
|
-
"
|
|
547
|
-
"
|
|
548
|
-
"
|
|
549
|
-
"
|
|
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
|
+
}
|
|
550
615
|
}
|
|
551
616
|
```
|
|
552
617
|
|
|
553
618
|
</details>
|
|
554
619
|
|
|
555
|
-
#### `getPrescribedObservers({
|
|
620
|
+
#### `getPrescribedObservers({ epochIndex })`
|
|
556
621
|
|
|
557
|
-
Retrieves the prescribed observers of the
|
|
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.
|
|
558
623
|
|
|
559
624
|
```typescript
|
|
560
|
-
const
|
|
561
|
-
const observers = await
|
|
625
|
+
const io = IO.init();
|
|
626
|
+
const observers = await io.getPrescribedObservers({ epochIndex: 0 });
|
|
562
627
|
```
|
|
563
628
|
|
|
564
629
|
<details>
|
|
@@ -583,48 +648,16 @@ const observers = await arIO.getPrescribedObservers();
|
|
|
583
648
|
|
|
584
649
|
</details>
|
|
585
650
|
|
|
586
|
-
|
|
651
|
+
#### `getTokenCost({ intent, ...args })`
|
|
587
652
|
|
|
588
|
-
|
|
589
|
-
// observers from a previous epoch
|
|
590
|
-
const previousEpochObservers = await arIO.getPrescribedObservers({
|
|
591
|
-
evaluationOptions: {
|
|
592
|
-
evalTo: { blockHeight: 1296975 }, // some block height from a previous epoch
|
|
593
|
-
},
|
|
594
|
-
});
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
<details>
|
|
598
|
-
<summary>Output</summary>
|
|
599
|
-
|
|
600
|
-
```json
|
|
601
|
-
[
|
|
602
|
-
{
|
|
603
|
-
"gatewayAddress": "2Ic0ZIpt85tjiVRaD_qoTSo9jgT7w0rbf4puSTRidcU",
|
|
604
|
-
"observerAddress": "2Ic0ZIpt85tjiVRaD_qoTSo9jgT7w0rbf4puSTRidcU",
|
|
605
|
-
"stake": 10000000000, // vault in mIO
|
|
606
|
-
"start": 1292450,
|
|
607
|
-
"stakeWeight": 1,
|
|
608
|
-
"tenureWeight": 0.4494598765432099,
|
|
609
|
-
"gatewayRewardRatioWeight": 1,
|
|
610
|
-
"observerRewardRatioWeight": 1,
|
|
611
|
-
"compositeWeight": 0.4494598765432099,
|
|
612
|
-
"normalizedCompositeWeight": 0.002057032496835938
|
|
613
|
-
}
|
|
614
|
-
]
|
|
615
|
-
```
|
|
616
|
-
|
|
617
|
-
</details>
|
|
618
|
-
|
|
619
|
-
#### `getPriceForInteraction({ interactionName, payload })`
|
|
620
|
-
|
|
621
|
-
Calculates the price in mIO to perform the interaction in question, eg a 'buyRecord' interaction, where payload is the specific params for that interaction.
|
|
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.
|
|
622
654
|
|
|
623
655
|
```typescript
|
|
624
|
-
const price = await
|
|
625
|
-
.
|
|
626
|
-
|
|
627
|
-
|
|
656
|
+
const price = await io
|
|
657
|
+
.getTokenCost({
|
|
658
|
+
intent: 'Buy-Record',
|
|
659
|
+
name: 'ar-io',
|
|
660
|
+
type: 'permabuy',
|
|
628
661
|
})
|
|
629
662
|
.then((p) => new mIOToken(p).toIO());
|
|
630
663
|
// Price is returned as mio, convert to IO and log it out
|
|
@@ -642,28 +675,27 @@ console.log({ price: price.valueOf() });
|
|
|
642
675
|
|
|
643
676
|
#### `joinNetwork(params)`
|
|
644
677
|
|
|
645
|
-
Joins a gateway to the ar.io network via its associated wallet.
|
|
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._
|
|
646
681
|
|
|
647
682
|
```typescript
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const authenticatedArIO = IO.init({ signer });
|
|
665
|
-
const { id: txId } = await authenticatedArIO.joinNetwork(
|
|
666
|
-
joinNetworkParams,
|
|
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
|
+
},
|
|
667
699
|
// optional additional tags
|
|
668
700
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
669
701
|
);
|
|
@@ -671,18 +703,17 @@ const { id: txId } = await authenticatedArIO.joinNetwork(
|
|
|
671
703
|
|
|
672
704
|
#### `updateGatewaySettings(gatewaySettings)`
|
|
673
705
|
|
|
674
|
-
Writes new gateway settings to the callers gateway configuration.
|
|
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._
|
|
675
709
|
|
|
676
710
|
```typescript
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
const authenticatedArIO = IO.init({ signer });
|
|
684
|
-
const { id: txId } = await authenticatedArIO.updateGatewaySettings(
|
|
685
|
-
updateGatewaySettingsParams,
|
|
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
|
+
},
|
|
686
717
|
// optional additional tags
|
|
687
718
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
688
719
|
);
|
|
@@ -690,19 +721,17 @@ const { id: txId } = await authenticatedArIO.updateGatewaySettings(
|
|
|
690
721
|
|
|
691
722
|
#### `increaseDelegateStake({ target, qty })`
|
|
692
723
|
|
|
693
|
-
Increases the callers stake on the target gateway.
|
|
724
|
+
Increases the callers stake on the target gateway.
|
|
725
|
+
|
|
726
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
694
727
|
|
|
695
728
|
```typescript
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
// signer required for write interactions APIs
|
|
703
|
-
const authenticatedArIO = IO.init({ signer });
|
|
704
|
-
const { id: txId } = await authenticatedArIO.increaseDelegateStake(
|
|
705
|
-
params,
|
|
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
|
+
},
|
|
706
735
|
// optional additional tags
|
|
707
736
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
708
737
|
);
|
|
@@ -710,82 +739,87 @@ const { id: txId } = await authenticatedArIO.increaseDelegateStake(
|
|
|
710
739
|
|
|
711
740
|
#### `decreaseDelegateStake({ target, qty })`
|
|
712
741
|
|
|
713
|
-
Decreases the callers stake on the target gateway.
|
|
742
|
+
Decreases the callers stake on the target gateway.
|
|
743
|
+
|
|
744
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
714
745
|
|
|
715
746
|
```typescript
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
});
|
|
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
|
+
);
|
|
727
757
|
```
|
|
728
758
|
|
|
729
759
|
#### `increaseOperatorStake({ qty })`
|
|
730
760
|
|
|
731
|
-
Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
|
|
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._
|
|
732
764
|
|
|
733
765
|
```typescript
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
});
|
|
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
|
+
);
|
|
744
775
|
```
|
|
745
776
|
|
|
746
777
|
#### `decreaseOperatorStake({ qty })`
|
|
747
778
|
|
|
748
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.
|
|
749
780
|
|
|
781
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
782
|
+
|
|
750
783
|
```typescript
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
});
|
|
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
|
+
);
|
|
761
793
|
```
|
|
762
794
|
|
|
763
795
|
#### `saveObservations({ reportTxId, failedGateways })`
|
|
764
796
|
|
|
765
797
|
Saves the observations of the current epoch. Requires `signer` to be provided on `IO.init` to sign the transaction.
|
|
766
798
|
|
|
799
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
800
|
+
|
|
767
801
|
```typescript
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
});
|
|
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
|
+
);
|
|
779
812
|
```
|
|
780
813
|
|
|
781
814
|
#### `transfer({ target, qty, denomination })`
|
|
782
815
|
|
|
783
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.
|
|
784
817
|
|
|
818
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
819
|
+
|
|
785
820
|
```typescript
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
const { id: txId } = await authenticatedArIO.transfer(
|
|
821
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
822
|
+
const { id: txId } = await io.transfer(
|
|
789
823
|
{
|
|
790
824
|
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
791
825
|
qty: new IOToken(1000).toMIO(),
|
|
@@ -796,15 +830,17 @@ const { id: txId } = await authenticatedArIO.transfer(
|
|
|
796
830
|
);
|
|
797
831
|
```
|
|
798
832
|
|
|
799
|
-
#### `increaseUndernameLimit({
|
|
833
|
+
#### `increaseUndernameLimit({ name, qty })`
|
|
800
834
|
|
|
801
835
|
Increases the undername support of a domain up to a maximum of 10k. Domains, by default, support up to 10 undernames.
|
|
802
836
|
|
|
837
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
838
|
+
|
|
803
839
|
```typescript
|
|
804
|
-
const
|
|
805
|
-
const { id: txId } = await
|
|
840
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
841
|
+
const { id: txId } = await io.increaseUndernameLimit(
|
|
806
842
|
{
|
|
807
|
-
|
|
843
|
+
name: 'ar-io',
|
|
808
844
|
qty: 420,
|
|
809
845
|
},
|
|
810
846
|
// optional additional tags
|
|
@@ -812,15 +848,15 @@ const { id: txId } = await authenticatedArIO.increaseUndernameLimit(
|
|
|
812
848
|
);
|
|
813
849
|
```
|
|
814
850
|
|
|
815
|
-
#### `extendLease({
|
|
851
|
+
#### `extendLease({ name, years })`
|
|
816
852
|
|
|
817
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.
|
|
818
854
|
|
|
819
855
|
```typescript
|
|
820
|
-
const
|
|
821
|
-
const { id: txId } = await
|
|
856
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
857
|
+
const { id: txId } = await io.extendLease(
|
|
822
858
|
{
|
|
823
|
-
|
|
859
|
+
name: 'ar-io',
|
|
824
860
|
years: 1,
|
|
825
861
|
},
|
|
826
862
|
// optional additional tags
|
|
@@ -828,14 +864,22 @@ const { id: txId } = await authenticatedArIO.extendLease(
|
|
|
828
864
|
);
|
|
829
865
|
```
|
|
830
866
|
|
|
831
|
-
###
|
|
867
|
+
### Configuration
|
|
832
868
|
|
|
833
|
-
The
|
|
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.
|
|
834
870
|
|
|
835
871
|
```typescript
|
|
836
|
-
// provide a custom
|
|
837
|
-
const
|
|
838
|
-
|
|
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
|
+
})
|
|
839
883
|
});
|
|
840
884
|
```
|
|
841
885
|
|
|
@@ -843,41 +887,53 @@ const remoteCustomArIO = IO.init({
|
|
|
843
887
|
|
|
844
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.
|
|
845
889
|
|
|
846
|
-
### APIs
|
|
890
|
+
### ANT APIs
|
|
847
891
|
|
|
848
|
-
#### `init({ signer
|
|
892
|
+
#### `init({ signer )`
|
|
849
893
|
|
|
850
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.
|
|
851
895
|
|
|
852
896
|
```typescript
|
|
853
|
-
const arweave = Arweave.init({
|
|
854
|
-
host: 'ar-io.dev',
|
|
855
|
-
port: 443,
|
|
856
|
-
protocol: 'https'
|
|
857
|
-
})
|
|
858
897
|
// in a browser environment with ArConnect
|
|
859
|
-
const browserSigner = new ArConnectSigner(window.arweaveWallet, arweave);
|
|
860
898
|
const ant = ANT.init({
|
|
861
|
-
signer:
|
|
899
|
+
signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({})),
|
|
862
900
|
processId: 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
863
901
|
});
|
|
864
902
|
|
|
865
903
|
// in a node environment
|
|
866
|
-
const nodeSigner = new ArweaveSigner(JWK);
|
|
867
904
|
const ant = ANT.init({
|
|
868
|
-
signer:
|
|
905
|
+
signer: new ArweaveSigner(JWK),
|
|
869
906
|
processId: 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
870
907
|
});
|
|
871
908
|
|
|
872
909
|
```
|
|
873
910
|
|
|
874
|
-
#### `
|
|
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()`
|
|
875
933
|
|
|
876
934
|
Returns the owner of the configured ANT process.
|
|
877
935
|
|
|
878
936
|
```typescript
|
|
879
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
880
|
-
const ant = ANT.init({ processId });
|
|
881
937
|
const owner = await ant.getOwner();
|
|
882
938
|
```
|
|
883
939
|
|
|
@@ -890,13 +946,11 @@ const owner = await ant.getOwner();
|
|
|
890
946
|
|
|
891
947
|
</details>
|
|
892
948
|
|
|
893
|
-
#### `getControllers(
|
|
949
|
+
#### `getControllers()`
|
|
894
950
|
|
|
895
951
|
Returns the controllers of the configured ANT process.
|
|
896
952
|
|
|
897
953
|
```typescript
|
|
898
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
899
|
-
const ant = ANT.init({ processId });
|
|
900
954
|
const controllers = await ant.getControllers();
|
|
901
955
|
```
|
|
902
956
|
|
|
@@ -909,13 +963,11 @@ const controllers = await ant.getControllers();
|
|
|
909
963
|
|
|
910
964
|
</details>
|
|
911
965
|
|
|
912
|
-
#### `getRecords(
|
|
966
|
+
#### `getRecords()`
|
|
913
967
|
|
|
914
968
|
Returns all records on the configured ANT process, including the required `@` record that resolve connected ArNS names.
|
|
915
969
|
|
|
916
970
|
```typescript
|
|
917
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
918
|
-
const ant = ANT.init({ processId });
|
|
919
971
|
const records = await ant.getRecords();
|
|
920
972
|
```
|
|
921
973
|
|
|
@@ -961,12 +1013,11 @@ const records = await ant.getRecords();
|
|
|
961
1013
|
|
|
962
1014
|
Transfers ownership of the ANT to a new target address. Target MUST be an Arweave address.
|
|
963
1015
|
|
|
1016
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1017
|
+
|
|
964
1018
|
```typescript
|
|
965
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
966
|
-
const ant = ANT.init({ processId });
|
|
967
|
-
const recipient = 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f';
|
|
968
1019
|
const { id: txId } = await ant.transfer(
|
|
969
|
-
{ target:
|
|
1020
|
+
{ target: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
970
1021
|
// optional additional tags
|
|
971
1022
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
972
1023
|
);
|
|
@@ -976,12 +1027,11 @@ const { id: txId } = await ant.transfer(
|
|
|
976
1027
|
|
|
977
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.
|
|
978
1029
|
|
|
1030
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1031
|
+
|
|
979
1032
|
```typescript
|
|
980
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
981
|
-
const ant = ANT.init({ processId });
|
|
982
|
-
const controller = 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f';
|
|
983
1033
|
const { id: txId } = await ant.setController(
|
|
984
|
-
{ controller },
|
|
1034
|
+
{ controller: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
985
1035
|
// optional additional tags
|
|
986
1036
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
987
1037
|
);
|
|
@@ -991,50 +1041,45 @@ const { id: txId } = await ant.setController(
|
|
|
991
1041
|
|
|
992
1042
|
Removes a controller from the list of approved controllers on the ANT.
|
|
993
1043
|
|
|
1044
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1045
|
+
|
|
994
1046
|
```typescript
|
|
995
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
996
|
-
const ant = ANT.init({ processId });
|
|
997
|
-
const controller = 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f';
|
|
998
1047
|
const { id: txId } = await ant.removeController(
|
|
999
|
-
{ controller },
|
|
1048
|
+
{ controller: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
|
|
1000
1049
|
// optional additional tags
|
|
1001
1050
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1002
1051
|
);
|
|
1003
1052
|
```
|
|
1004
1053
|
|
|
1005
|
-
#### `setRecord({
|
|
1054
|
+
#### `setRecord({ undername, transactionId, ttlSeconds })`
|
|
1006
1055
|
|
|
1007
1056
|
Updates or creates a record in the ANT process.
|
|
1008
1057
|
|
|
1058
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1059
|
+
|
|
1009
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.
|
|
1010
1061
|
|
|
1011
1062
|
```typescript
|
|
1012
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
1013
|
-
const ant = ANT.init({ processId });
|
|
1014
|
-
const subDomain = 'test-domain';
|
|
1015
|
-
const transactionId = '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
1016
|
-
const ttlSeconds = 900;
|
|
1017
1063
|
const { id: txId } = await ant.setRecord(
|
|
1018
1064
|
{
|
|
1019
|
-
|
|
1020
|
-
transactionId
|
|
1021
|
-
ttlSeconds
|
|
1065
|
+
undername: '@',
|
|
1066
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
|
|
1067
|
+
ttlSeconds: 3600
|
|
1022
1068
|
},
|
|
1023
1069
|
// optional additional tags
|
|
1024
1070
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1025
1071
|
);
|
|
1026
1072
|
```
|
|
1027
1073
|
|
|
1028
|
-
#### `removeRecord({
|
|
1074
|
+
#### `removeRecord({ undername })`
|
|
1029
1075
|
|
|
1030
1076
|
Removes a record from the ANT process.
|
|
1031
1077
|
|
|
1078
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1079
|
+
|
|
1032
1080
|
```typescript
|
|
1033
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
1034
|
-
const ant = ANT.init({ processId });
|
|
1035
|
-
const subDomain = 'test-domain';
|
|
1036
1081
|
const { id: txId } = await ant.removeRecord(
|
|
1037
|
-
{
|
|
1082
|
+
{ undername: 'remove-domemain' },
|
|
1038
1083
|
// optional additional tags
|
|
1039
1084
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1040
1085
|
);
|
|
@@ -1044,12 +1089,11 @@ const { id: txId } = await ant.removeRecord(
|
|
|
1044
1089
|
|
|
1045
1090
|
Sets the name of the ANT process.
|
|
1046
1091
|
|
|
1092
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1093
|
+
|
|
1047
1094
|
```typescript
|
|
1048
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
1049
|
-
const ant = ANT.init({ processId });
|
|
1050
|
-
const name = 'chumbawumba';
|
|
1051
1095
|
const { id: txId } = await ant.setName(
|
|
1052
|
-
{ name },
|
|
1096
|
+
{ name: 'My ANT' },
|
|
1053
1097
|
// optional additional tags
|
|
1054
1098
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1055
1099
|
);
|
|
@@ -1059,24 +1103,32 @@ const { id: txId } = await ant.setName(
|
|
|
1059
1103
|
|
|
1060
1104
|
Sets the ticker of the ANT process.
|
|
1061
1105
|
|
|
1106
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1107
|
+
|
|
1062
1108
|
```typescript
|
|
1063
|
-
const processId = 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM';
|
|
1064
|
-
const ant = ANT.init({ processId });
|
|
1065
|
-
const ticker = 'ANT-WUMBA';
|
|
1066
1109
|
const { id: txId } = await ant.setTicker(
|
|
1067
|
-
{ ticker },
|
|
1110
|
+
{ ticker: 'ANT-NEW-TICKER' },
|
|
1111
|
+
// optional tags
|
|
1068
1112
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1069
1113
|
);
|
|
1070
1114
|
```
|
|
1071
1115
|
|
|
1072
1116
|
### Configuration
|
|
1073
1117
|
|
|
1074
|
-
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.
|
|
1075
1119
|
|
|
1076
1120
|
```typescript
|
|
1077
|
-
|
|
1078
|
-
const
|
|
1079
|
-
|
|
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
|
+
})
|
|
1080
1132
|
});
|
|
1081
1133
|
```
|
|
1082
1134
|
|
|
@@ -1125,3 +1177,6 @@ For more information on how to contribute, please see [CONTRIBUTING.md].
|
|
|
1125
1177
|
[examples/webpack]: ./examples/webpack
|
|
1126
1178
|
[examples/vite]: ./examples/vite
|
|
1127
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
|