@ar.io/sdk 3.22.2 → 3.23.0-alpha.2
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 +248 -248
- package/lib/cjs/cli/cli.js +11 -2
- package/lib/cjs/cli/options.js +5 -0
- package/lib/cjs/cli/utils.js +18 -2
- package/lib/cjs/common/ant-registry.js +1 -1
- package/lib/cjs/common/ant.js +10 -1
- package/lib/cjs/common/index.js +1 -0
- package/lib/cjs/common/loggers/winston.js +1 -1
- package/lib/cjs/common/marketplace.js +575 -0
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/utils/json.js +1 -1
- package/lib/cjs/utils/processes.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +11 -2
- package/lib/esm/cli/options.js +5 -0
- package/lib/esm/cli/utils.js +18 -2
- package/lib/esm/common/ant-registry.js +1 -1
- package/lib/esm/common/ant.js +10 -1
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/loggers/winston.js +1 -1
- package/lib/esm/common/marketplace.js +568 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/utils/json.js +1 -1
- package/lib/esm/utils/processes.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/options.d.ts +5 -0
- package/lib/types/common/ant.d.ts +7 -1
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/common/marketplace.d.ts +434 -0
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/types/ant.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +12 -25
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ yarn add @ar.io/sdk --ignore-engines
|
|
|
42
42
|
## Quick Start
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
import { ARIO } from
|
|
45
|
+
import { ARIO } from "@ar.io/sdk";
|
|
46
46
|
|
|
47
47
|
const ario = ARIO.mainnet(); // defaults to mainnet
|
|
48
48
|
const gateways = await ario.getGateways();
|
|
@@ -108,7 +108,7 @@ The SDK is provided in both CommonJS and ESM formats and is compatible with bund
|
|
|
108
108
|
#### Bundlers (Webpack, Rollup, ESbuild, etc.)
|
|
109
109
|
|
|
110
110
|
```javascript
|
|
111
|
-
import { ARIO } from
|
|
111
|
+
import { ARIO } from "@ar.io/sdk/web";
|
|
112
112
|
|
|
113
113
|
// set up client
|
|
114
114
|
const ario = ARIO.mainnet();
|
|
@@ -121,7 +121,7 @@ const gateways = await ario.getGateways();
|
|
|
121
121
|
```html
|
|
122
122
|
<script type="module">
|
|
123
123
|
// replace <version> with a release version (e.g. 3.8.4)
|
|
124
|
-
import { ARIO } from
|
|
124
|
+
import { ARIO } from "https://github.com/ar-io/ar-io-sdk/releases/download/v<version>/web.bundle.min.js";
|
|
125
125
|
|
|
126
126
|
// set up client
|
|
127
127
|
const ario = ARIO.mainnet();
|
|
@@ -135,7 +135,7 @@ const gateways = await ario.getGateways();
|
|
|
135
135
|
#### ESM (NodeNext)
|
|
136
136
|
|
|
137
137
|
```javascript
|
|
138
|
-
import { ARIO } from
|
|
138
|
+
import { ARIO } from "@ar.io/sdk/node";
|
|
139
139
|
|
|
140
140
|
// set up client
|
|
141
141
|
const ario = ARIO.mainnet();
|
|
@@ -146,7 +146,7 @@ const gateways = await ario.getGateways();
|
|
|
146
146
|
#### CJS
|
|
147
147
|
|
|
148
148
|
```javascript
|
|
149
|
-
import { ARIO } from
|
|
149
|
+
import { ARIO } from "@ar.io/sdk";
|
|
150
150
|
|
|
151
151
|
// set up client
|
|
152
152
|
const ario = ARIO.mainnet();
|
|
@@ -174,11 +174,12 @@ Factory function to that creates a read-only or writeable client. By providing a
|
|
|
174
174
|
const ario = ARIO.init();
|
|
175
175
|
|
|
176
176
|
// read-write client for browser environments
|
|
177
|
-
const ario = ARIO.init({
|
|
177
|
+
const ario = ARIO.init({
|
|
178
|
+
signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({})),
|
|
179
|
+
});
|
|
178
180
|
|
|
179
181
|
// read-write client for node environments
|
|
180
182
|
const ario = ARIO.init({ signer: new ArweaveSigner(JWK) });
|
|
181
|
-
|
|
182
183
|
```
|
|
183
184
|
|
|
184
185
|
#### `getInfo()`
|
|
@@ -250,7 +251,7 @@ const ario = ARIO.mainnet();
|
|
|
250
251
|
// the balance will be returned in mARIO as a value
|
|
251
252
|
const balance = await ario
|
|
252
253
|
.getBalance({
|
|
253
|
-
address:
|
|
254
|
+
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
254
255
|
})
|
|
255
256
|
.then((balance: number) => new mARIOToken(balance).toARIO()); // convert it to ARIO for readability
|
|
256
257
|
```
|
|
@@ -271,10 +272,10 @@ Retrieves the balances of the ARIO process in `mARIO`, paginated and sorted by t
|
|
|
271
272
|
```typescript
|
|
272
273
|
const ario = ARIO.mainnet();
|
|
273
274
|
const balances = await ario.getBalances({
|
|
274
|
-
cursor:
|
|
275
|
+
cursor: "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
275
276
|
limit: 100,
|
|
276
|
-
sortBy:
|
|
277
|
-
sortOrder:
|
|
277
|
+
sortBy: "balance",
|
|
278
|
+
sortOrder: "desc",
|
|
278
279
|
});
|
|
279
280
|
```
|
|
280
281
|
|
|
@@ -316,11 +317,11 @@ const ario = ARIO.mainnet({
|
|
|
316
317
|
});
|
|
317
318
|
const { id: txId } = await ario.transfer(
|
|
318
319
|
{
|
|
319
|
-
target:
|
|
320
|
+
target: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
320
321
|
qty: new ARIOToken(1000).toMARIO(),
|
|
321
322
|
},
|
|
322
323
|
// optional additional tags
|
|
323
|
-
{ tags: [{ name:
|
|
324
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
324
325
|
);
|
|
325
326
|
```
|
|
326
327
|
|
|
@@ -339,7 +340,7 @@ As of `v3.8.1` the SDK defaults all API interactions to **mainnet**. To use the
|
|
|
339
340
|
As of `v3.8.1` the SDK defaults all API interactions to **mainnet**. To use the **testnet** or **devnet** provide the appropriate `ARIO_TESTNET_PROCESS_ID` or `ARIO_DEVNET_PROCESS_ID` when initializing the client.
|
|
340
341
|
|
|
341
342
|
```typescript
|
|
342
|
-
import { ARIO } from
|
|
343
|
+
import { ARIO } from "@ar.io/sdk";
|
|
343
344
|
|
|
344
345
|
const ario = ARIO.mainnet(); // or ARIO.init()
|
|
345
346
|
```
|
|
@@ -347,7 +348,7 @@ const ario = ARIO.mainnet(); // or ARIO.init()
|
|
|
347
348
|
#### Testnet
|
|
348
349
|
|
|
349
350
|
```typescript
|
|
350
|
-
import { ARIO } from
|
|
351
|
+
import { ARIO } from "@ar.io/sdk";
|
|
351
352
|
|
|
352
353
|
const testnet = ARIO.testnet(); // or ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID })
|
|
353
354
|
```
|
|
@@ -369,7 +370,7 @@ To claim testnet tokens from the testnet token faucet, you can use one of the fo
|
|
|
369
370
|
<summary><i>Example client-side code for claiming tokens</i></summary>
|
|
370
371
|
|
|
371
372
|
```typescript
|
|
372
|
-
import { ARIO } from
|
|
373
|
+
import { ARIO } from "@ar.io/sdk";
|
|
373
374
|
|
|
374
375
|
const testnet = ARIO.testnet();
|
|
375
376
|
const captchaUrl = await ario.faucet.captchaUrl();
|
|
@@ -377,17 +378,17 @@ const captchaUrl = await ario.faucet.captchaUrl();
|
|
|
377
378
|
// open the captcha URL in the browser, and listen for the auth token event
|
|
378
379
|
const captchaWindow = window.open(
|
|
379
380
|
captchaUrl.captchaUrl,
|
|
380
|
-
|
|
381
|
-
|
|
381
|
+
"_blank",
|
|
382
|
+
"width=600,height=600",
|
|
382
383
|
);
|
|
383
384
|
/**
|
|
384
385
|
* The captcha URL includes a window.parent.postMessage event that is used to send the auth token to the parent window.
|
|
385
386
|
* You can store the auth token in localStorage and use it to claim tokens for the duration of the auth token's expiration (default 1 hour).
|
|
386
387
|
*/
|
|
387
|
-
window.parent.addEventListener(
|
|
388
|
-
if (event.data.type ===
|
|
389
|
-
localStorage.setItem(
|
|
390
|
-
localStorage.setItem(
|
|
388
|
+
window.parent.addEventListener("message", async (event) => {
|
|
389
|
+
if (event.data.type === "ario-jwt-success") {
|
|
390
|
+
localStorage.setItem("ario-jwt", event.data.token);
|
|
391
|
+
localStorage.setItem("ario-jwt-expires-at", event.data.expiresAt);
|
|
391
392
|
// close our captcha window
|
|
392
393
|
captchaWindow?.close();
|
|
393
394
|
// claim the tokens using the JWT token
|
|
@@ -399,7 +400,7 @@ window.parent.addEventListener('message', async (event) => {
|
|
|
399
400
|
})
|
|
400
401
|
.then((res) => {
|
|
401
402
|
alert(
|
|
402
|
-
|
|
403
|
+
"Successfully claimed 100 ARIO tokens! Transaction ID: " + res.id,
|
|
403
404
|
);
|
|
404
405
|
})
|
|
405
406
|
.catch((err) => {
|
|
@@ -412,11 +413,11 @@ window.parent.addEventListener('message', async (event) => {
|
|
|
412
413
|
* Once you have a valid JWT, you can check if it is still valid and use it for subsequent requests without having to open the captcha again.
|
|
413
414
|
*/
|
|
414
415
|
if (
|
|
415
|
-
localStorage.getItem(
|
|
416
|
-
Date.now() < parseInt(localStorage.getItem(
|
|
416
|
+
localStorage.getItem("ario-jwt-expires-at") &&
|
|
417
|
+
Date.now() < parseInt(localStorage.getItem("ario-jwt-expires-at") ?? "0")
|
|
417
418
|
) {
|
|
418
419
|
const res = await testnet.faucet.claimWithAuthToken({
|
|
419
|
-
authToken: localStorage.getItem(
|
|
420
|
+
authToken: localStorage.getItem("ario-jwt") ?? "",
|
|
420
421
|
recipient: await window.arweaveWallet.getActiveAddress(),
|
|
421
422
|
quantity: new ARIOToken(100).toMARIO().valueOf(), // 100 ARIO
|
|
422
423
|
});
|
|
@@ -434,8 +435,8 @@ Retrieves the locked-balance user vault of the ARIO process by the specified wal
|
|
|
434
435
|
```typescript
|
|
435
436
|
const ario = ARIO.mainnet();
|
|
436
437
|
const vault = await ario.getVault({
|
|
437
|
-
address:
|
|
438
|
-
vaultId:
|
|
438
|
+
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
439
|
+
vaultId: "vaultIdOne",
|
|
439
440
|
});
|
|
440
441
|
```
|
|
441
442
|
|
|
@@ -459,10 +460,10 @@ Retrieves all locked-balance user vaults of the ARIO process, paginated and sort
|
|
|
459
460
|
```typescript
|
|
460
461
|
const ario = ARIO.mainnet();
|
|
461
462
|
const vaults = await ario.getVaults({
|
|
462
|
-
cursor:
|
|
463
|
+
cursor: "0",
|
|
463
464
|
limit: 100,
|
|
464
|
-
sortBy:
|
|
465
|
-
sortOrder:
|
|
465
|
+
sortBy: "balance",
|
|
466
|
+
sortOrder: "desc",
|
|
466
467
|
});
|
|
467
468
|
```
|
|
468
469
|
|
|
@@ -508,13 +509,13 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
508
509
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
509
510
|
const { id: txId } = await ario.vaultedTransfer(
|
|
510
511
|
{
|
|
511
|
-
recipient:
|
|
512
|
+
recipient: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
512
513
|
quantity: new ARIOToken(1000).toMARIO(),
|
|
513
514
|
lockLengthMs: 1000 * 60 * 60 * 24 * 365, // 1 year
|
|
514
515
|
revokable: true,
|
|
515
516
|
},
|
|
516
517
|
// optional additional tags
|
|
517
|
-
{ tags: [{ name:
|
|
518
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
518
519
|
);
|
|
519
520
|
```
|
|
520
521
|
|
|
@@ -527,8 +528,8 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
527
528
|
```typescript
|
|
528
529
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
529
530
|
const { id: txId } = await ario.revokeVault({
|
|
530
|
-
recipient:
|
|
531
|
-
vaultId:
|
|
531
|
+
recipient: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
532
|
+
vaultId: "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
532
533
|
});
|
|
533
534
|
```
|
|
534
535
|
|
|
@@ -553,7 +554,7 @@ Extends the lock length of a signer's vault by the specified `extendLengthMs` mi
|
|
|
553
554
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
554
555
|
|
|
555
556
|
const { id: txId } = await ario.extendVault({
|
|
556
|
-
vaultId:
|
|
557
|
+
vaultId: "vaultIdOne",
|
|
557
558
|
extendLengthMs: 1000 * 60 * 60 * 24 * 365, // 1 year
|
|
558
559
|
});
|
|
559
560
|
```
|
|
@@ -565,7 +566,7 @@ Increases the balance of a signer's vault by the specified `quantity` of mARIO.
|
|
|
565
566
|
```typescript
|
|
566
567
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
567
568
|
const { id: txId } = await ario.increaseVault({
|
|
568
|
-
vaultId:
|
|
569
|
+
vaultId: "vaultIdOne",
|
|
569
570
|
quantity: new ARIOToken(1000).toMARIO(),
|
|
570
571
|
});
|
|
571
572
|
```
|
|
@@ -579,7 +580,7 @@ Retrieves a gateway's info by its staking wallet address.
|
|
|
579
580
|
```typescript
|
|
580
581
|
const ario = ARIO.mainnet();
|
|
581
582
|
const gateway = await ario.getGateway({
|
|
582
|
-
address:
|
|
583
|
+
address: "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
|
|
583
584
|
});
|
|
584
585
|
```
|
|
585
586
|
|
|
@@ -629,8 +630,8 @@ Retrieves registered gateways of the ARIO process, using pagination and sorting
|
|
|
629
630
|
const ario = ARIO.mainnet();
|
|
630
631
|
const gateways = await ario.getGateways({
|
|
631
632
|
limit: 100,
|
|
632
|
-
sortOrder:
|
|
633
|
-
sortBy:
|
|
633
|
+
sortOrder: "desc",
|
|
634
|
+
sortBy: "operatorStake",
|
|
634
635
|
});
|
|
635
636
|
```
|
|
636
637
|
|
|
@@ -691,10 +692,10 @@ Retrieves all delegates for a specific gateway, paginated and sorted by the spec
|
|
|
691
692
|
```typescript
|
|
692
693
|
const ario = ARIO.mainnet();
|
|
693
694
|
const delegates = await ario.getGatewayDelegates({
|
|
694
|
-
address:
|
|
695
|
+
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
695
696
|
limit: 3,
|
|
696
|
-
sortBy:
|
|
697
|
-
sortOrder:
|
|
697
|
+
sortBy: "startTimestamp",
|
|
698
|
+
sortOrder: "desc",
|
|
698
699
|
});
|
|
699
700
|
```
|
|
700
701
|
|
|
@@ -746,16 +747,16 @@ const { id: txId } = await ario.joinNetwork(
|
|
|
746
747
|
allowDelegatedStaking: true, // allows delegated staking
|
|
747
748
|
minDelegatedStake: new ARIOToken(100).toMARIO(), // minimum delegated stake allowed
|
|
748
749
|
delegateRewardShareRatio: 10, // percentage of rewards to share with delegates (e.g. 10%)
|
|
749
|
-
label:
|
|
750
|
-
note:
|
|
751
|
-
properties:
|
|
752
|
-
observerWallet:
|
|
753
|
-
fqdn:
|
|
750
|
+
label: "john smith", // min 1, max 64 characters
|
|
751
|
+
note: "The example gateway", // max 256 characters
|
|
752
|
+
properties: "FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44", // Arweave transaction ID containing additional properties of the Gateway
|
|
753
|
+
observerWallet: "0VE0wIhDy90WiQoV3U2PeY44FH1aVetOoulPGqgYukj", // wallet address of the observer, must match OBSERVER_WALLET on the observer
|
|
754
|
+
fqdn: "example.com", // fully qualified domain name - note: you must own the domain and set the OBSERVER_WALLET on your gateway to match `observerWallet`
|
|
754
755
|
port: 443, // port number
|
|
755
|
-
protocol:
|
|
756
|
+
protocol: "https", // only 'https' is supported
|
|
756
757
|
},
|
|
757
758
|
// optional additional tags
|
|
758
|
-
{ tags: [{ name:
|
|
759
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
759
760
|
);
|
|
760
761
|
```
|
|
761
762
|
|
|
@@ -770,7 +771,7 @@ const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
|
770
771
|
|
|
771
772
|
const { id: txId } = await ario.leaveNetwork(
|
|
772
773
|
// optional additional tags
|
|
773
|
-
{ tags: [{ name:
|
|
774
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
774
775
|
);
|
|
775
776
|
```
|
|
776
777
|
|
|
@@ -788,7 +789,7 @@ const { id: txId } = await ario.updateGatewaySettings(
|
|
|
788
789
|
minDelegatedStake: new ARIOToken(100).toMARIO(),
|
|
789
790
|
},
|
|
790
791
|
// optional additional tags
|
|
791
|
-
{ tags: [{ name:
|
|
792
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
792
793
|
);
|
|
793
794
|
```
|
|
794
795
|
|
|
@@ -802,11 +803,11 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
802
803
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
803
804
|
const { id: txId } = await ario.increaseDelegateStake(
|
|
804
805
|
{
|
|
805
|
-
target:
|
|
806
|
+
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
806
807
|
qty: new ARIOToken(100).toMARIO(),
|
|
807
808
|
},
|
|
808
809
|
// optional additional tags
|
|
809
|
-
{ tags: [{ name:
|
|
810
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
810
811
|
);
|
|
811
812
|
```
|
|
812
813
|
|
|
@@ -820,11 +821,11 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
820
821
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
821
822
|
const { id: txId } = await ario.decreaseDelegateStake(
|
|
822
823
|
{
|
|
823
|
-
target:
|
|
824
|
+
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
824
825
|
qty: new ARIOToken(100).toMARIO(),
|
|
825
826
|
},
|
|
826
827
|
{
|
|
827
|
-
tags: [{ name:
|
|
828
|
+
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
|
|
828
829
|
},
|
|
829
830
|
);
|
|
830
831
|
```
|
|
@@ -834,7 +835,7 @@ Pay the early withdrawal fee and withdraw instantly.
|
|
|
834
835
|
```typescript
|
|
835
836
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
836
837
|
const { id: txId } = await ario.decreaseDelegateStake({
|
|
837
|
-
target:
|
|
838
|
+
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
838
839
|
qty: new ARIOToken(100).toMARIO(),
|
|
839
840
|
instant: true, // Immediately withdraw this stake and pay the instant withdrawal fee
|
|
840
841
|
});
|
|
@@ -847,11 +848,11 @@ Retrieves all active and vaulted stakes across all gateways for a specific addre
|
|
|
847
848
|
```typescript
|
|
848
849
|
const ario = ARIO.mainnet();
|
|
849
850
|
const vaults = await ario.getDelegations({
|
|
850
|
-
address:
|
|
851
|
-
cursor:
|
|
851
|
+
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
852
|
+
cursor: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_123456789",
|
|
852
853
|
limit: 2,
|
|
853
|
-
sortBy:
|
|
854
|
-
sortOrder:
|
|
854
|
+
sortBy: "startTimestamp",
|
|
855
|
+
sortOrder: "asc",
|
|
855
856
|
});
|
|
856
857
|
```
|
|
857
858
|
|
|
@@ -901,21 +902,19 @@ const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
|
901
902
|
const { id: txId } = await ario.instantWithdrawal(
|
|
902
903
|
{
|
|
903
904
|
// gateway address where delegate vault exists
|
|
904
|
-
gatewayAddress:
|
|
905
|
+
gatewayAddress: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
905
906
|
// delegated vault id to cancel
|
|
906
|
-
vaultId:
|
|
907
|
+
vaultId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
907
908
|
},
|
|
908
909
|
// optional additional tags
|
|
909
910
|
{
|
|
910
|
-
tags: [{ name:
|
|
911
|
+
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
|
|
911
912
|
},
|
|
912
913
|
);
|
|
913
914
|
// removes an operator vault from a gateway
|
|
914
|
-
const { id: txId } = await ario.instantWithdrawal(
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
},
|
|
918
|
-
);
|
|
915
|
+
const { id: txId } = await ario.instantWithdrawal({
|
|
916
|
+
vaultId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
917
|
+
});
|
|
919
918
|
```
|
|
920
919
|
|
|
921
920
|
#### `cancelWithdrawal({ gatewayAddress, vaultId })`
|
|
@@ -930,20 +929,18 @@ const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
|
930
929
|
const { id: txId } = await ario.cancelWithdrawal(
|
|
931
930
|
{
|
|
932
931
|
// gateway address where vault exists
|
|
933
|
-
gatewayAddress:
|
|
932
|
+
gatewayAddress: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
934
933
|
// vault id to cancel
|
|
935
|
-
vaultId:
|
|
934
|
+
vaultId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
936
935
|
},
|
|
937
936
|
// optional additional tags
|
|
938
|
-
{ tags: [{ name:
|
|
937
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
939
938
|
);
|
|
940
939
|
// cancels an operator vault from a gateway
|
|
941
|
-
const { id: txId } = await ario.cancelWithdrawal(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
},
|
|
946
|
-
);
|
|
940
|
+
const { id: txId } = await ario.cancelWithdrawal({
|
|
941
|
+
// operator vault id to cancel
|
|
942
|
+
vaultId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
943
|
+
});
|
|
947
944
|
```
|
|
948
945
|
|
|
949
946
|
#### `getAllowedDelegates({ address, cursor, limit, sortBy, sortOrder })`
|
|
@@ -953,7 +950,7 @@ Retrieves all allowed delegates for a specific address. The `cursor` used for pa
|
|
|
953
950
|
```typescript
|
|
954
951
|
const ario = ARIO.mainnet();
|
|
955
952
|
const allowedDelegates = await ario.getAllowedDelegates({
|
|
956
|
-
address:
|
|
953
|
+
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
957
954
|
});
|
|
958
955
|
```
|
|
959
956
|
|
|
@@ -1020,8 +1017,8 @@ Retrieves all vaults across all gateways, paginated and sorted by the specified
|
|
|
1020
1017
|
const ario = ARIO.mainnet();
|
|
1021
1018
|
const vaults = await ario.getAllGatewayVaults({
|
|
1022
1019
|
limit: 1,
|
|
1023
|
-
sortBy:
|
|
1024
|
-
sortOrder:
|
|
1020
|
+
sortBy: "endTimestamp",
|
|
1021
|
+
sortOrder: "desc",
|
|
1025
1022
|
});
|
|
1026
1023
|
```
|
|
1027
1024
|
|
|
@@ -1064,7 +1061,7 @@ const { id: txId } = await ario.increaseOperatorStake(
|
|
|
1064
1061
|
qty: new ARIOToken(100).toMARIO(),
|
|
1065
1062
|
},
|
|
1066
1063
|
{
|
|
1067
|
-
tags: [{ name:
|
|
1064
|
+
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
|
|
1068
1065
|
},
|
|
1069
1066
|
);
|
|
1070
1067
|
```
|
|
@@ -1082,7 +1079,7 @@ const { id: txId } = await ario.decreaseOperatorStake(
|
|
|
1082
1079
|
qty: new ARIOToken(100).toMARIO(),
|
|
1083
1080
|
},
|
|
1084
1081
|
{
|
|
1085
|
-
tags: [{ name:
|
|
1082
|
+
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
|
|
1086
1083
|
},
|
|
1087
1084
|
);
|
|
1088
1085
|
```
|
|
@@ -1097,10 +1094,10 @@ e.g: If 1000 mARIO is redelegated and the fee rate is 10%, the fee will be 100 m
|
|
|
1097
1094
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
1098
1095
|
|
|
1099
1096
|
const { id: txId } = await ario.redelegateStake({
|
|
1100
|
-
target:
|
|
1101
|
-
source:
|
|
1097
|
+
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1098
|
+
source: "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
|
|
1102
1099
|
stakeQty: new ARIOToken(1000).toMARIO(),
|
|
1103
|
-
vaultId:
|
|
1100
|
+
vaultId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
1104
1101
|
});
|
|
1105
1102
|
```
|
|
1106
1103
|
|
|
@@ -1112,7 +1109,7 @@ Retrieves the fee rate as percentage required to redelegate the stake of a speci
|
|
|
1112
1109
|
const ario = ARIO.mainnet();
|
|
1113
1110
|
|
|
1114
1111
|
const fee = await ario.getRedelegationFee({
|
|
1115
|
-
address:
|
|
1112
|
+
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1116
1113
|
});
|
|
1117
1114
|
```
|
|
1118
1115
|
|
|
@@ -1136,8 +1133,8 @@ Retrieves all delegates across all gateways, paginated and sorted by the specifi
|
|
|
1136
1133
|
const ario = ARIO.mainnet();
|
|
1137
1134
|
const delegates = await ario.getAllDelegates({
|
|
1138
1135
|
limit: 2,
|
|
1139
|
-
sortBy:
|
|
1140
|
-
sortOrder:
|
|
1136
|
+
sortBy: "startTimestamp",
|
|
1137
|
+
sortOrder: "desc",
|
|
1141
1138
|
});
|
|
1142
1139
|
```
|
|
1143
1140
|
|
|
@@ -1185,7 +1182,7 @@ Resolves an ArNS name to the underlying data id stored on the names correspondin
|
|
|
1185
1182
|
|
|
1186
1183
|
```typescript
|
|
1187
1184
|
const ario = ARIO.mainnet();
|
|
1188
|
-
const record = await ario.resolveArNSName({ name:
|
|
1185
|
+
const record = await ario.resolveArNSName({ name: "ardrive" });
|
|
1189
1186
|
```
|
|
1190
1187
|
|
|
1191
1188
|
<details>
|
|
@@ -1209,7 +1206,7 @@ const record = await ario.resolveArNSName({ name: 'ardrive' });
|
|
|
1209
1206
|
|
|
1210
1207
|
```typescript
|
|
1211
1208
|
const ario = ARIO.mainnet();
|
|
1212
|
-
const record = await ario.resolveArNSName({ name:
|
|
1209
|
+
const record = await ario.resolveArNSName({ name: "logo_ardrive" });
|
|
1213
1210
|
```
|
|
1214
1211
|
|
|
1215
1212
|
<details>
|
|
@@ -1247,28 +1244,28 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1247
1244
|
const ario = ARIO.mainnet({ signer });
|
|
1248
1245
|
const record = await ario.buyRecord(
|
|
1249
1246
|
{
|
|
1250
|
-
name:
|
|
1251
|
-
type:
|
|
1247
|
+
name: "ardrive",
|
|
1248
|
+
type: "lease",
|
|
1252
1249
|
years: 1,
|
|
1253
|
-
processId:
|
|
1254
|
-
referrer:
|
|
1250
|
+
processId: "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", // optional: assign to existing ANT process
|
|
1251
|
+
referrer: "my-app.com", // optional: track purchase referrals for analytics
|
|
1255
1252
|
},
|
|
1256
1253
|
{
|
|
1257
1254
|
// optional tags
|
|
1258
|
-
tags: [{ name:
|
|
1255
|
+
tags: [{ name: "App-Name", value: "ArNS-App" }],
|
|
1259
1256
|
onSigningProgress: (step, event) => {
|
|
1260
1257
|
console.log(`Signing progress: ${step}`);
|
|
1261
|
-
if (step ===
|
|
1262
|
-
console.log(
|
|
1258
|
+
if (step === "spawning-ant") {
|
|
1259
|
+
console.log("Spawning ant:", event);
|
|
1263
1260
|
}
|
|
1264
|
-
if (step ===
|
|
1265
|
-
console.log(
|
|
1261
|
+
if (step === "registering-ant") {
|
|
1262
|
+
console.log("Registering ant:", event);
|
|
1266
1263
|
}
|
|
1267
|
-
if (step ===
|
|
1268
|
-
console.log(
|
|
1264
|
+
if (step === "verifying-state") {
|
|
1265
|
+
console.log("Verifying state:", event);
|
|
1269
1266
|
}
|
|
1270
|
-
if (step ===
|
|
1271
|
-
console.log(
|
|
1267
|
+
if (step === "buying-name") {
|
|
1268
|
+
console.log("Buying name:", event);
|
|
1272
1269
|
}
|
|
1273
1270
|
},
|
|
1274
1271
|
},
|
|
@@ -1285,12 +1282,12 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1285
1282
|
const ario = ARIO.mainnet({ signer });
|
|
1286
1283
|
const record = await ario.upgradeRecord(
|
|
1287
1284
|
{
|
|
1288
|
-
name:
|
|
1289
|
-
referrer:
|
|
1285
|
+
name: "ardrive",
|
|
1286
|
+
referrer: "my-app.com", // optional: track purchase referrals for analytics
|
|
1290
1287
|
},
|
|
1291
1288
|
{
|
|
1292
1289
|
// optional tags
|
|
1293
|
-
tags: [{ name:
|
|
1290
|
+
tags: [{ name: "App-Name", value: "ArNS-App" }],
|
|
1294
1291
|
},
|
|
1295
1292
|
);
|
|
1296
1293
|
```
|
|
@@ -1301,7 +1298,7 @@ Retrieves the record info of the specified ArNS name.
|
|
|
1301
1298
|
|
|
1302
1299
|
```typescript
|
|
1303
1300
|
const ario = ARIO.mainnet();
|
|
1304
|
-
const record = await ario.getArNSRecord({ name:
|
|
1301
|
+
const record = await ario.getArNSRecord({ name: "ardrive" });
|
|
1305
1302
|
```
|
|
1306
1303
|
|
|
1307
1304
|
<details>
|
|
@@ -1328,8 +1325,8 @@ const ario = ARIO.mainnet();
|
|
|
1328
1325
|
// get the newest 100 names
|
|
1329
1326
|
const records = await ario.getArNSRecords({
|
|
1330
1327
|
limit: 100,
|
|
1331
|
-
sortBy:
|
|
1332
|
-
sortOrder:
|
|
1328
|
+
sortBy: "startTimestamp",
|
|
1329
|
+
sortOrder: "desc",
|
|
1333
1330
|
});
|
|
1334
1331
|
```
|
|
1335
1332
|
|
|
@@ -1405,10 +1402,10 @@ Retrieves all registered ArNS records of the specified address according to the
|
|
|
1405
1402
|
```typescript
|
|
1406
1403
|
const ario = ARIO.mainnet();
|
|
1407
1404
|
const records = await ario.getArNSRecordsForAddress({
|
|
1408
|
-
address:
|
|
1405
|
+
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1409
1406
|
limit: 100,
|
|
1410
|
-
sortBy:
|
|
1411
|
-
sortOrder:
|
|
1407
|
+
sortBy: "startTimestamp",
|
|
1408
|
+
sortOrder: "desc",
|
|
1412
1409
|
});
|
|
1413
1410
|
```
|
|
1414
1411
|
|
|
@@ -1451,12 +1448,12 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1451
1448
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
1452
1449
|
const { id: txId } = await ario.increaseUndernameLimit(
|
|
1453
1450
|
{
|
|
1454
|
-
name:
|
|
1451
|
+
name: "ar-io",
|
|
1455
1452
|
qty: 420,
|
|
1456
|
-
referrer:
|
|
1453
|
+
referrer: "my-app.com", // optional: track purchase referrals for analytics
|
|
1457
1454
|
},
|
|
1458
1455
|
// optional additional tags
|
|
1459
|
-
{ tags: [{ name:
|
|
1456
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
1460
1457
|
);
|
|
1461
1458
|
```
|
|
1462
1459
|
|
|
@@ -1468,12 +1465,12 @@ Extends the lease of a registered ArNS domain, with an extension of 1-5 years de
|
|
|
1468
1465
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
1469
1466
|
const { id: txId } = await ario.extendLease(
|
|
1470
1467
|
{
|
|
1471
|
-
name:
|
|
1468
|
+
name: "ar-io",
|
|
1472
1469
|
years: 1,
|
|
1473
|
-
referrer:
|
|
1470
|
+
referrer: "my-app.com", // optional: track purchase referrals for analytics
|
|
1474
1471
|
},
|
|
1475
1472
|
// optional additional tags
|
|
1476
|
-
{ tags: [{ name:
|
|
1473
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
1477
1474
|
);
|
|
1478
1475
|
```
|
|
1479
1476
|
|
|
@@ -1484,9 +1481,9 @@ Calculates the price in mARIO to perform the interaction in question, eg a 'Buy-
|
|
|
1484
1481
|
```typescript
|
|
1485
1482
|
const price = await ario
|
|
1486
1483
|
.getTokenCost({
|
|
1487
|
-
intent:
|
|
1488
|
-
name:
|
|
1489
|
-
type:
|
|
1484
|
+
intent: "Buy-Name",
|
|
1485
|
+
name: "ar-io",
|
|
1486
|
+
type: "permabuy",
|
|
1490
1487
|
})
|
|
1491
1488
|
.then((p) => new mARIOToken(p).toARIO()); // convert to ARIO for readability
|
|
1492
1489
|
```
|
|
@@ -1506,11 +1503,11 @@ Calculates the expanded cost details for the interaction in question, e.g a 'Buy
|
|
|
1506
1503
|
|
|
1507
1504
|
```typescript
|
|
1508
1505
|
const costDetails = await ario.getCostDetails({
|
|
1509
|
-
intent:
|
|
1510
|
-
fromAddress:
|
|
1511
|
-
fundFrom:
|
|
1512
|
-
name:
|
|
1513
|
-
type:
|
|
1506
|
+
intent: "Buy-Name",
|
|
1507
|
+
fromAddress: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1508
|
+
fundFrom: "stakes",
|
|
1509
|
+
name: "ar-io",
|
|
1510
|
+
type: "permabuy",
|
|
1514
1511
|
});
|
|
1515
1512
|
```
|
|
1516
1513
|
|
|
@@ -1563,8 +1560,8 @@ Retrieves all active returned names of the ARIO process, paginated and sorted by
|
|
|
1563
1560
|
const ario = ARIO.mainnet();
|
|
1564
1561
|
const returnedNames = await ario.getArNSReturnedNames({
|
|
1565
1562
|
limit: 100,
|
|
1566
|
-
sortBy:
|
|
1567
|
-
sortOrder:
|
|
1563
|
+
sortBy: "endTimestamp",
|
|
1564
|
+
sortOrder: "asc", // return the returned names ending soonest first
|
|
1568
1565
|
});
|
|
1569
1566
|
```
|
|
1570
1567
|
|
|
@@ -1604,7 +1601,7 @@ Retrieves the returned name data for the specified returned name.
|
|
|
1604
1601
|
|
|
1605
1602
|
```typescript
|
|
1606
1603
|
const ario = ARIO.mainnet();
|
|
1607
|
-
const returnedName = await ario.getArNSReturnedName({ name:
|
|
1604
|
+
const returnedName = await ario.getArNSReturnedName({ name: "permalink" });
|
|
1608
1605
|
```
|
|
1609
1606
|
|
|
1610
1607
|
<details>
|
|
@@ -1859,11 +1856,11 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1859
1856
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
1860
1857
|
const { id: txId } = await ario.saveObservations(
|
|
1861
1858
|
{
|
|
1862
|
-
reportTxId:
|
|
1863
|
-
failedGateways: [
|
|
1859
|
+
reportTxId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
1860
|
+
failedGateways: ["t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3"],
|
|
1864
1861
|
},
|
|
1865
1862
|
{
|
|
1866
|
-
tags: [{ name:
|
|
1863
|
+
tags: [{ name: "App-Name", value: "My-Awesome-App" }],
|
|
1867
1864
|
},
|
|
1868
1865
|
);
|
|
1869
1866
|
```
|
|
@@ -1910,10 +1907,10 @@ Retrieves all primary names paginated and sorted by the specified criteria. The
|
|
|
1910
1907
|
```typescript
|
|
1911
1908
|
const ario = ARIO.mainnet();
|
|
1912
1909
|
const names = await ario.getPrimaryNames({
|
|
1913
|
-
cursor:
|
|
1910
|
+
cursor: "ao", // this is the last name from the previous request
|
|
1914
1911
|
limit: 1,
|
|
1915
|
-
sortBy:
|
|
1916
|
-
sortOrder:
|
|
1912
|
+
sortBy: "startTimestamp",
|
|
1913
|
+
sortOrder: "desc",
|
|
1917
1914
|
});
|
|
1918
1915
|
```
|
|
1919
1916
|
|
|
@@ -1947,11 +1944,11 @@ Retrieves the primary name for a given name or address.
|
|
|
1947
1944
|
```typescript
|
|
1948
1945
|
const ario = ARIO.mainnet();
|
|
1949
1946
|
const name = await ario.getPrimaryName({
|
|
1950
|
-
name:
|
|
1947
|
+
name: "arns",
|
|
1951
1948
|
});
|
|
1952
1949
|
// or
|
|
1953
1950
|
const name = await ario.getPrimaryName({
|
|
1954
|
-
address:
|
|
1951
|
+
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1955
1952
|
});
|
|
1956
1953
|
```
|
|
1957
1954
|
|
|
@@ -1977,7 +1974,7 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1977
1974
|
```typescript
|
|
1978
1975
|
const signer = new ArweaveSigner(jwk);
|
|
1979
1976
|
const ario = ARIO.mainnet({ signer });
|
|
1980
|
-
await ario.setPrimaryName({ name:
|
|
1977
|
+
await ario.setPrimaryName({ name: "my-arns-name" }); // the caller must already have purchased the name my-arns-name and be assigned as the owner of the processId that is assigned to the name
|
|
1981
1978
|
```
|
|
1982
1979
|
|
|
1983
1980
|
#### `requestPrimaryName({ name })`
|
|
@@ -1989,7 +1986,7 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1989
1986
|
```typescript
|
|
1990
1987
|
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
|
|
1991
1988
|
const { id: txId } = await ario.requestPrimaryName({
|
|
1992
|
-
name:
|
|
1989
|
+
name: "arns",
|
|
1993
1990
|
});
|
|
1994
1991
|
```
|
|
1995
1992
|
|
|
@@ -2000,7 +1997,7 @@ Retrieves the primary name request for a a wallet address.
|
|
|
2000
1997
|
```typescript
|
|
2001
1998
|
const ario = ARIO.mainnet();
|
|
2002
1999
|
const request = await ario.getPrimaryNameRequest({
|
|
2003
|
-
initiator:
|
|
2000
|
+
initiator: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
2004
2001
|
});
|
|
2005
2002
|
```
|
|
2006
2003
|
|
|
@@ -2055,15 +2052,14 @@ Factory function to that creates a read-only or writeable client. By providing a
|
|
|
2055
2052
|
// in a browser environment with ArConnect
|
|
2056
2053
|
const ant = ANT.init({
|
|
2057
2054
|
signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({})),
|
|
2058
|
-
processId:
|
|
2055
|
+
processId: "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2059
2056
|
});
|
|
2060
2057
|
|
|
2061
2058
|
// in a node environment
|
|
2062
2059
|
const ant = ANT.init({
|
|
2063
2060
|
signer: new ArweaveSigner(JWK),
|
|
2064
|
-
processId:
|
|
2061
|
+
processId: "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2065
2062
|
});
|
|
2066
|
-
|
|
2067
2063
|
```
|
|
2068
2064
|
|
|
2069
2065
|
### Spawn
|
|
@@ -2075,26 +2071,26 @@ Spawns a new ANT (Arweave Name Token) process. This static function creates a ne
|
|
|
2075
2071
|
_Note: Requires `signer` to be provided to sign the spawn transaction._
|
|
2076
2072
|
|
|
2077
2073
|
```typescript
|
|
2078
|
-
import { ANT } from
|
|
2079
|
-
import { ArweaveSigner } from
|
|
2074
|
+
import { ANT } from "@ar.io/sdk";
|
|
2075
|
+
import { ArweaveSigner } from "@ar.io/sdk/node";
|
|
2080
2076
|
|
|
2081
2077
|
const processId = await ANT.spawn({
|
|
2082
2078
|
signer: new ArweaveSigner(jwk),
|
|
2083
2079
|
state: {
|
|
2084
|
-
name:
|
|
2085
|
-
ticker:
|
|
2086
|
-
description:
|
|
2080
|
+
name: "My ANT",
|
|
2081
|
+
ticker: "MYANT",
|
|
2082
|
+
description: "My custom ANT token",
|
|
2087
2083
|
},
|
|
2088
2084
|
});
|
|
2089
2085
|
|
|
2090
2086
|
// Using a custom module ID
|
|
2091
2087
|
const processId = await ANT.spawn({
|
|
2092
2088
|
signer: new ArweaveSigner(jwk),
|
|
2093
|
-
module:
|
|
2089
|
+
module: "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE", // Custom module ID
|
|
2094
2090
|
state: {
|
|
2095
|
-
name:
|
|
2096
|
-
ticker:
|
|
2097
|
-
description:
|
|
2091
|
+
name: "My Custom Module ANT",
|
|
2092
|
+
ticker: "CUSTOM",
|
|
2093
|
+
description: "ANT using a specific module version",
|
|
2098
2094
|
},
|
|
2099
2095
|
});
|
|
2100
2096
|
```
|
|
@@ -2134,8 +2130,8 @@ console.log(`ANT was spawned with module: ${moduleId}`);
|
|
|
2134
2130
|
|
|
2135
2131
|
// With custom GraphQL URL and retries
|
|
2136
2132
|
const moduleId = await ant.getModuleId({
|
|
2137
|
-
graphqlUrl:
|
|
2138
|
-
retries: 5
|
|
2133
|
+
graphqlUrl: "https://arweave.net/graphql",
|
|
2134
|
+
retries: 5,
|
|
2139
2135
|
});
|
|
2140
2136
|
```
|
|
2141
2137
|
|
|
@@ -2158,7 +2154,7 @@ console.log(`ANT is running version: ${version}`);
|
|
|
2158
2154
|
|
|
2159
2155
|
// With custom ANT registry
|
|
2160
2156
|
const version = await ant.getVersion({
|
|
2161
|
-
antRegistryId:
|
|
2157
|
+
antRegistryId: "custom-ant-registry-id",
|
|
2162
2158
|
});
|
|
2163
2159
|
```
|
|
2164
2160
|
|
|
@@ -2178,7 +2174,7 @@ Checks if the current ANT version is the latest according to the ANT registry.
|
|
|
2178
2174
|
```typescript
|
|
2179
2175
|
const isLatest = await ant.isLatestVersion();
|
|
2180
2176
|
if (!isLatest) {
|
|
2181
|
-
console.log(
|
|
2177
|
+
console.log("ANT can be upgraded to the latest version");
|
|
2182
2178
|
}
|
|
2183
2179
|
```
|
|
2184
2180
|
|
|
@@ -2196,7 +2192,7 @@ true
|
|
|
2196
2192
|
Static method that returns the full array of available ANT versions and the latest version from the ANT registry.
|
|
2197
2193
|
|
|
2198
2194
|
```typescript
|
|
2199
|
-
import { ANT } from
|
|
2195
|
+
import { ANT } from "@ar.io/sdk";
|
|
2200
2196
|
|
|
2201
2197
|
// Get all available ANT versions
|
|
2202
2198
|
const antVersions = ANT.versions;
|
|
@@ -2224,10 +2220,10 @@ Result:
|
|
|
2224
2220
|
Static method that returns the latest ANT version from the ANT registry.
|
|
2225
2221
|
|
|
2226
2222
|
```typescript
|
|
2227
|
-
import { ANT } from
|
|
2223
|
+
import { ANT } from "@ar.io/sdk";
|
|
2228
2224
|
|
|
2229
2225
|
// Get the latest ANT version
|
|
2230
|
-
import { ANT } from
|
|
2226
|
+
import { ANT } from "@ar.io/sdk";
|
|
2231
2227
|
|
|
2232
2228
|
// Get all available ANT versions
|
|
2233
2229
|
const antVersions = ANT.versions;
|
|
@@ -2473,7 +2469,7 @@ const records = await ant.getRecords();
|
|
|
2473
2469
|
Returns a specific record by its undername.
|
|
2474
2470
|
|
|
2475
2471
|
```typescript
|
|
2476
|
-
const record = await ant.getRecord({ undername:
|
|
2472
|
+
const record = await ant.getRecord({ undername: "dapp" });
|
|
2477
2473
|
```
|
|
2478
2474
|
|
|
2479
2475
|
<details>
|
|
@@ -2521,7 +2517,7 @@ Returns the balance of a specific address.
|
|
|
2521
2517
|
|
|
2522
2518
|
```typescript
|
|
2523
2519
|
const balance = await ant.getBalance({
|
|
2524
|
-
address:
|
|
2520
|
+
address: "ccp3blG__gKUvG3hsGC2u06aDmqv4CuhuDJGOIg0jw4",
|
|
2525
2521
|
});
|
|
2526
2522
|
```
|
|
2527
2523
|
|
|
@@ -2544,9 +2540,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2544
2540
|
|
|
2545
2541
|
```typescript
|
|
2546
2542
|
const { id: txId } = await ant.transfer(
|
|
2547
|
-
{ target:
|
|
2543
|
+
{ target: "aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f" },
|
|
2548
2544
|
// optional additional tags
|
|
2549
|
-
{ tags: [{ name:
|
|
2545
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2550
2546
|
);
|
|
2551
2547
|
```
|
|
2552
2548
|
|
|
@@ -2560,9 +2556,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2560
2556
|
|
|
2561
2557
|
```typescript
|
|
2562
2558
|
const { id: txId } = await ant.addController(
|
|
2563
|
-
{ controller:
|
|
2559
|
+
{ controller: "aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f" },
|
|
2564
2560
|
// optional additional tags
|
|
2565
|
-
{ tags: [{ name:
|
|
2561
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2566
2562
|
);
|
|
2567
2563
|
```
|
|
2568
2564
|
|
|
@@ -2574,9 +2570,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2574
2570
|
|
|
2575
2571
|
```typescript
|
|
2576
2572
|
const { id: txId } = await ant.removeController(
|
|
2577
|
-
{ controller:
|
|
2573
|
+
{ controller: "aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f" },
|
|
2578
2574
|
// optional additional tags
|
|
2579
|
-
{ tags: [{ name:
|
|
2575
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2580
2576
|
);
|
|
2581
2577
|
```
|
|
2582
2578
|
|
|
@@ -2590,24 +2586,24 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2590
2586
|
|
|
2591
2587
|
```typescript
|
|
2592
2588
|
// get the ant for the base name
|
|
2593
|
-
const arnsRecord = await ario.getArNSRecord({ name:
|
|
2589
|
+
const arnsRecord = await ario.getArNSRecord({ name: "ardrive" });
|
|
2594
2590
|
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2595
2591
|
|
|
2596
2592
|
// Basic usage
|
|
2597
2593
|
const { id: txId } = await ant.setBaseNameRecord({
|
|
2598
|
-
transactionId:
|
|
2594
|
+
transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2599
2595
|
ttlSeconds: 3600,
|
|
2600
2596
|
});
|
|
2601
2597
|
|
|
2602
2598
|
// With ownership delegation and metadata
|
|
2603
2599
|
const { id: txId } = await ant.setBaseNameRecord({
|
|
2604
|
-
transactionId:
|
|
2600
|
+
transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2605
2601
|
ttlSeconds: 3600,
|
|
2606
|
-
owner:
|
|
2607
|
-
displayName:
|
|
2608
|
-
logo:
|
|
2609
|
-
description:
|
|
2610
|
-
keywords: [
|
|
2602
|
+
owner: "user-wallet-address-123...", // delegate ownership to another address
|
|
2603
|
+
displayName: "ArDrive", // display name
|
|
2604
|
+
logo: "logo-tx-id-123...", // logo transaction ID
|
|
2605
|
+
description: "Decentralized storage application",
|
|
2606
|
+
keywords: ["storage", "decentralized", "web3"],
|
|
2611
2607
|
});
|
|
2612
2608
|
|
|
2613
2609
|
// ardrive.ar.io will now resolve to the provided transaction id and include metadata
|
|
@@ -2622,33 +2618,33 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2622
2618
|
> 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.
|
|
2623
2619
|
|
|
2624
2620
|
```typescript
|
|
2625
|
-
const arnsRecord = await ario.getArNSRecord({ name:
|
|
2621
|
+
const arnsRecord = await ario.getArNSRecord({ name: "ardrive" });
|
|
2626
2622
|
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2627
2623
|
|
|
2628
2624
|
// Basic usage
|
|
2629
2625
|
const { id: txId } = await ant.setUndernameRecord(
|
|
2630
2626
|
{
|
|
2631
|
-
undername:
|
|
2632
|
-
transactionId:
|
|
2627
|
+
undername: "dapp",
|
|
2628
|
+
transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2633
2629
|
ttlSeconds: 900,
|
|
2634
2630
|
},
|
|
2635
2631
|
// optional additional tags
|
|
2636
|
-
{ tags: [{ name:
|
|
2632
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2637
2633
|
);
|
|
2638
2634
|
|
|
2639
2635
|
// With ownership delegation and metadata
|
|
2640
2636
|
const { id: txId } = await ant.setUndernameRecord(
|
|
2641
2637
|
{
|
|
2642
|
-
undername:
|
|
2643
|
-
transactionId:
|
|
2638
|
+
undername: "alice",
|
|
2639
|
+
transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2644
2640
|
ttlSeconds: 900,
|
|
2645
|
-
owner:
|
|
2641
|
+
owner: "alice-wallet-address-123...", // delegate ownership to Alice
|
|
2646
2642
|
displayName: "Alice's Site", // display name
|
|
2647
|
-
logo:
|
|
2648
|
-
description:
|
|
2649
|
-
keywords: [
|
|
2643
|
+
logo: "avatar-tx-id-123...", // avatar/logo transaction ID
|
|
2644
|
+
description: "Personal portfolio and blog",
|
|
2645
|
+
keywords: ["portfolio", "personal", "blog"],
|
|
2650
2646
|
},
|
|
2651
|
-
{ tags: [{ name:
|
|
2647
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2652
2648
|
);
|
|
2653
2649
|
|
|
2654
2650
|
// dapp_ardrive.ar.io will now resolve to the provided transaction id
|
|
@@ -2663,9 +2659,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2663
2659
|
|
|
2664
2660
|
```typescript
|
|
2665
2661
|
const { id: txId } = await ant.removeUndernameRecord(
|
|
2666
|
-
{ undername:
|
|
2662
|
+
{ undername: "dapp" },
|
|
2667
2663
|
// optional additional tags
|
|
2668
|
-
{ tags: [{ name:
|
|
2664
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2669
2665
|
);
|
|
2670
2666
|
|
|
2671
2667
|
// dapp_ardrive.ar.io will no longer resolve to the provided transaction id
|
|
@@ -2704,12 +2700,12 @@ Removes a record from the ANT process.
|
|
|
2704
2700
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2705
2701
|
|
|
2706
2702
|
```typescript
|
|
2707
|
-
const arnsRecord = await ario.getArNSRecord({ name:
|
|
2703
|
+
const arnsRecord = await ario.getArNSRecord({ name: "ardrive" });
|
|
2708
2704
|
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2709
2705
|
const { id: txId } = await ant.removeRecord(
|
|
2710
|
-
{ undername:
|
|
2706
|
+
{ undername: "dapp" },
|
|
2711
2707
|
// optional additional tags
|
|
2712
|
-
{ tags: [{ name:
|
|
2708
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2713
2709
|
);
|
|
2714
2710
|
|
|
2715
2711
|
// dapp_ardrive.ar.io will no longer resolve to the provided transaction id
|
|
@@ -2725,9 +2721,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2725
2721
|
|
|
2726
2722
|
```typescript
|
|
2727
2723
|
const { id: txId } = await ant.setName(
|
|
2728
|
-
{ name:
|
|
2724
|
+
{ name: "My ANT" },
|
|
2729
2725
|
// optional additional tags
|
|
2730
|
-
{ tags: [{ name:
|
|
2726
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2731
2727
|
);
|
|
2732
2728
|
```
|
|
2733
2729
|
|
|
@@ -2739,9 +2735,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2739
2735
|
|
|
2740
2736
|
```typescript
|
|
2741
2737
|
const { id: txId } = await ant.setTicker(
|
|
2742
|
-
{ ticker:
|
|
2738
|
+
{ ticker: "ANT-NEW-TICKER" },
|
|
2743
2739
|
// optional tags
|
|
2744
|
-
{ tags: [{ name:
|
|
2740
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2745
2741
|
);
|
|
2746
2742
|
```
|
|
2747
2743
|
|
|
@@ -2753,9 +2749,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2753
2749
|
|
|
2754
2750
|
```typescript
|
|
2755
2751
|
const { id: txId } = await ant.setDescription(
|
|
2756
|
-
{ description:
|
|
2752
|
+
{ description: "A friendly description of this ANT" },
|
|
2757
2753
|
// optional tags
|
|
2758
|
-
{ tags: [{ name:
|
|
2754
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2759
2755
|
);
|
|
2760
2756
|
```
|
|
2761
2757
|
|
|
@@ -2767,9 +2763,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2767
2763
|
|
|
2768
2764
|
```typescript
|
|
2769
2765
|
const { id: txId } = await ant.setKeywords(
|
|
2770
|
-
{ keywords: [
|
|
2766
|
+
{ keywords: ["Game", "FPS", "AO"] },
|
|
2771
2767
|
// optional tags
|
|
2772
|
-
{ tags: [{ name:
|
|
2768
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2773
2769
|
);
|
|
2774
2770
|
```
|
|
2775
2771
|
|
|
@@ -2789,9 +2785,9 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2789
2785
|
|
|
2790
2786
|
```typescript
|
|
2791
2787
|
const { id: txId } = await ant.setLogo(
|
|
2792
|
-
{ txId:
|
|
2788
|
+
{ txId: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f" },
|
|
2793
2789
|
// optional tags
|
|
2794
|
-
{ tags: [{ name:
|
|
2790
|
+
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
2795
2791
|
);
|
|
2796
2792
|
```
|
|
2797
2793
|
|
|
@@ -2805,7 +2801,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2805
2801
|
|
|
2806
2802
|
```typescript
|
|
2807
2803
|
const { id: txId } = await ant.releaseName({
|
|
2808
|
-
name:
|
|
2804
|
+
name: "permalink",
|
|
2809
2805
|
arioProcessId: ARIO_MAINNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
|
|
2810
2806
|
});
|
|
2811
2807
|
```
|
|
@@ -2818,7 +2814,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2818
2814
|
|
|
2819
2815
|
```typescript
|
|
2820
2816
|
const { id: txId } = await ant.reassignName({
|
|
2821
|
-
name:
|
|
2817
|
+
name: "ardrive",
|
|
2822
2818
|
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2823
2819
|
antProcessId: NEW_ANT_PROCESS_ID, // the new ANT process id that will take over ownership of the name
|
|
2824
2820
|
});
|
|
@@ -2832,8 +2828,8 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2832
2828
|
|
|
2833
2829
|
```typescript
|
|
2834
2830
|
const { id: txId } = await ant.approvePrimaryNameRequest({
|
|
2835
|
-
name:
|
|
2836
|
-
address:
|
|
2831
|
+
name: "arns",
|
|
2832
|
+
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3", // must match the request initiator address
|
|
2837
2833
|
arioProcessId: ARIO_MAINNET_PROCESS_ID, // the ARIO process id to use for the request
|
|
2838
2834
|
});
|
|
2839
2835
|
```
|
|
@@ -2846,7 +2842,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2846
2842
|
|
|
2847
2843
|
```typescript
|
|
2848
2844
|
const { id: txId } = await ant.removePrimaryNames({
|
|
2849
|
-
names: [
|
|
2845
|
+
names: ["arns", "test_arns"], // any primary names associated with a base name controlled by this ANT will be removed
|
|
2850
2846
|
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2851
2847
|
notifyOwners: true, // if true, the owners of the removed names will be send AO messages to notify them of the removal
|
|
2852
2848
|
});
|
|
@@ -2866,24 +2862,24 @@ const result = await ant.upgrade();
|
|
|
2866
2862
|
|
|
2867
2863
|
// Upgrade ANT and reassign specific ArNS names to the new process
|
|
2868
2864
|
const result = await ant.upgrade({
|
|
2869
|
-
names: [
|
|
2865
|
+
names: ["ardrive", "example"],
|
|
2870
2866
|
});
|
|
2871
2867
|
|
|
2872
2868
|
// with callbacks
|
|
2873
2869
|
const result = await ant.upgrade({
|
|
2874
|
-
names: [
|
|
2870
|
+
names: ["ardrive", "example"],
|
|
2875
2871
|
onSigningProgress: (event, payload) => {
|
|
2876
2872
|
console.log(`${event}:`, payload);
|
|
2877
|
-
if (event ===
|
|
2873
|
+
if (event === "checking-version") {
|
|
2878
2874
|
console.log(`Checking version: ${payload.antProcessId}`);
|
|
2879
2875
|
}
|
|
2880
|
-
if (event ===
|
|
2876
|
+
if (event === "fetching-affiliated-names") {
|
|
2881
2877
|
console.log(`Fetching affiliated names: ${payload.arioProcessId}`);
|
|
2882
2878
|
}
|
|
2883
|
-
if (event ===
|
|
2879
|
+
if (event === "reassigning-name") {
|
|
2884
2880
|
console.log(`Reassigning name: ${payload.name}`);
|
|
2885
2881
|
}
|
|
2886
|
-
if (event ===
|
|
2882
|
+
if (event === "validating-names") {
|
|
2887
2883
|
console.log(`Validating names: ${payload.names}`);
|
|
2888
2884
|
}
|
|
2889
2885
|
// other callback events...
|
|
@@ -2925,8 +2921,8 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2925
2921
|
|
|
2926
2922
|
```typescript
|
|
2927
2923
|
const { id: txId } = await ant.transferRecord({
|
|
2928
|
-
undername:
|
|
2929
|
-
recipient:
|
|
2924
|
+
undername: "alice", // the subdomain/record to transfer
|
|
2925
|
+
recipient: "new-owner-address-123...", // address of the new owner
|
|
2930
2926
|
});
|
|
2931
2927
|
|
|
2932
2928
|
// alice_ardrive.ar.io is now owned by the new owner address
|
|
@@ -2949,7 +2945,7 @@ ar.io transfer-record \
|
|
|
2949
2945
|
**Checking Record Ownership:**
|
|
2950
2946
|
|
|
2951
2947
|
```typescript
|
|
2952
|
-
const record = await ant.getRecord({ undername:
|
|
2948
|
+
const record = await ant.getRecord({ undername: "alice" });
|
|
2953
2949
|
console.log(`Record owner: ${record.owner}`);
|
|
2954
2950
|
console.log(`Transaction ID: ${record.transactionId}`);
|
|
2955
2951
|
```
|
|
@@ -2959,34 +2955,34 @@ console.log(`Transaction ID: ${record.transactionId}`);
|
|
|
2959
2955
|
```typescript
|
|
2960
2956
|
// Alice (record owner) updating her own record
|
|
2961
2957
|
const aliceAnt = ANT.init({
|
|
2962
|
-
processId:
|
|
2958
|
+
processId: "ANT_PROCESS_ID",
|
|
2963
2959
|
signer: new ArweaveSigner(aliceJwk), // Alice's wallet
|
|
2964
2960
|
});
|
|
2965
2961
|
|
|
2966
2962
|
// ✅ CORRECT: Alice includes her own address as owner
|
|
2967
2963
|
const { id: txId } = await aliceAnt.setUndernameRecord({
|
|
2968
|
-
undername:
|
|
2969
|
-
transactionId:
|
|
2964
|
+
undername: "alice",
|
|
2965
|
+
transactionId: "new-content-tx-id-456...",
|
|
2970
2966
|
ttlSeconds: 1800,
|
|
2971
|
-
owner:
|
|
2972
|
-
displayName:
|
|
2973
|
-
description:
|
|
2967
|
+
owner: "alice-wallet-address-123...", // MUST be Alice's own address
|
|
2968
|
+
displayName: "Alice Updated Portfolio",
|
|
2969
|
+
description: "Updated personal portfolio and blog",
|
|
2974
2970
|
});
|
|
2975
2971
|
|
|
2976
2972
|
// ❌ WRONG: Omitting owner field will renounce ownership
|
|
2977
2973
|
const badUpdate = await aliceAnt.setUndernameRecord({
|
|
2978
|
-
undername:
|
|
2979
|
-
transactionId:
|
|
2974
|
+
undername: "alice",
|
|
2975
|
+
transactionId: "new-content-tx-id-456...",
|
|
2980
2976
|
ttlSeconds: 1800,
|
|
2981
2977
|
// Missing owner field - this will renounce ownership!
|
|
2982
2978
|
});
|
|
2983
2979
|
|
|
2984
2980
|
// ❌ WRONG: Setting different owner will transfer ownership
|
|
2985
2981
|
const badTransfer = await aliceAnt.setUndernameRecord({
|
|
2986
|
-
undername:
|
|
2987
|
-
transactionId:
|
|
2982
|
+
undername: "alice",
|
|
2983
|
+
transactionId: "new-content-tx-id-456...",
|
|
2988
2984
|
ttlSeconds: 1800,
|
|
2989
|
-
owner:
|
|
2985
|
+
owner: "someone-else-address-789...", // This transfers ownership to someone else!
|
|
2990
2986
|
});
|
|
2991
2987
|
```
|
|
2992
2988
|
|
|
@@ -2996,19 +2992,19 @@ If a record owner updates their record without including the `owner` field, the
|
|
|
2996
2992
|
|
|
2997
2993
|
```typescript
|
|
2998
2994
|
// Before: alice record is owned by alice-wallet-address-123...
|
|
2999
|
-
const recordBefore = await ant.getRecord({ undername:
|
|
2995
|
+
const recordBefore = await ant.getRecord({ undername: "alice" });
|
|
3000
2996
|
console.log(recordBefore.owner); // "alice-wallet-address-123..."
|
|
3001
2997
|
|
|
3002
2998
|
// Alice updates without owner field
|
|
3003
2999
|
await aliceAnt.setUndernameRecord({
|
|
3004
|
-
undername:
|
|
3005
|
-
transactionId:
|
|
3000
|
+
undername: "alice",
|
|
3001
|
+
transactionId: "new-tx-id...",
|
|
3006
3002
|
ttlSeconds: 900,
|
|
3007
3003
|
// No owner field = renounces ownership
|
|
3008
3004
|
});
|
|
3009
3005
|
|
|
3010
3006
|
// After: record ownership reverts to ANT owner
|
|
3011
|
-
const recordAfter = await ant.getRecord({ undername:
|
|
3007
|
+
const recordAfter = await ant.getRecord({ undername: "alice" });
|
|
3012
3008
|
console.log(recordAfter.owner); // undefined (controlled by ANT owner again)
|
|
3013
3009
|
```
|
|
3014
3010
|
|
|
@@ -3021,9 +3017,9 @@ Forks an existing ANT process to create a new one with the same state but potent
|
|
|
3021
3017
|
```typescript
|
|
3022
3018
|
const newProcessId = await ANT.fork({
|
|
3023
3019
|
signer: new ArweaveSigner(jwk),
|
|
3024
|
-
antProcessId:
|
|
3020
|
+
antProcessId: "existing-ant-process-id",
|
|
3025
3021
|
// Optional: specify a specific module ID, defaults to latest from registry
|
|
3026
|
-
module:
|
|
3022
|
+
module: "new-module-id",
|
|
3027
3023
|
onSigningProgress: (event, payload) => {
|
|
3028
3024
|
console.log(`Fork progress: ${event}`);
|
|
3029
3025
|
},
|
|
@@ -3040,23 +3036,27 @@ Static method to upgrade an ANT by forking it to the latest version and reassign
|
|
|
3040
3036
|
// Upgrade and reassign all affiliated names
|
|
3041
3037
|
const result = await ANT.upgrade({
|
|
3042
3038
|
signer: new ArweaveSigner(jwk),
|
|
3043
|
-
antProcessId:
|
|
3039
|
+
antProcessId: "existing-ant-process-id",
|
|
3044
3040
|
reassignAffiliatedNames: true,
|
|
3045
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID
|
|
3041
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
3046
3042
|
});
|
|
3047
3043
|
|
|
3048
3044
|
// Upgrade and reassign specific names
|
|
3049
3045
|
const result = await ANT.upgrade({
|
|
3050
3046
|
signer: new ArweaveSigner(jwk),
|
|
3051
|
-
antProcessId:
|
|
3052
|
-
names: [
|
|
3047
|
+
antProcessId: "existing-ant-process-id",
|
|
3048
|
+
names: ["ardrive", "example"],
|
|
3053
3049
|
reassignAffiliatedNames: false,
|
|
3054
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID
|
|
3050
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
3055
3051
|
});
|
|
3056
3052
|
|
|
3057
3053
|
console.log(`Upgraded to process: ${result.forkedProcessId}`);
|
|
3058
|
-
console.log(
|
|
3059
|
-
|
|
3054
|
+
console.log(
|
|
3055
|
+
`Successfully reassigned names: ${Object.keys(result.reassignedNames)}`,
|
|
3056
|
+
);
|
|
3057
|
+
console.log(
|
|
3058
|
+
`Failed reassignments: ${Object.keys(result.failedReassignedNames)}`,
|
|
3059
|
+
);
|
|
3060
3060
|
```
|
|
3061
3061
|
|
|
3062
3062
|
## Token Conversion
|
|
@@ -3068,7 +3068,7 @@ The ARIO process stores all values as mARIO (milli-ARIO) to avoid floating-point
|
|
|
3068
3068
|
#### Converting ARIO to mARIO
|
|
3069
3069
|
|
|
3070
3070
|
```typescript
|
|
3071
|
-
import { ARIOToken, mARIOToken } from
|
|
3071
|
+
import { ARIOToken, mARIOToken } from "@ar.io/sdk";
|
|
3072
3072
|
|
|
3073
3073
|
const arioValue = 1;
|
|
3074
3074
|
const mARIOValue = new ARIOToken(arioValue).toMARIO();
|
|
@@ -3084,13 +3084,13 @@ The library uses a lightweight console logger by default for both Node.js and we
|
|
|
3084
3084
|
#### Default Logger
|
|
3085
3085
|
|
|
3086
3086
|
```typescript
|
|
3087
|
-
import { Logger } from
|
|
3087
|
+
import { Logger } from "@ar.io/sdk";
|
|
3088
3088
|
|
|
3089
3089
|
// set the log level
|
|
3090
|
-
Logger.default.setLogLevel(
|
|
3090
|
+
Logger.default.setLogLevel("debug");
|
|
3091
3091
|
|
|
3092
3092
|
// Create a new logger instance with a specific level
|
|
3093
|
-
const logger = new Logger({ level:
|
|
3093
|
+
const logger = new Logger({ level: "debug" });
|
|
3094
3094
|
```
|
|
3095
3095
|
|
|
3096
3096
|
#### Custom Logger Implementation
|
|
@@ -3098,7 +3098,7 @@ const logger = new Logger({ level: 'debug' });
|
|
|
3098
3098
|
You can provide any custom logger that implements the `ILogger` interface:
|
|
3099
3099
|
|
|
3100
3100
|
```typescript
|
|
3101
|
-
import { ARIO, ILogger } from
|
|
3101
|
+
import { ARIO, ILogger } from "@ar.io/sdk";
|
|
3102
3102
|
|
|
3103
3103
|
// Custom logger example
|
|
3104
3104
|
const customLogger: ILogger = {
|
|
@@ -3156,10 +3156,10 @@ Example:
|
|
|
3156
3156
|
```typescript
|
|
3157
3157
|
const records = await ario.getArNSRecords({
|
|
3158
3158
|
filters: {
|
|
3159
|
-
type:
|
|
3159
|
+
type: "lease",
|
|
3160
3160
|
processId: [
|
|
3161
|
-
|
|
3162
|
-
|
|
3161
|
+
"ZkgLfyHALs5koxzojpcsEFAKA8fbpzP7l-tbM7wmQNM",
|
|
3162
|
+
"r61rbOjyXx3u644nGl9bkwLWlWmArMEzQgxBo2R-Vu0",
|
|
3163
3163
|
],
|
|
3164
3164
|
},
|
|
3165
3165
|
});
|