@ar.io/sdk 3.24.0-solana.1 → 4.0.0-alpha.1
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 +682 -600
- package/lib/esm/cli/cli.js +188 -152
- package/lib/esm/cli/commands/antCommands.js +23 -58
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
- package/lib/esm/cli/commands/escrowCommands.js +221 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +142 -23
- package/lib/esm/cli/commands/pruneCommands.js +150 -0
- package/lib/esm/cli/commands/readCommands.js +22 -3
- package/lib/esm/cli/commands/transfer.js +6 -6
- package/lib/esm/cli/options.js +124 -58
- package/lib/esm/cli/utils.js +280 -174
- package/lib/esm/common/ant-registry.js +17 -143
- package/lib/esm/common/ant.js +44 -1167
- package/lib/esm/common/faucet.js +11 -6
- package/lib/esm/common/index.js +0 -4
- package/lib/esm/common/io.js +25 -1412
- package/lib/esm/constants.js +13 -19
- package/lib/esm/solana/ant-readable.js +724 -0
- package/lib/esm/solana/ant-registry-readable.js +133 -0
- package/lib/esm/solana/ant-registry-writeable.js +472 -0
- package/lib/esm/solana/ant-writeable.js +384 -0
- package/lib/esm/solana/ata.js +70 -0
- package/lib/esm/solana/canonical-message.js +128 -0
- package/lib/esm/solana/clusters.js +111 -0
- package/lib/esm/solana/constants.js +146 -0
- package/lib/esm/solana/delegation-math.js +112 -0
- package/lib/esm/solana/deserialize.js +711 -0
- package/lib/esm/solana/escrow.js +839 -0
- package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
- package/lib/esm/solana/funding-plan.js +699 -0
- package/lib/esm/solana/index.js +126 -0
- package/lib/esm/solana/instruction.js +39 -0
- package/lib/esm/solana/io-readable.js +2182 -0
- package/lib/esm/solana/io-writeable.js +3196 -0
- package/lib/esm/solana/json-rpc.js +90 -0
- package/lib/esm/solana/metadata.js +81 -0
- package/lib/esm/solana/mpl-core.js +192 -0
- package/lib/esm/solana/pda.js +332 -0
- package/lib/esm/solana/predict-prescribed-observers.js +110 -0
- package/lib/esm/solana/retry.js +117 -0
- package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
- package/lib/esm/solana/send.js +372 -0
- package/lib/esm/solana/spawn-ant.js +224 -0
- package/lib/esm/solana/types.js +1 -0
- package/lib/esm/types/ant.js +27 -15
- package/lib/esm/types/io.js +8 -11
- package/lib/esm/utils/ant.js +0 -63
- package/lib/esm/utils/index.js +0 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +5 -13
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
- package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
- package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
- package/lib/types/cli/commands/readCommands.d.ts +27 -22
- package/lib/types/cli/commands/transfer.d.ts +9 -9
- package/lib/types/cli/options.d.ts +76 -21
- package/lib/types/cli/types.d.ts +11 -13
- package/lib/types/cli/utils.d.ts +71 -31
- package/lib/types/common/ant-registry.d.ts +49 -47
- package/lib/types/common/ant.d.ts +54 -539
- package/lib/types/common/faucet.d.ts +20 -8
- package/lib/types/common/index.d.ts +0 -3
- package/lib/types/common/io.d.ts +51 -263
- package/lib/types/constants.d.ts +11 -18
- package/lib/types/solana/ant-readable.d.ts +180 -0
- package/lib/types/solana/ant-registry-readable.d.ts +105 -0
- package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
- package/lib/types/solana/ant-writeable.d.ts +177 -0
- package/lib/types/solana/ata.d.ts +44 -0
- package/lib/types/solana/canonical-message.d.ts +121 -0
- package/lib/types/solana/clusters.d.ts +109 -0
- package/lib/types/solana/constants.d.ts +119 -0
- package/lib/types/solana/delegation-math.d.ts +45 -0
- package/lib/types/solana/deserialize.d.ts +262 -0
- package/lib/types/solana/escrow.d.ts +480 -0
- package/lib/types/solana/events.d.ts +38 -0
- package/lib/types/solana/funding-plan.d.ts +225 -0
- package/lib/types/solana/index.d.ts +87 -0
- package/lib/types/solana/instruction.d.ts +39 -0
- package/lib/types/solana/io-readable.d.ts +499 -0
- package/lib/types/solana/io-writeable.d.ts +893 -0
- package/lib/types/solana/json-rpc.d.ts +47 -0
- package/lib/types/solana/metadata.d.ts +84 -0
- package/lib/types/solana/mpl-core.d.ts +120 -0
- package/lib/types/solana/pda.d.ts +95 -0
- package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
- package/lib/types/solana/retry.d.ts +62 -0
- package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
- package/lib/types/solana/send.d.ts +94 -0
- package/lib/types/solana/spawn-ant.d.ts +145 -0
- package/lib/types/solana/types.d.ts +82 -0
- package/lib/types/types/ant-registry.d.ts +43 -4
- package/lib/types/types/ant.d.ts +114 -96
- package/lib/types/types/common.d.ts +18 -74
- package/lib/types/types/faucet.d.ts +2 -2
- package/lib/types/types/io.d.ts +244 -158
- package/lib/types/types/token.d.ts +0 -12
- package/lib/types/utils/ant.d.ts +1 -12
- package/lib/types/utils/index.d.ts +0 -3
- package/lib/types/version.d.ts +1 -1
- package/package.json +36 -33
- package/lib/cjs/cli/cli.js +0 -822
- package/lib/cjs/cli/commands/antCommands.js +0 -113
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
- package/lib/cjs/cli/commands/readCommands.js +0 -215
- package/lib/cjs/cli/commands/transfer.js +0 -159
- package/lib/cjs/cli/options.js +0 -470
- package/lib/cjs/cli/types.js +0 -2
- package/lib/cjs/cli/utils.js +0 -639
- package/lib/cjs/common/ant-registry.js +0 -155
- package/lib/cjs/common/ant-versions.js +0 -93
- package/lib/cjs/common/ant.js +0 -1182
- package/lib/cjs/common/arweave.js +0 -27
- package/lib/cjs/common/contracts/ao-process.js +0 -224
- package/lib/cjs/common/error.js +0 -64
- package/lib/cjs/common/faucet.js +0 -150
- package/lib/cjs/common/hyperbeam/hb.js +0 -173
- package/lib/cjs/common/index.js +0 -42
- package/lib/cjs/common/io.js +0 -1423
- package/lib/cjs/common/logger.js +0 -83
- package/lib/cjs/common/loggers/winston.js +0 -68
- package/lib/cjs/common/marketplace.js +0 -731
- package/lib/cjs/common/turbo.js +0 -223
- package/lib/cjs/constants.js +0 -41
- package/lib/cjs/node/index.js +0 -39
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/types/ant-registry.js +0 -2
- package/lib/cjs/types/ant.js +0 -168
- package/lib/cjs/types/common.js +0 -2
- package/lib/cjs/types/faucet.js +0 -2
- package/lib/cjs/types/index.js +0 -37
- package/lib/cjs/types/io.js +0 -51
- package/lib/cjs/types/token.js +0 -116
- package/lib/cjs/utils/ant.js +0 -108
- package/lib/cjs/utils/ao.js +0 -432
- package/lib/cjs/utils/arweave.js +0 -285
- package/lib/cjs/utils/base64.js +0 -62
- package/lib/cjs/utils/hash.js +0 -56
- package/lib/cjs/utils/index.js +0 -38
- package/lib/cjs/utils/processes.js +0 -173
- package/lib/cjs/utils/random.js +0 -30
- package/lib/cjs/utils/schema.js +0 -15
- package/lib/cjs/utils/url.js +0 -37
- package/lib/cjs/version.js +0 -20
- package/lib/cjs/web/index.js +0 -41
- package/lib/esm/common/ant-versions.js +0 -87
- package/lib/esm/common/arweave.js +0 -21
- package/lib/esm/common/contracts/ao-process.js +0 -220
- package/lib/esm/common/hyperbeam/hb.js +0 -169
- package/lib/esm/common/marketplace.js +0 -724
- package/lib/esm/common/turbo.js +0 -215
- package/lib/esm/node/index.js +0 -20
- package/lib/esm/utils/ao.js +0 -420
- package/lib/esm/utils/arweave.js +0 -271
- package/lib/esm/utils/processes.js +0 -167
- package/lib/esm/web/index.js +0 -20
- package/lib/types/common/ant-versions.d.ts +0 -39
- package/lib/types/common/arweave.d.ts +0 -17
- package/lib/types/common/contracts/ao-process.d.ts +0 -47
- package/lib/types/common/hyperbeam/hb.d.ts +0 -88
- package/lib/types/common/marketplace.d.ts +0 -568
- package/lib/types/common/turbo.d.ts +0 -61
- package/lib/types/node/index.d.ts +0 -20
- package/lib/types/utils/ao.d.ts +0 -80
- package/lib/types/utils/arweave.d.ts +0 -79
- package/lib/types/utils/processes.d.ts +0 -39
- package/lib/types/web/index.d.ts +0 -20
package/README.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://codecov.io/gh/ar-io/ar-io-sdk)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The Solana-native SDK for the AR.IO network. Provides typed
|
|
6
|
+
client classes (`ARIO`, `ANT`, `ANTRegistry`), PDA helpers,
|
|
7
|
+
deserializers, and escrow primitives for the AR.IO protocol on Solana.
|
|
8
|
+
Codama-generated instruction builders and account decoders are
|
|
9
|
+
supplied by [`@ar.io/solana-contracts`](https://www.npmjs.com/package/@ar.io/solana-contracts).
|
|
6
10
|
|
|
7
11
|
## Table of Contents
|
|
8
12
|
|
|
@@ -17,6 +21,7 @@ This is the home of the ar.io SDK. This SDK provides functionality for interacti
|
|
|
17
21
|
- [Token Conversion](#token-conversion)
|
|
18
22
|
- [Logging](#logging)
|
|
19
23
|
- [Pagination](#pagination)
|
|
24
|
+
- [Advanced](#advanced)
|
|
20
25
|
- [Resources](#resources)
|
|
21
26
|
- [Developers](#developers)
|
|
22
27
|
|
|
@@ -24,7 +29,7 @@ This is the home of the ar.io SDK. This SDK provides functionality for interacti
|
|
|
24
29
|
|
|
25
30
|
## Installation
|
|
26
31
|
|
|
27
|
-
Requires `node>=v18.0.0
|
|
32
|
+
Requires `node>=v18.0.0`.
|
|
28
33
|
|
|
29
34
|
```shell
|
|
30
35
|
npm install @ar.io/sdk
|
|
@@ -33,21 +38,49 @@ npm install @ar.io/sdk
|
|
|
33
38
|
or
|
|
34
39
|
|
|
35
40
|
```shell
|
|
36
|
-
yarn add @ar.io/sdk
|
|
41
|
+
yarn add @ar.io/sdk
|
|
37
42
|
```
|
|
38
43
|
|
|
39
|
-
> [!NOTE]
|
|
40
|
-
> The `--ignore-engines` flag is required when using yarn, as [permaweb/aoconnect] recommends only the use of npm. Alternatively, you can add a `.yarnrc.yml` file to your project containing `ignore-engines true` to ignore the engines check.
|
|
41
|
-
|
|
42
44
|
## Quick Start
|
|
43
45
|
|
|
44
46
|
```typescript
|
|
45
|
-
import { ARIO } from
|
|
47
|
+
import { ARIO } from '@ar.io/sdk';
|
|
48
|
+
import { createSolanaRpc } from '@solana/kit';
|
|
46
49
|
|
|
47
|
-
const
|
|
50
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
51
|
+
const ario = ARIO.init({ rpc });
|
|
48
52
|
const gateways = await ario.getGateways();
|
|
49
53
|
```
|
|
50
54
|
|
|
55
|
+
Write operations need a `@solana/kit` signer plus an `rpcSubscriptions`
|
|
56
|
+
client (used by kit's `sendAndConfirmTransaction`):
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { ARIO } from '@ar.io/sdk';
|
|
60
|
+
import {
|
|
61
|
+
createSolanaRpc,
|
|
62
|
+
createSolanaRpcSubscriptions,
|
|
63
|
+
createKeyPairSignerFromBytes,
|
|
64
|
+
} from '@solana/kit';
|
|
65
|
+
import { readFileSync } from 'node:fs';
|
|
66
|
+
|
|
67
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
68
|
+
const rpcSubscriptions = createSolanaRpcSubscriptions(
|
|
69
|
+
'wss://api.mainnet-beta.solana.com',
|
|
70
|
+
);
|
|
71
|
+
const signer = await createKeyPairSignerFromBytes(
|
|
72
|
+
new Uint8Array(JSON.parse(readFileSync('keypair.json', 'utf8'))),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
76
|
+
await ario.buyRecord({
|
|
77
|
+
name: 'foo',
|
|
78
|
+
type: 'lease',
|
|
79
|
+
years: 1,
|
|
80
|
+
processId: '<ANT mint pubkey>',
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
51
84
|
<details>
|
|
52
85
|
<summary>Output</summary>
|
|
53
86
|
|
|
@@ -58,7 +91,13 @@ const gateways = await ario.getGateways();
|
|
|
58
91
|
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
59
92
|
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
60
93
|
"operatorStake": 250000000000,
|
|
94
|
+
"totalDelegatedStake": 0,
|
|
61
95
|
"settings": {
|
|
96
|
+
"allowDelegatedStaking": true,
|
|
97
|
+
"allowedDelegates": [],
|
|
98
|
+
"autoStake": false,
|
|
99
|
+
"delegateRewardShareRatio": 10,
|
|
100
|
+
"minDelegatedStake": 100000000,
|
|
62
101
|
"fqdn": "ar-io.dev",
|
|
63
102
|
"label": "ar.io Test",
|
|
64
103
|
"note": "Test Gateway operated by PDS for the ar.io ecosystem.",
|
|
@@ -67,28 +106,33 @@ const gateways = await ario.getGateways();
|
|
|
67
106
|
"protocol": "https"
|
|
68
107
|
},
|
|
69
108
|
"startTimestamp": 1720720621424,
|
|
109
|
+
"endTimestamp": 0,
|
|
70
110
|
"stats": {
|
|
111
|
+
"passedConsecutiveEpochs": 30,
|
|
71
112
|
"failedConsecutiveEpochs": 0,
|
|
72
|
-
"passedEpochCount": 30,
|
|
73
|
-
"submittedEpochCount": 30,
|
|
74
113
|
"totalEpochCount": 31,
|
|
75
|
-
"
|
|
114
|
+
"passedEpochCount": 30,
|
|
115
|
+
"failedEpochCount": 1,
|
|
116
|
+
"observedEpochCount": 30,
|
|
117
|
+
"prescribedEpochCount": 31
|
|
76
118
|
},
|
|
77
119
|
"status": "joined",
|
|
78
|
-
"vaults": {},
|
|
79
120
|
"weights": {
|
|
80
|
-
"
|
|
81
|
-
"gatewayPerformanceRatio": 1,
|
|
121
|
+
"stakeWeight": 5.02400000024,
|
|
82
122
|
"tenureWeight": 0.19444444444444,
|
|
123
|
+
"gatewayPerformanceRatio": 1,
|
|
124
|
+
"observerPerformanceRatio": 1,
|
|
125
|
+
"gatewayRewardRatioWeight": 1,
|
|
83
126
|
"observerRewardRatioWeight": 1,
|
|
84
|
-
"
|
|
85
|
-
"
|
|
127
|
+
"compositeWeight": 0.97688888893556,
|
|
128
|
+
"normalizedCompositeWeight": 0.19247316211083
|
|
86
129
|
}
|
|
87
130
|
}
|
|
88
131
|
],
|
|
89
132
|
"hasMore": true,
|
|
90
133
|
"nextCursor": "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
91
134
|
"totalItems": 316,
|
|
135
|
+
"limit": 100,
|
|
92
136
|
"sortBy": "startTimestamp",
|
|
93
137
|
"sortOrder": "desc"
|
|
94
138
|
}
|
|
@@ -98,88 +142,92 @@ const gateways = await ario.getGateways();
|
|
|
98
142
|
|
|
99
143
|
## Usage
|
|
100
144
|
|
|
101
|
-
The SDK is
|
|
145
|
+
The SDK is published as an ES module (`"type": "module"`) and is
|
|
146
|
+
compatible with modern bundlers such as Webpack, Rollup, ESbuild, and
|
|
147
|
+
Vite. CommonJS consumers should migrate to ESM (Node 18+ supports ESM
|
|
148
|
+
natively). Refer to the [examples] directory to see how to use the SDK
|
|
149
|
+
in various environments.
|
|
150
|
+
|
|
151
|
+
### Subpath exports
|
|
152
|
+
|
|
153
|
+
- `@ar.io/sdk` — main entry. `ARIO`, `ANT`, `ANTRegistry`, Solana
|
|
154
|
+
client classes, PDA helpers, deserializers, escrow primitives.
|
|
155
|
+
- `@ar.io/sdk/solana` — alias of the main entry (kept for one release
|
|
156
|
+
while consumers migrate from the previous subpath layout).
|
|
102
157
|
|
|
103
158
|
### Web
|
|
104
159
|
|
|
105
160
|
> [!WARNING]
|
|
106
|
-
> Polyfills are not provided by default for bundled web projects (Vite,
|
|
107
|
-
|
|
108
|
-
|
|
161
|
+
> Polyfills are not provided by default for bundled web projects (Vite,
|
|
162
|
+
> ESBuild, Webpack, Rollup, etc.). Depending on your bundler config, you
|
|
163
|
+
> will need polyfills for `crypto`, `process` and `buffer`. Refer to
|
|
164
|
+
> [examples/webpack] and [examples/vite] for examples.
|
|
109
165
|
|
|
110
166
|
```javascript
|
|
111
|
-
import { ARIO } from
|
|
167
|
+
import { ARIO } from '@ar.io/sdk';
|
|
168
|
+
import { createSolanaRpc } from '@solana/kit';
|
|
112
169
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
170
|
+
const ario = ARIO.init({
|
|
171
|
+
rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
|
|
172
|
+
});
|
|
116
173
|
const gateways = await ario.getGateways();
|
|
117
174
|
```
|
|
118
175
|
|
|
119
|
-
|
|
176
|
+
### Browser bundle
|
|
120
177
|
|
|
121
178
|
```html
|
|
122
179
|
<script type="module">
|
|
123
|
-
// replace <version> with a release version
|
|
124
|
-
import { ARIO } from
|
|
180
|
+
// replace <version> with a release version
|
|
181
|
+
import { ARIO } from 'https://github.com/ar-io/ar-io-sdk/releases/download/v<version>/web.bundle.min.js';
|
|
182
|
+
import { createSolanaRpc } from 'https://esm.sh/@solana/kit@6';
|
|
125
183
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
184
|
+
const ario = ARIO.init({
|
|
185
|
+
rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
|
|
186
|
+
});
|
|
129
187
|
const gateways = await ario.getGateways();
|
|
130
188
|
</script>
|
|
131
189
|
```
|
|
132
190
|
|
|
133
|
-
###
|
|
134
|
-
|
|
135
|
-
#### ESM (NodeNext)
|
|
136
|
-
|
|
137
|
-
```javascript
|
|
138
|
-
import { ARIO } from "@ar.io/sdk/node";
|
|
139
|
-
|
|
140
|
-
// set up client
|
|
141
|
-
const ario = ARIO.mainnet();
|
|
142
|
-
// fetch gateways
|
|
143
|
-
const gateways = await ario.getGateways();
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
#### CJS
|
|
147
|
-
|
|
148
|
-
```javascript
|
|
149
|
-
import { ARIO } from "@ar.io/sdk";
|
|
150
|
-
|
|
151
|
-
// set up client
|
|
152
|
-
const ario = ARIO.mainnet();
|
|
153
|
-
// fetch gateways
|
|
154
|
-
const gateways = await ario.getGateways();
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Typescript
|
|
191
|
+
### TypeScript
|
|
158
192
|
|
|
159
|
-
The SDK
|
|
193
|
+
The SDK ships TypeScript types alongside the JS output. Types are
|
|
194
|
+
exported from `./lib/types/solana/index.d.ts` and resolve automatically
|
|
195
|
+
for ESM consumers.
|
|
160
196
|
|
|
161
197
|
> [!NOTE]
|
|
162
|
-
>
|
|
198
|
+
> TypeScript 5.3+ is recommended (the SDK uses `nodenext` module
|
|
199
|
+
> resolution with `.js` extensions in relative imports).
|
|
163
200
|
|
|
164
201
|
## ARIO Contract
|
|
165
202
|
|
|
166
203
|
### General
|
|
167
204
|
|
|
168
|
-
#### `init({ signer })`
|
|
205
|
+
#### `init({ rpc, rpcSubscriptions?, signer? })`
|
|
169
206
|
|
|
170
|
-
Factory function
|
|
207
|
+
Factory function that creates a read-only or writeable ARIO client.
|
|
208
|
+
Providing `signer` plus `rpcSubscriptions` enables write methods
|
|
209
|
+
(`joinNetwork`, `delegateStake`, `buyRecord`, etc.). Without a signer,
|
|
210
|
+
the client is read-only.
|
|
171
211
|
|
|
172
212
|
```typescript
|
|
173
|
-
|
|
174
|
-
|
|
213
|
+
import { ARIO } from '@ar.io/sdk';
|
|
214
|
+
import {
|
|
215
|
+
createSolanaRpc,
|
|
216
|
+
createSolanaRpcSubscriptions,
|
|
217
|
+
createKeyPairSignerFromBytes,
|
|
218
|
+
} from '@solana/kit';
|
|
175
219
|
|
|
176
|
-
|
|
177
|
-
const ario = ARIO.init({
|
|
178
|
-
signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({})),
|
|
179
|
-
});
|
|
220
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
180
221
|
|
|
181
|
-
// read-
|
|
182
|
-
const ario = ARIO.init({
|
|
222
|
+
// read-only client
|
|
223
|
+
const ario = ARIO.init({ rpc });
|
|
224
|
+
|
|
225
|
+
// read-write client (needs rpcSubscriptions for sendAndConfirm)
|
|
226
|
+
const rpcSubscriptions = createSolanaRpcSubscriptions(
|
|
227
|
+
'wss://api.mainnet-beta.solana.com',
|
|
228
|
+
);
|
|
229
|
+
const signer = await createKeyPairSignerFromBytes(/* 64-byte secret key */);
|
|
230
|
+
const arioWrite = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
183
231
|
```
|
|
184
232
|
|
|
185
233
|
#### `getInfo()`
|
|
@@ -187,7 +235,7 @@ const ario = ARIO.init({ signer: new ArweaveSigner(JWK) });
|
|
|
187
235
|
Retrieves the information of the ARIO process.
|
|
188
236
|
|
|
189
237
|
```typescript
|
|
190
|
-
const ario = ARIO.
|
|
238
|
+
const ario = ARIO.init({ rpc });
|
|
191
239
|
const info = await ario.getInfo();
|
|
192
240
|
```
|
|
193
241
|
|
|
@@ -196,16 +244,29 @@ const info = await ario.getInfo();
|
|
|
196
244
|
|
|
197
245
|
```json
|
|
198
246
|
{
|
|
199
|
-
"Name": "
|
|
247
|
+
"Name": "AR.IO",
|
|
200
248
|
"Ticker": "ARIO",
|
|
201
|
-
"
|
|
249
|
+
"Logo": "",
|
|
202
250
|
"Denomination": 6,
|
|
203
|
-
"Handlers": [
|
|
204
|
-
"LastCreatedEpochIndex":
|
|
205
|
-
"LastDistributedEpochIndex":
|
|
251
|
+
"Handlers": [],
|
|
252
|
+
"LastCreatedEpochIndex": 0,
|
|
253
|
+
"LastDistributedEpochIndex": 0,
|
|
254
|
+
"totalSupply": 1000000000000000,
|
|
255
|
+
"protocolBalance": 0,
|
|
256
|
+
"epochSettings": {
|
|
257
|
+
"durationMs": 86400000,
|
|
258
|
+
"prescribedNameCount": 25,
|
|
259
|
+
"maxObservers": 50
|
|
260
|
+
}
|
|
206
261
|
}
|
|
207
262
|
```
|
|
208
263
|
|
|
264
|
+
> **Note**: `Handlers`, `LastCreatedEpochIndex`, and `LastDistributedEpochIndex`
|
|
265
|
+
> are placeholders on Solana (returned for backwards-compatible field shape
|
|
266
|
+
> with consumer code). `totalSupply` / `protocolBalance` are live reads from
|
|
267
|
+
> the `ArioConfig` PDA; `epochSettings` is live from the `EpochSettings`
|
|
268
|
+
> PDA. See `src/solana/io-readable.ts` for the exact projection.
|
|
269
|
+
|
|
209
270
|
</details>
|
|
210
271
|
|
|
211
272
|
#### `getTokenSupply()`
|
|
@@ -221,7 +282,7 @@ Retrieves the total supply of tokens, returned in mARIO. The total supply includ
|
|
|
221
282
|
- `protocolBalance` - tokens that are held in the protocol's treasury. This is included in the circulating supply.
|
|
222
283
|
|
|
223
284
|
```typescript
|
|
224
|
-
const ario = ARIO.
|
|
285
|
+
const ario = ARIO.init({ rpc });
|
|
225
286
|
const supply = await ario.getTokenSupply();
|
|
226
287
|
```
|
|
227
288
|
|
|
@@ -247,7 +308,7 @@ const supply = await ario.getTokenSupply();
|
|
|
247
308
|
Retrieves the balance of the specified wallet address.
|
|
248
309
|
|
|
249
310
|
```typescript
|
|
250
|
-
const ario = ARIO.
|
|
311
|
+
const ario = ARIO.init({ rpc });
|
|
251
312
|
// the balance will be returned in mARIO as a value
|
|
252
313
|
const balance = await ario
|
|
253
314
|
.getBalance({
|
|
@@ -270,7 +331,7 @@ const balance = await ario
|
|
|
270
331
|
Retrieves the balances of the ARIO process in `mARIO`, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.
|
|
271
332
|
|
|
272
333
|
```typescript
|
|
273
|
-
const ario = ARIO.
|
|
334
|
+
const ario = ARIO.init({ rpc });
|
|
274
335
|
const balances = await ario.getBalances({
|
|
275
336
|
cursor: "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
276
337
|
limit: 100,
|
|
@@ -312,59 +373,49 @@ Transfers `mARIO` to the designated `target` recipient address. Requires `signer
|
|
|
312
373
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
313
374
|
|
|
314
375
|
```typescript
|
|
315
|
-
const ario = ARIO.
|
|
316
|
-
|
|
376
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
377
|
+
const { id: txId } = await ario.transfer({
|
|
378
|
+
target: 'RecipientSolanaPubkeyBase58',
|
|
379
|
+
qty: new ARIOToken(1000).toMARIO(),
|
|
317
380
|
});
|
|
318
|
-
const { id: txId } = await ario.transfer(
|
|
319
|
-
{
|
|
320
|
-
target: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
321
|
-
qty: new ARIOToken(1000).toMARIO(),
|
|
322
|
-
},
|
|
323
|
-
// optional additional tags
|
|
324
|
-
{ tags: [{ name: "App-Name", value: "My-Awesome-App" }] },
|
|
325
|
-
);
|
|
326
381
|
```
|
|
327
382
|
|
|
328
383
|
### Networks
|
|
329
384
|
|
|
330
|
-
The SDK
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
- `ARIO_TESTNET_PROCESS_ID` - Testnet ARIO process ID (testing and development)
|
|
334
|
-
- `ARIO_DEVNET_PROCESS_ID` - Devnet ARIO process ID (development)
|
|
335
|
-
|
|
336
|
-
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.
|
|
337
|
-
|
|
338
|
-
#### Mainnet
|
|
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.
|
|
385
|
+
The SDK talks to whatever cluster your `@solana/kit` RPC client points
|
|
386
|
+
at — mainnet-beta by default. For devnet or a local validator, override
|
|
387
|
+
the RPC URL and (on any non-mainnet cluster) the per-program addresses:
|
|
341
388
|
|
|
342
389
|
```typescript
|
|
343
|
-
import { ARIO } from
|
|
390
|
+
import { ARIO } from '@ar.io/sdk';
|
|
391
|
+
import { createSolanaRpc, address } from '@solana/kit';
|
|
344
392
|
|
|
345
|
-
const ario = ARIO.
|
|
393
|
+
const ario = ARIO.init({
|
|
394
|
+
rpc: createSolanaRpc('https://api.devnet.solana.com'),
|
|
395
|
+
coreProgramId: address('<ARIO_CORE_PROGRAM_ID>'),
|
|
396
|
+
garProgramId: address('<ARIO_GAR_PROGRAM_ID>'),
|
|
397
|
+
arnsProgramId: address('<ARIO_ARNS_PROGRAM_ID>'),
|
|
398
|
+
antProgramId: address('<ARIO_ANT_PROGRAM_ID>'),
|
|
399
|
+
});
|
|
346
400
|
```
|
|
347
401
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
|
-
import { ARIO } from "@ar.io/sdk";
|
|
352
|
-
|
|
353
|
-
const testnet = ARIO.testnet(); // or ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID })
|
|
354
|
-
```
|
|
402
|
+
On localnet (Surfpool) source program IDs from
|
|
403
|
+
`migration/localnet/out/localnet.env` in the `solana-ar-io` monorepo.
|
|
355
404
|
|
|
356
405
|
##### Faucet
|
|
357
406
|
|
|
358
|
-
The SDK
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
1. Visit [faucet.ar.io](https://faucet.ar.io) - the easiest way to quickly get tokens for testing for a single address.
|
|
407
|
+
The SDK exposes a `createFaucet` HTTP wrapper around the ar.io faucet
|
|
408
|
+
service ([faucet.ar.io](https://faucet.ar.io)). The faucet backend has
|
|
409
|
+
not yet been ported to issue Solana-mint transfers — the SDK surface is
|
|
410
|
+
documented here for forward-compatibility once it lands:
|
|
363
411
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
412
|
+
- `createFaucet({ arioInstance, processId }).captchaUrl()` — returns
|
|
413
|
+
the captcha URL.
|
|
414
|
+
- `createFaucet({ arioInstance, processId }).claimWithAuthToken({ authToken, recipient, quantity })` —
|
|
415
|
+
claim tokens for `recipient` using an auth token returned by the
|
|
416
|
+
captcha flow.
|
|
417
|
+
- `createFaucet({ arioInstance, processId }).verifyAuthToken({ authToken })` —
|
|
418
|
+
check whether an auth token is still valid.
|
|
368
419
|
|
|
369
420
|
<details>
|
|
370
421
|
<summary><i>Example client-side code for claiming tokens</i></summary>
|
|
@@ -372,7 +423,7 @@ To claim testnet tokens from the testnet token faucet, you can use one of the fo
|
|
|
372
423
|
```typescript
|
|
373
424
|
import { ARIO } from "@ar.io/sdk";
|
|
374
425
|
|
|
375
|
-
const
|
|
426
|
+
const ario = ARIO.init({ rpc });
|
|
376
427
|
const captchaUrl = await ario.faucet.captchaUrl();
|
|
377
428
|
|
|
378
429
|
// open the captcha URL in the browser, and listen for the auth token event
|
|
@@ -433,7 +484,7 @@ if (
|
|
|
433
484
|
Retrieves the locked-balance user vault of the ARIO process by the specified wallet address and vault ID.
|
|
434
485
|
|
|
435
486
|
```typescript
|
|
436
|
-
const ario = ARIO.
|
|
487
|
+
const ario = ARIO.init({ rpc });
|
|
437
488
|
const vault = await ario.getVault({
|
|
438
489
|
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
439
490
|
vaultId: "vaultIdOne",
|
|
@@ -458,7 +509,7 @@ const vault = await ario.getVault({
|
|
|
458
509
|
Retrieves all locked-balance user vaults of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.
|
|
459
510
|
|
|
460
511
|
```typescript
|
|
461
|
-
const ario = ARIO.
|
|
512
|
+
const ario = ARIO.init({ rpc });
|
|
462
513
|
const vaults = await ario.getVaults({
|
|
463
514
|
cursor: "0",
|
|
464
515
|
limit: 100,
|
|
@@ -506,7 +557,7 @@ Transfers `mARIO` to the designated `recipient` address and locks the balance fo
|
|
|
506
557
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
507
558
|
|
|
508
559
|
```typescript
|
|
509
|
-
const ario = ARIO.
|
|
560
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
510
561
|
const { id: txId } = await ario.vaultedTransfer(
|
|
511
562
|
{
|
|
512
563
|
recipient: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
@@ -526,7 +577,7 @@ Revokes a vaulted transfer by the recipient address and vault ID. Only the sende
|
|
|
526
577
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
527
578
|
|
|
528
579
|
```typescript
|
|
529
|
-
const ario = ARIO.
|
|
580
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
530
581
|
const { id: txId } = await ario.revokeVault({
|
|
531
582
|
recipient: "-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5",
|
|
532
583
|
vaultId: "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
@@ -538,7 +589,7 @@ const { id: txId } = await ario.revokeVault({
|
|
|
538
589
|
Creates a vault for the specified `quantity` of mARIO from the signer's balance and locks it for the specified `lockLengthMs` milliseconds.
|
|
539
590
|
|
|
540
591
|
```typescript
|
|
541
|
-
const ario = ARIO.
|
|
592
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
542
593
|
|
|
543
594
|
const { id: txId } = await ario.createVault({
|
|
544
595
|
lockLengthMs: 1000 * 60 * 60 * 24 * 365, // 1 year
|
|
@@ -551,7 +602,7 @@ const { id: txId } = await ario.createVault({
|
|
|
551
602
|
Extends the lock length of a signer's vault by the specified `extendLengthMs` milliseconds.
|
|
552
603
|
|
|
553
604
|
```typescript
|
|
554
|
-
const ario = ARIO.
|
|
605
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
555
606
|
|
|
556
607
|
const { id: txId } = await ario.extendVault({
|
|
557
608
|
vaultId: "vaultIdOne",
|
|
@@ -564,7 +615,7 @@ const { id: txId } = await ario.extendVault({
|
|
|
564
615
|
Increases the balance of a signer's vault by the specified `quantity` of mARIO.
|
|
565
616
|
|
|
566
617
|
```typescript
|
|
567
|
-
const ario = ARIO.
|
|
618
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
568
619
|
const { id: txId } = await ario.increaseVault({
|
|
569
620
|
vaultId: "vaultIdOne",
|
|
570
621
|
quantity: new ARIOToken(1000).toMARIO(),
|
|
@@ -578,7 +629,7 @@ const { id: txId } = await ario.increaseVault({
|
|
|
578
629
|
Retrieves a gateway's info by its staking wallet address.
|
|
579
630
|
|
|
580
631
|
```typescript
|
|
581
|
-
const ario = ARIO.
|
|
632
|
+
const ario = ARIO.init({ rpc });
|
|
582
633
|
const gateway = await ario.getGateway({
|
|
583
634
|
address: "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
|
|
584
635
|
});
|
|
@@ -591,7 +642,13 @@ const gateway = await ario.getGateway({
|
|
|
591
642
|
{
|
|
592
643
|
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
593
644
|
"operatorStake": 250000000000,
|
|
645
|
+
"totalDelegatedStake": 0,
|
|
594
646
|
"settings": {
|
|
647
|
+
"allowDelegatedStaking": true,
|
|
648
|
+
"allowedDelegates": [],
|
|
649
|
+
"autoStake": false,
|
|
650
|
+
"delegateRewardShareRatio": 10,
|
|
651
|
+
"minDelegatedStake": 100000000,
|
|
595
652
|
"fqdn": "ar-io.dev",
|
|
596
653
|
"label": "ar.io Test",
|
|
597
654
|
"note": "Test Gateway operated by PDS for the ar.io ecosystem.",
|
|
@@ -600,22 +657,26 @@ const gateway = await ario.getGateway({
|
|
|
600
657
|
"protocol": "https"
|
|
601
658
|
},
|
|
602
659
|
"startTimestamp": 1720720620813,
|
|
660
|
+
"endTimestamp": 0,
|
|
603
661
|
"stats": {
|
|
662
|
+
"passedConsecutiveEpochs": 30,
|
|
604
663
|
"failedConsecutiveEpochs": 0,
|
|
605
|
-
"passedEpochCount": 30,
|
|
606
|
-
"submittedEpochCount": 30,
|
|
607
664
|
"totalEpochCount": 31,
|
|
608
|
-
"
|
|
665
|
+
"passedEpochCount": 30,
|
|
666
|
+
"failedEpochCount": 1,
|
|
667
|
+
"observedEpochCount": 30,
|
|
668
|
+
"prescribedEpochCount": 31
|
|
609
669
|
},
|
|
610
670
|
"status": "joined",
|
|
611
|
-
"vaults": {},
|
|
612
671
|
"weights": {
|
|
613
|
-
"
|
|
614
|
-
"gatewayPerformanceRatio": 1,
|
|
672
|
+
"stakeWeight": 5.02400000024,
|
|
615
673
|
"tenureWeight": 0.19444444444444,
|
|
674
|
+
"gatewayPerformanceRatio": 1,
|
|
675
|
+
"observerPerformanceRatio": 1,
|
|
676
|
+
"gatewayRewardRatioWeight": 1,
|
|
616
677
|
"observerRewardRatioWeight": 1,
|
|
617
|
-
"
|
|
618
|
-
"
|
|
678
|
+
"compositeWeight": 0.97688888893556,
|
|
679
|
+
"normalizedCompositeWeight": 0.19247316211083
|
|
619
680
|
}
|
|
620
681
|
}
|
|
621
682
|
```
|
|
@@ -627,7 +688,7 @@ const gateway = await ario.getGateway({
|
|
|
627
688
|
Retrieves registered gateways of the ARIO process, using pagination and sorting by the specified criteria. The `cursor` used for pagination is the last gateway address from the previous request.
|
|
628
689
|
|
|
629
690
|
```typescript
|
|
630
|
-
const ario = ARIO.
|
|
691
|
+
const ario = ARIO.init({ rpc });
|
|
631
692
|
const gateways = await ario.getGateways({
|
|
632
693
|
limit: 100,
|
|
633
694
|
sortOrder: "desc",
|
|
@@ -647,7 +708,13 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
|
|
|
647
708
|
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
648
709
|
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
649
710
|
"operatorStake": 250000000000,
|
|
711
|
+
"totalDelegatedStake": 0,
|
|
650
712
|
"settings": {
|
|
713
|
+
"allowDelegatedStaking": true,
|
|
714
|
+
"allowedDelegates": [],
|
|
715
|
+
"autoStake": false,
|
|
716
|
+
"delegateRewardShareRatio": 10,
|
|
717
|
+
"minDelegatedStake": 100000000,
|
|
651
718
|
"fqdn": "ar-io.dev",
|
|
652
719
|
"label": "ar.io Test",
|
|
653
720
|
"note": "Test Gateway operated by PDS for the ar.io ecosystem.",
|
|
@@ -656,28 +723,33 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
|
|
|
656
723
|
"protocol": "https"
|
|
657
724
|
},
|
|
658
725
|
"startTimestamp": 1720720620813,
|
|
726
|
+
"endTimestamp": 0,
|
|
659
727
|
"stats": {
|
|
728
|
+
"passedConsecutiveEpochs": 30,
|
|
660
729
|
"failedConsecutiveEpochs": 0,
|
|
661
|
-
"passedEpochCount": 30,
|
|
662
|
-
"submittedEpochCount": 30,
|
|
663
730
|
"totalEpochCount": 31,
|
|
664
|
-
"
|
|
731
|
+
"passedEpochCount": 30,
|
|
732
|
+
"failedEpochCount": 1,
|
|
733
|
+
"observedEpochCount": 30,
|
|
734
|
+
"prescribedEpochCount": 31
|
|
665
735
|
},
|
|
666
736
|
"status": "joined",
|
|
667
|
-
"vaults": {},
|
|
668
737
|
"weights": {
|
|
669
|
-
"
|
|
670
|
-
"gatewayPerformanceRatio": 1,
|
|
738
|
+
"stakeWeight": 5.02400000024,
|
|
671
739
|
"tenureWeight": 0.19444444444444,
|
|
740
|
+
"gatewayPerformanceRatio": 1,
|
|
741
|
+
"observerPerformanceRatio": 1,
|
|
742
|
+
"gatewayRewardRatioWeight": 1,
|
|
672
743
|
"observerRewardRatioWeight": 1,
|
|
673
|
-
"
|
|
674
|
-
"
|
|
744
|
+
"compositeWeight": 0.97688888893556,
|
|
745
|
+
"normalizedCompositeWeight": 0.19247316211083
|
|
675
746
|
}
|
|
676
747
|
}
|
|
677
748
|
],
|
|
678
749
|
"hasMore": true,
|
|
679
750
|
"nextCursor": "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
680
751
|
"totalItems": 316,
|
|
752
|
+
"limit": 100,
|
|
681
753
|
"sortBy": "operatorStake",
|
|
682
754
|
"sortOrder": "desc"
|
|
683
755
|
}
|
|
@@ -690,7 +762,7 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
|
|
|
690
762
|
Retrieves all delegates for a specific gateway, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last delegate address from the previous request.
|
|
691
763
|
|
|
692
764
|
```typescript
|
|
693
|
-
const ario = ARIO.
|
|
765
|
+
const ario = ARIO.init({ rpc });
|
|
694
766
|
const delegates = await ario.getGatewayDelegates({
|
|
695
767
|
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
696
768
|
limit: 3,
|
|
@@ -739,7 +811,7 @@ Joins a gateway to the ar.io network via its associated wallet.
|
|
|
739
811
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
740
812
|
|
|
741
813
|
```typescript
|
|
742
|
-
const ario = ARIO.
|
|
814
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
743
815
|
const { id: txId } = await ario.joinNetwork(
|
|
744
816
|
{
|
|
745
817
|
qty: new ARIOToken(10_000).toMARIO(), // minimum operator stake allowed
|
|
@@ -767,7 +839,7 @@ Sets the gateway as `leaving` on the ar.io network. Requires `signer` to be prov
|
|
|
767
839
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
768
840
|
|
|
769
841
|
```typescript
|
|
770
|
-
const ario = ARIO.
|
|
842
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
771
843
|
|
|
772
844
|
const { id: txId } = await ario.leaveNetwork(
|
|
773
845
|
// optional additional tags
|
|
@@ -782,7 +854,7 @@ Writes new gateway settings to the callers gateway configuration.
|
|
|
782
854
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
783
855
|
|
|
784
856
|
```typescript
|
|
785
|
-
const ario = ARIO.
|
|
857
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
786
858
|
const { id: txId } = await ario.updateGatewaySettings(
|
|
787
859
|
{
|
|
788
860
|
// any other settings you want to update
|
|
@@ -800,7 +872,7 @@ Increases the callers stake on the target gateway.
|
|
|
800
872
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
801
873
|
|
|
802
874
|
```typescript
|
|
803
|
-
const ario = ARIO.
|
|
875
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
804
876
|
const { id: txId } = await ario.increaseDelegateStake(
|
|
805
877
|
{
|
|
806
878
|
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
@@ -818,7 +890,7 @@ Decreases the callers stake on the target gateway. Can instantly decrease stake
|
|
|
818
890
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
819
891
|
|
|
820
892
|
```typescript
|
|
821
|
-
const ario = ARIO.
|
|
893
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
822
894
|
const { id: txId } = await ario.decreaseDelegateStake(
|
|
823
895
|
{
|
|
824
896
|
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
@@ -833,7 +905,7 @@ const { id: txId } = await ario.decreaseDelegateStake(
|
|
|
833
905
|
Pay the early withdrawal fee and withdraw instantly.
|
|
834
906
|
|
|
835
907
|
```typescript
|
|
836
|
-
const ario = ARIO.
|
|
908
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
837
909
|
const { id: txId } = await ario.decreaseDelegateStake({
|
|
838
910
|
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
839
911
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -846,7 +918,7 @@ const { id: txId } = await ario.decreaseDelegateStake({
|
|
|
846
918
|
Retrieves all active and vaulted stakes across all gateways for a specific address, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last delegationId (concatenated gateway and startTimestamp of the delgation) from the previous request.
|
|
847
919
|
|
|
848
920
|
```typescript
|
|
849
|
-
const ario = ARIO.
|
|
921
|
+
const ario = ARIO.init({ rpc });
|
|
850
922
|
const vaults = await ario.getDelegations({
|
|
851
923
|
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
852
924
|
cursor: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_123456789",
|
|
@@ -897,7 +969,7 @@ Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is pr
|
|
|
897
969
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
898
970
|
|
|
899
971
|
```typescript
|
|
900
|
-
const ario = ARIO.
|
|
972
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
901
973
|
// removes a delegated vault from a gateway
|
|
902
974
|
const { id: txId } = await ario.instantWithdrawal(
|
|
903
975
|
{
|
|
@@ -924,7 +996,7 @@ Cancels an existing vault on a gateway. The vaulted stake will be returned to th
|
|
|
924
996
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
925
997
|
|
|
926
998
|
```typescript
|
|
927
|
-
const ario = ARIO.
|
|
999
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
928
1000
|
// cancels a delegated vault from a gateway
|
|
929
1001
|
const { id: txId } = await ario.cancelWithdrawal(
|
|
930
1002
|
{
|
|
@@ -948,7 +1020,7 @@ const { id: txId } = await ario.cancelWithdrawal({
|
|
|
948
1020
|
Retrieves all allowed delegates for a specific address. The `cursor` used for pagination is the last address from the previous request.
|
|
949
1021
|
|
|
950
1022
|
```typescript
|
|
951
|
-
const ario = ARIO.
|
|
1023
|
+
const ario = ARIO.init({ rpc });
|
|
952
1024
|
const allowedDelegates = await ario.getAllowedDelegates({
|
|
953
1025
|
address: "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
954
1026
|
});
|
|
@@ -979,7 +1051,7 @@ const allowedDelegates = await ario.getAllowedDelegates({
|
|
|
979
1051
|
Retrieves all vaults across all gateways for a specific address, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last vaultId from the previous request.
|
|
980
1052
|
|
|
981
1053
|
```typescript
|
|
982
|
-
const ario = ARIO.
|
|
1054
|
+
const ario = ARIO.init({ rpc });
|
|
983
1055
|
const vaults = await ario.getGatewayVaults({
|
|
984
1056
|
address: '"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM',
|
|
985
1057
|
});
|
|
@@ -1014,7 +1086,7 @@ const vaults = await ario.getGatewayVaults({
|
|
|
1014
1086
|
Retrieves all vaults across all gateways, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last vaultId from the previous request.
|
|
1015
1087
|
|
|
1016
1088
|
```typescript
|
|
1017
|
-
const ario = ARIO.
|
|
1089
|
+
const ario = ARIO.init({ rpc });
|
|
1018
1090
|
const vaults = await ario.getAllGatewayVaults({
|
|
1019
1091
|
limit: 1,
|
|
1020
1092
|
sortBy: "endTimestamp",
|
|
@@ -1048,6 +1120,57 @@ const vaults = await ario.getAllGatewayVaults({
|
|
|
1048
1120
|
|
|
1049
1121
|
</details>
|
|
1050
1122
|
|
|
1123
|
+
#### `getWithdrawals({ address, cursor, limit, sortBy, sortOrder })`
|
|
1124
|
+
|
|
1125
|
+
Returns every pending stake withdrawal owned by `address` — covering both operator-stake decreases (`isDelegate: false`) and delegate-stake decreases (`isDelegate: true`). A withdrawal is claimable when `Date.now() >= endTimestamp`; call `claimWithdrawal({ withdrawalId: item.vaultId })` to release the tokens.
|
|
1126
|
+
|
|
1127
|
+
This is the per-owner read needed to drive "you have X claimable withdrawals" UIs without fanning out across every gateway the wallet has interacted with.
|
|
1128
|
+
|
|
1129
|
+
```typescript
|
|
1130
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1131
|
+
|
|
1132
|
+
const withdrawals = await ario.getWithdrawals({
|
|
1133
|
+
address: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
const claimable = withdrawals.items.filter(
|
|
1137
|
+
(w) => Date.now() >= w.endTimestamp,
|
|
1138
|
+
);
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
<details>
|
|
1142
|
+
<summary>Output</summary>
|
|
1143
|
+
|
|
1144
|
+
```json
|
|
1145
|
+
{
|
|
1146
|
+
"hasMore": false,
|
|
1147
|
+
"totalItems": 2,
|
|
1148
|
+
"limit": 100,
|
|
1149
|
+
"items": [
|
|
1150
|
+
{
|
|
1151
|
+
"cursorId": "8CSdSjf7gXqQ5p1U2qfdwHzVw9sZRYHJpDpV87dnvb4d",
|
|
1152
|
+
"vaultId": "0",
|
|
1153
|
+
"gatewayAddress": "Bxz7Q2tWfqr9Q5T6cZjUnVxRk9CnHwShfgUaW5fY1Mvr",
|
|
1154
|
+
"balance": 50000000000,
|
|
1155
|
+
"startTimestamp": 1735843635857,
|
|
1156
|
+
"endTimestamp": 1738435635857,
|
|
1157
|
+
"isDelegate": true
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
"cursorId": "FmWUz4w7vSdLcz1nN8H1n2KkjJgrQQXR1n4kV3WqJ7Hf",
|
|
1161
|
+
"vaultId": "1",
|
|
1162
|
+
"gatewayAddress": "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
|
|
1163
|
+
"balance": 10000000000,
|
|
1164
|
+
"startTimestamp": 1735843835857,
|
|
1165
|
+
"endTimestamp": 1738435835857,
|
|
1166
|
+
"isDelegate": false
|
|
1167
|
+
}
|
|
1168
|
+
]
|
|
1169
|
+
}
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
</details>
|
|
1173
|
+
|
|
1051
1174
|
#### `increaseOperatorStake({ qty })`
|
|
1052
1175
|
|
|
1053
1176
|
Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
|
|
@@ -1055,7 +1178,7 @@ Increases the callers operator stake. Must be executed with a wallet registered
|
|
|
1055
1178
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1056
1179
|
|
|
1057
1180
|
```typescript
|
|
1058
|
-
const ario = ARIO.
|
|
1181
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1059
1182
|
const { id: txId } = await ario.increaseOperatorStake(
|
|
1060
1183
|
{
|
|
1061
1184
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -1073,7 +1196,7 @@ Decreases the callers operator stake. Must be executed with a wallet registered
|
|
|
1073
1196
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1074
1197
|
|
|
1075
1198
|
```typescript
|
|
1076
|
-
const ario = ARIO.
|
|
1199
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1077
1200
|
const { id: txId } = await ario.decreaseOperatorStake(
|
|
1078
1201
|
{
|
|
1079
1202
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -1091,7 +1214,7 @@ Redelegates the stake of a specific address to a new gateway. Vault ID may be op
|
|
|
1091
1214
|
e.g: If 1000 mARIO is redelegated and the fee rate is 10%, the fee will be 100 mARIO. Resulting in 900 mARIO being redelegated to the new gateway and 100 mARIO being deducted back to the protocol balance.
|
|
1092
1215
|
|
|
1093
1216
|
```typescript
|
|
1094
|
-
const ario = ARIO.
|
|
1217
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1095
1218
|
|
|
1096
1219
|
const { id: txId } = await ario.redelegateStake({
|
|
1097
1220
|
target: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
@@ -1106,7 +1229,7 @@ const { id: txId } = await ario.redelegateStake({
|
|
|
1106
1229
|
Retrieves the fee rate as percentage required to redelegate the stake of a specific address. Fee rate ranges from 0% to 60% based on the number of redelegations since the last fee reset.
|
|
1107
1230
|
|
|
1108
1231
|
```typescript
|
|
1109
|
-
const ario = ARIO.
|
|
1232
|
+
const ario = ARIO.init({ rpc });
|
|
1110
1233
|
|
|
1111
1234
|
const fee = await ario.getRedelegationFee({
|
|
1112
1235
|
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
@@ -1130,7 +1253,7 @@ const fee = await ario.getRedelegationFee({
|
|
|
1130
1253
|
Retrieves all delegates across all gateways, paginated and sorted by the specified criteria. The `cursor` used for pagination is a `cursorId` derived from delegate address and the gatewayAddress from the previous request. e.g `address_gatewayAddress`.
|
|
1131
1254
|
|
|
1132
1255
|
```typescript
|
|
1133
|
-
const ario = ARIO.
|
|
1256
|
+
const ario = ARIO.init({ rpc });
|
|
1134
1257
|
const delegates = await ario.getAllDelegates({
|
|
1135
1258
|
limit: 2,
|
|
1136
1259
|
sortBy: "startTimestamp",
|
|
@@ -1181,7 +1304,7 @@ Resolves an ArNS name to the underlying data id stored on the names correspondin
|
|
|
1181
1304
|
##### Resolving a base name
|
|
1182
1305
|
|
|
1183
1306
|
```typescript
|
|
1184
|
-
const ario = ARIO.
|
|
1307
|
+
const ario = ARIO.init({ rpc });
|
|
1185
1308
|
const record = await ario.resolveArNSName({ name: "ardrive" });
|
|
1186
1309
|
```
|
|
1187
1310
|
|
|
@@ -1190,13 +1313,12 @@ const record = await ario.resolveArNSName({ name: "ardrive" });
|
|
|
1190
1313
|
|
|
1191
1314
|
```json
|
|
1192
1315
|
{
|
|
1316
|
+
"name": "ardrive",
|
|
1193
1317
|
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
1194
1318
|
"txId": "kvhEUsIY5bXe0Wu2-YUFz20O078uYFzmQIO-7brv8qw",
|
|
1195
1319
|
"type": "lease",
|
|
1196
|
-
"
|
|
1197
|
-
"undernameLimit": 100
|
|
1198
|
-
"owner": "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1199
|
-
"name": "ardrive"
|
|
1320
|
+
"ttlSeconds": 3600,
|
|
1321
|
+
"undernameLimit": 100
|
|
1200
1322
|
}
|
|
1201
1323
|
```
|
|
1202
1324
|
|
|
@@ -1205,7 +1327,7 @@ const record = await ario.resolveArNSName({ name: "ardrive" });
|
|
|
1205
1327
|
##### Resolving an undername
|
|
1206
1328
|
|
|
1207
1329
|
```typescript
|
|
1208
|
-
const ario = ARIO.
|
|
1330
|
+
const ario = ARIO.init({ rpc });
|
|
1209
1331
|
const record = await ario.resolveArNSName({ name: "logo_ardrive" });
|
|
1210
1332
|
```
|
|
1211
1333
|
|
|
@@ -1214,13 +1336,12 @@ const record = await ario.resolveArNSName({ name: "logo_ardrive" });
|
|
|
1214
1336
|
|
|
1215
1337
|
```json
|
|
1216
1338
|
{
|
|
1339
|
+
"name": "ardrive",
|
|
1217
1340
|
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
1218
1341
|
"txId": "kvhEUsIY5bXe0Wu2-YUFz20O078uYFzmQIO-7brv8qw",
|
|
1219
1342
|
"type": "lease",
|
|
1220
|
-
"
|
|
1221
|
-
"undernameLimit": 100
|
|
1222
|
-
"owner": "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1223
|
-
"name": "ardrive"
|
|
1343
|
+
"ttlSeconds": 3600,
|
|
1344
|
+
"undernameLimit": 100
|
|
1224
1345
|
}
|
|
1225
1346
|
```
|
|
1226
1347
|
|
|
@@ -1241,7 +1362,7 @@ _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
|
1241
1362
|
- `referrer` - _optional_: track purchase referrals for analytics (e.g. `my-app.com`)
|
|
1242
1363
|
|
|
1243
1364
|
```typescript
|
|
1244
|
-
const ario = ARIO.
|
|
1365
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1245
1366
|
const record = await ario.buyRecord(
|
|
1246
1367
|
{
|
|
1247
1368
|
name: "ardrive",
|
|
@@ -1279,7 +1400,7 @@ Upgrades an existing leased ArNS record to a permanent ownership. The record mus
|
|
|
1279
1400
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1280
1401
|
|
|
1281
1402
|
```typescript
|
|
1282
|
-
const ario = ARIO.
|
|
1403
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1283
1404
|
const record = await ario.upgradeRecord(
|
|
1284
1405
|
{
|
|
1285
1406
|
name: "ardrive",
|
|
@@ -1297,7 +1418,7 @@ const record = await ario.upgradeRecord(
|
|
|
1297
1418
|
Retrieves the record info of the specified ArNS name.
|
|
1298
1419
|
|
|
1299
1420
|
```typescript
|
|
1300
|
-
const ario = ARIO.
|
|
1421
|
+
const ario = ARIO.init({ rpc });
|
|
1301
1422
|
const record = await ario.getArNSRecord({ name: "ardrive" });
|
|
1302
1423
|
```
|
|
1303
1424
|
|
|
@@ -1307,10 +1428,11 @@ const record = await ario.getArNSRecord({ name: "ardrive" });
|
|
|
1307
1428
|
```json
|
|
1308
1429
|
{
|
|
1309
1430
|
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
1310
|
-
"endTimestamp": 1752256702026,
|
|
1311
1431
|
"startTimestamp": 1720720819969,
|
|
1432
|
+
"endTimestamp": 1752256702026,
|
|
1312
1433
|
"type": "lease",
|
|
1313
|
-
"undernameLimit": 100
|
|
1434
|
+
"undernameLimit": 100,
|
|
1435
|
+
"purchasePrice": 75541282285
|
|
1314
1436
|
}
|
|
1315
1437
|
```
|
|
1316
1438
|
|
|
@@ -1321,7 +1443,7 @@ const record = await ario.getArNSRecord({ name: "ardrive" });
|
|
|
1321
1443
|
Retrieves all registered ArNS records of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last ArNS name from the previous request.
|
|
1322
1444
|
|
|
1323
1445
|
```typescript
|
|
1324
|
-
const ario = ARIO.
|
|
1446
|
+
const ario = ARIO.init({ rpc });
|
|
1325
1447
|
// get the newest 100 names
|
|
1326
1448
|
const records = await ario.getArNSRecords({
|
|
1327
1449
|
limit: 100,
|
|
@@ -1395,12 +1517,12 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`
|
|
|
1395
1517
|
|
|
1396
1518
|
</details>
|
|
1397
1519
|
|
|
1398
|
-
#### `getArNSRecordsForAddress({ address,
|
|
1520
|
+
#### `getArNSRecordsForAddress({ address, cursor, limit, sortBy, sortOrder })`
|
|
1399
1521
|
|
|
1400
1522
|
Retrieves all registered ArNS records of the specified address according to the `ANTRegistry` access control list, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last ArNS name from the previous request.
|
|
1401
1523
|
|
|
1402
1524
|
```typescript
|
|
1403
|
-
const ario = ARIO.
|
|
1525
|
+
const ario = ARIO.init({ rpc });
|
|
1404
1526
|
const records = await ario.getArNSRecordsForAddress({
|
|
1405
1527
|
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
1406
1528
|
limit: 100,
|
|
@@ -1445,7 +1567,7 @@ Increases the undername support of a domain up to a maximum of 10k. Domains, by
|
|
|
1445
1567
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1446
1568
|
|
|
1447
1569
|
```typescript
|
|
1448
|
-
const ario = ARIO.
|
|
1570
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1449
1571
|
const { id: txId } = await ario.increaseUndernameLimit(
|
|
1450
1572
|
{
|
|
1451
1573
|
name: "ar-io",
|
|
@@ -1462,7 +1584,7 @@ const { id: txId } = await ario.increaseUndernameLimit(
|
|
|
1462
1584
|
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.
|
|
1463
1585
|
|
|
1464
1586
|
```typescript
|
|
1465
|
-
const ario = ARIO.
|
|
1587
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1466
1588
|
const { id: txId } = await ario.extendLease(
|
|
1467
1589
|
{
|
|
1468
1590
|
name: "ar-io",
|
|
@@ -1516,19 +1638,14 @@ const costDetails = await ario.getCostDetails({
|
|
|
1516
1638
|
|
|
1517
1639
|
```json
|
|
1518
1640
|
{
|
|
1519
|
-
"tokenCost":
|
|
1520
|
-
"
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
"
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
}
|
|
1528
|
-
},
|
|
1529
|
-
"shortfall": 0
|
|
1530
|
-
},
|
|
1531
|
-
"discounts": []
|
|
1641
|
+
"tokenCost": 1907401818,
|
|
1642
|
+
"discounts": [
|
|
1643
|
+
{
|
|
1644
|
+
"name": "Gateway Operator",
|
|
1645
|
+
"discountTotal": 476850455,
|
|
1646
|
+
"multiplier": 0.8
|
|
1647
|
+
}
|
|
1648
|
+
]
|
|
1532
1649
|
}
|
|
1533
1650
|
```
|
|
1534
1651
|
|
|
@@ -1539,7 +1656,7 @@ const costDetails = await ario.getCostDetails({
|
|
|
1539
1656
|
Retrieves the current demand factor of the network. The demand factor is a multiplier applied to the cost of ArNS interactions based on the current network demand.
|
|
1540
1657
|
|
|
1541
1658
|
```typescript
|
|
1542
|
-
const ario = ARIO.
|
|
1659
|
+
const ario = ARIO.init({ rpc });
|
|
1543
1660
|
const demandFactor = await ario.getDemandFactor();
|
|
1544
1661
|
```
|
|
1545
1662
|
|
|
@@ -1557,7 +1674,7 @@ const demandFactor = await ario.getDemandFactor();
|
|
|
1557
1674
|
Retrieves all active returned names of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last returned name from the previous request.
|
|
1558
1675
|
|
|
1559
1676
|
```typescript
|
|
1560
|
-
const ario = ARIO.
|
|
1677
|
+
const ario = ARIO.init({ rpc });
|
|
1561
1678
|
const returnedNames = await ario.getArNSReturnedNames({
|
|
1562
1679
|
limit: 100,
|
|
1563
1680
|
sortBy: "endTimestamp",
|
|
@@ -1573,21 +1690,15 @@ const returnedNames = await ario.getArNSReturnedNames({
|
|
|
1573
1690
|
"items": [
|
|
1574
1691
|
{
|
|
1575
1692
|
"name": "permalink",
|
|
1576
|
-
"endTimestamp": 1730985241349,
|
|
1577
1693
|
"startTimestamp": 1729775641349,
|
|
1578
|
-
"
|
|
1579
|
-
"demandFactor": 1.05256,
|
|
1694
|
+
"endTimestamp": 1730985241349,
|
|
1580
1695
|
"initiator": "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",
|
|
1581
|
-
"
|
|
1582
|
-
"durationMs": 1209600000,
|
|
1583
|
-
"decayRate": 0.000000000016847809193121693,
|
|
1584
|
-
"scalingExponent": 190,
|
|
1585
|
-
"startPriceMultiplier": 50
|
|
1586
|
-
}
|
|
1696
|
+
"premiumMultiplier": 50
|
|
1587
1697
|
}
|
|
1588
1698
|
],
|
|
1589
1699
|
"hasMore": false,
|
|
1590
1700
|
"totalItems": 1,
|
|
1701
|
+
"limit": 100,
|
|
1591
1702
|
"sortBy": "endTimestamp",
|
|
1592
1703
|
"sortOrder": "asc"
|
|
1593
1704
|
}
|
|
@@ -1600,7 +1711,7 @@ const returnedNames = await ario.getArNSReturnedNames({
|
|
|
1600
1711
|
Retrieves the returned name data for the specified returned name.
|
|
1601
1712
|
|
|
1602
1713
|
```typescript
|
|
1603
|
-
const ario = ARIO.
|
|
1714
|
+
const ario = ARIO.init({ rpc });
|
|
1604
1715
|
const returnedName = await ario.getArNSReturnedName({ name: "permalink" });
|
|
1605
1716
|
```
|
|
1606
1717
|
|
|
@@ -1610,17 +1721,10 @@ const returnedName = await ario.getArNSReturnedName({ name: "permalink" });
|
|
|
1610
1721
|
```json
|
|
1611
1722
|
{
|
|
1612
1723
|
"name": "permalink",
|
|
1613
|
-
"endTimestamp": 1730985241349,
|
|
1614
1724
|
"startTimestamp": 1729775641349,
|
|
1615
|
-
"
|
|
1616
|
-
"demandFactor": 1.05256,
|
|
1725
|
+
"endTimestamp": 1730985241349,
|
|
1617
1726
|
"initiator": "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",
|
|
1618
|
-
"
|
|
1619
|
-
"durationMs": 1209600000,
|
|
1620
|
-
"decayRate": 0.000000000016847809193121693,
|
|
1621
|
-
"scalingExponent": 190,
|
|
1622
|
-
"startPriceMultiplier": 50
|
|
1623
|
-
}
|
|
1727
|
+
"premiumMultiplier": 50
|
|
1624
1728
|
}
|
|
1625
1729
|
```
|
|
1626
1730
|
|
|
@@ -1633,7 +1737,7 @@ const returnedName = await ario.getArNSReturnedName({ name: "permalink" });
|
|
|
1633
1737
|
Returns the current epoch data.
|
|
1634
1738
|
|
|
1635
1739
|
```typescript
|
|
1636
|
-
const ario = ARIO.
|
|
1740
|
+
const ario = ARIO.init({ rpc });
|
|
1637
1741
|
const epoch = await ario.getCurrentEpoch();
|
|
1638
1742
|
```
|
|
1639
1743
|
|
|
@@ -1643,10 +1747,10 @@ const epoch = await ario.getCurrentEpoch();
|
|
|
1643
1747
|
```json
|
|
1644
1748
|
{
|
|
1645
1749
|
"epochIndex": 0,
|
|
1750
|
+
"startHeight": 0,
|
|
1646
1751
|
"startTimestamp": 1720720621424,
|
|
1647
1752
|
"endTimestamp": 1752256702026,
|
|
1648
|
-
"
|
|
1649
|
-
"distributionTimestamp": 1711122739,
|
|
1753
|
+
"distributionTimestamp": 1752256702026,
|
|
1650
1754
|
"observations": {
|
|
1651
1755
|
"failureSummaries": {
|
|
1652
1756
|
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
@@ -1663,21 +1767,28 @@ const epoch = await ario.getCurrentEpoch();
|
|
|
1663
1767
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1664
1768
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1665
1769
|
"stake": 10000000000,
|
|
1666
|
-
"
|
|
1770
|
+
"startTimestamp": 1720720621424,
|
|
1667
1771
|
"stakeWeight": 1,
|
|
1668
1772
|
"tenureWeight": 0.4494598765432099,
|
|
1669
1773
|
"gatewayPerformanceRatio": 1,
|
|
1774
|
+
"observerPerformanceRatio": 1,
|
|
1775
|
+
"gatewayRewardRatioWeight": 1,
|
|
1670
1776
|
"observerRewardRatioWeight": 1,
|
|
1671
1777
|
"compositeWeight": 0.4494598765432099,
|
|
1672
1778
|
"normalizedCompositeWeight": 0.002057032496835938
|
|
1673
1779
|
}
|
|
1674
1780
|
],
|
|
1675
1781
|
"distributions": {
|
|
1676
|
-
"
|
|
1782
|
+
"totalEligibleGateways": 1,
|
|
1677
1783
|
"totalEligibleRewards": 100000000,
|
|
1678
|
-
"
|
|
1679
|
-
|
|
1680
|
-
|
|
1784
|
+
"totalEligibleObserverReward": 100000000,
|
|
1785
|
+
"totalEligibleGatewayReward": 100000000
|
|
1786
|
+
},
|
|
1787
|
+
"arnsStats": {
|
|
1788
|
+
"totalReturnedNames": 0,
|
|
1789
|
+
"totalActiveNames": 0,
|
|
1790
|
+
"totalGracePeriodNames": 0,
|
|
1791
|
+
"totalReservedNames": 0
|
|
1681
1792
|
}
|
|
1682
1793
|
}
|
|
1683
1794
|
```
|
|
@@ -1689,7 +1800,7 @@ const epoch = await ario.getCurrentEpoch();
|
|
|
1689
1800
|
Returns the epoch data for the specified block height. If no epoch index is provided, the current epoch is used.
|
|
1690
1801
|
|
|
1691
1802
|
```typescript
|
|
1692
|
-
const ario = ARIO.
|
|
1803
|
+
const ario = ARIO.init({ rpc });
|
|
1693
1804
|
const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
1694
1805
|
```
|
|
1695
1806
|
|
|
@@ -1699,9 +1810,9 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
|
1699
1810
|
```json
|
|
1700
1811
|
{
|
|
1701
1812
|
"epochIndex": 0,
|
|
1813
|
+
"startHeight": 0,
|
|
1702
1814
|
"startTimestamp": 1720720620813,
|
|
1703
1815
|
"endTimestamp": 1752256702026,
|
|
1704
|
-
"startHeight": 1350700,
|
|
1705
1816
|
"distributionTimestamp": 1752256702026,
|
|
1706
1817
|
"observations": {
|
|
1707
1818
|
"failureSummaries": {
|
|
@@ -1718,11 +1829,13 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
|
1718
1829
|
{
|
|
1719
1830
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1720
1831
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1721
|
-
"stake": 10000000000,
|
|
1832
|
+
"stake": 10000000000,
|
|
1722
1833
|
"startTimestamp": 1720720620813,
|
|
1723
1834
|
"stakeWeight": 1,
|
|
1724
1835
|
"tenureWeight": 0.4494598765432099,
|
|
1725
1836
|
"gatewayPerformanceRatio": 1,
|
|
1837
|
+
"observerPerformanceRatio": 1,
|
|
1838
|
+
"gatewayRewardRatioWeight": 1,
|
|
1726
1839
|
"observerRewardRatioWeight": 1,
|
|
1727
1840
|
"compositeWeight": 0.4494598765432099,
|
|
1728
1841
|
"normalizedCompositeWeight": 0.002057032496835938
|
|
@@ -1732,14 +1845,13 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
|
1732
1845
|
"totalEligibleGateways": 1,
|
|
1733
1846
|
"totalEligibleRewards": 100000000,
|
|
1734
1847
|
"totalEligibleObserverReward": 100000000,
|
|
1735
|
-
"totalEligibleGatewayReward": 100000000
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
"
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
}
|
|
1848
|
+
"totalEligibleGatewayReward": 100000000
|
|
1849
|
+
},
|
|
1850
|
+
"arnsStats": {
|
|
1851
|
+
"totalReturnedNames": 0,
|
|
1852
|
+
"totalActiveNames": 0,
|
|
1853
|
+
"totalGracePeriodNames": 0,
|
|
1854
|
+
"totalReservedNames": 0
|
|
1743
1855
|
}
|
|
1744
1856
|
}
|
|
1745
1857
|
```
|
|
@@ -1751,7 +1863,7 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
|
1751
1863
|
Returns the eligible epoch rewards for the specified block height. If no epoch index is provided, the current epoch is used.
|
|
1752
1864
|
|
|
1753
1865
|
```typescript
|
|
1754
|
-
const ario = ARIO.
|
|
1866
|
+
const ario = ARIO.init({ rpc });
|
|
1755
1867
|
const rewards = await ario.getEligibleEpochRewards({ epochIndex: 0 });
|
|
1756
1868
|
```
|
|
1757
1869
|
|
|
@@ -1784,7 +1896,7 @@ const rewards = await ario.getEligibleEpochRewards({ epochIndex: 0 });
|
|
|
1784
1896
|
Returns the epoch-indexed observation list. If no epoch index is provided, the current epoch is used.
|
|
1785
1897
|
|
|
1786
1898
|
```typescript
|
|
1787
|
-
const ario = ARIO.
|
|
1899
|
+
const ario = ARIO.init({ rpc });
|
|
1788
1900
|
const observations = await ario.getObservations();
|
|
1789
1901
|
```
|
|
1790
1902
|
|
|
@@ -1793,19 +1905,16 @@ const observations = await ario.getObservations();
|
|
|
1793
1905
|
|
|
1794
1906
|
```json
|
|
1795
1907
|
{
|
|
1796
|
-
"
|
|
1797
|
-
"
|
|
1798
|
-
"
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
"
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
"osZP4D9cqeDvbVFBaEfjIxwc1QLIvRxUBRAxDIX9je8": "aatgznEvC_UPcxp1v0uw_RqydhIfKm4wtt1KCpONBB0",
|
|
1807
|
-
"qZ90I67XG68BYIAFVNfm9PUdM7v1XtFTn7u-EOZFAtk": "Bd8SmFK9-ktJRmwIungS8ur6JM-JtpxrvMtjt5JkB1M"
|
|
1808
|
-
}
|
|
1908
|
+
"failureSummaries": {
|
|
1909
|
+
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
1910
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA"
|
|
1911
|
+
]
|
|
1912
|
+
},
|
|
1913
|
+
"reports": {
|
|
1914
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": "B6UUjKWjjEWDBvDSMXWNmymfwvgR9EN27z5FTkEVlX4",
|
|
1915
|
+
"Ie2wEEUDKoU26c7IuckHNn3vMFdNQnMvfPBrFzAb3NA": "7tKsiQ2fxv0D8ZVN_QEv29fZ8hwFIgHoEDrpeEG0DIs",
|
|
1916
|
+
"osZP4D9cqeDvbVFBaEfjIxwc1QLIvRxUBRAxDIX9je8": "aatgznEvC_UPcxp1v0uw_RqydhIfKm4wtt1KCpONBB0",
|
|
1917
|
+
"qZ90I67XG68BYIAFVNfm9PUdM7v1XtFTn7u-EOZFAtk": "Bd8SmFK9-ktJRmwIungS8ur6JM-JtpxrvMtjt5JkB1M"
|
|
1809
1918
|
}
|
|
1810
1919
|
}
|
|
1811
1920
|
```
|
|
@@ -1817,7 +1926,7 @@ const observations = await ario.getObservations();
|
|
|
1817
1926
|
Returns the current rewards distribution information. If no epoch index is provided, the current epoch is used.
|
|
1818
1927
|
|
|
1819
1928
|
```typescript
|
|
1820
|
-
const ario = ARIO.
|
|
1929
|
+
const ario = ARIO.init({ rpc });
|
|
1821
1930
|
const distributions = await ario.getDistributions({ epochIndex: 0 });
|
|
1822
1931
|
```
|
|
1823
1932
|
|
|
@@ -1829,20 +1938,7 @@ const distributions = await ario.getDistributions({ epochIndex: 0 });
|
|
|
1829
1938
|
"totalEligibleGateways": 1,
|
|
1830
1939
|
"totalEligibleRewards": 100000000,
|
|
1831
1940
|
"totalEligibleObserverReward": 100000000,
|
|
1832
|
-
"totalEligibleGatewayReward": 100000000
|
|
1833
|
-
"totalDistributedRewards": 100000000,
|
|
1834
|
-
"distributedTimestamp": 1720720621424,
|
|
1835
|
-
"rewards": {
|
|
1836
|
-
"eligible": {
|
|
1837
|
-
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": {
|
|
1838
|
-
"operatorReward": 100000000,
|
|
1839
|
-
"delegateRewards": {}
|
|
1840
|
-
}
|
|
1841
|
-
},
|
|
1842
|
-
"distributed": {
|
|
1843
|
-
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1941
|
+
"totalEligibleGatewayReward": 100000000
|
|
1846
1942
|
}
|
|
1847
1943
|
```
|
|
1848
1944
|
|
|
@@ -1853,7 +1949,7 @@ Saves the observations of the current epoch. Requires `signer` to be provided on
|
|
|
1853
1949
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1854
1950
|
|
|
1855
1951
|
```typescript
|
|
1856
|
-
const ario = ARIO.
|
|
1952
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1857
1953
|
const { id: txId } = await ario.saveObservations(
|
|
1858
1954
|
{
|
|
1859
1955
|
reportTxId: "fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3",
|
|
@@ -1872,7 +1968,7 @@ const { id: txId } = await ario.saveObservations(
|
|
|
1872
1968
|
Retrieves the prescribed observers of the ARIO process. To fetch prescribed observers for a previous epoch set the `epochIndex` to the desired epoch index.
|
|
1873
1969
|
|
|
1874
1970
|
```typescript
|
|
1875
|
-
const ario = ARIO.
|
|
1971
|
+
const ario = ARIO.init({ rpc });
|
|
1876
1972
|
const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
|
|
1877
1973
|
```
|
|
1878
1974
|
|
|
@@ -1884,11 +1980,13 @@ const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
|
|
|
1884
1980
|
{
|
|
1885
1981
|
"gatewayAddress": "BpQlyhREz4lNGS-y3rSS1WxADfxPpAuing9Lgfdrj2U",
|
|
1886
1982
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1887
|
-
"stake": 10000000000,
|
|
1888
|
-
"
|
|
1983
|
+
"stake": 10000000000,
|
|
1984
|
+
"startTimestamp": 1720720620813,
|
|
1889
1985
|
"stakeWeight": 1,
|
|
1890
1986
|
"tenureWeight": 0.41453703703703704,
|
|
1891
1987
|
"gatewayPerformanceRatio": 1,
|
|
1988
|
+
"observerPerformanceRatio": 1,
|
|
1989
|
+
"gatewayRewardRatioWeight": 1,
|
|
1892
1990
|
"observerRewardRatioWeight": 1,
|
|
1893
1991
|
"compositeWeight": 0.41453703703703704,
|
|
1894
1992
|
"normalizedCompositeWeight": 0.0018972019546783507
|
|
@@ -1905,7 +2003,7 @@ const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
|
|
|
1905
2003
|
Retrieves all primary names paginated and sorted by the specified criteria. The `cursor` used for pagination is the last name from the previous request.
|
|
1906
2004
|
|
|
1907
2005
|
```typescript
|
|
1908
|
-
const ario = ARIO.
|
|
2006
|
+
const ario = ARIO.init({ rpc });
|
|
1909
2007
|
const names = await ario.getPrimaryNames({
|
|
1910
2008
|
cursor: "ao", // this is the last name from the previous request
|
|
1911
2009
|
limit: 1,
|
|
@@ -1924,12 +2022,13 @@ const names = await ario.getPrimaryNames({
|
|
|
1924
2022
|
"totalItems": 100,
|
|
1925
2023
|
"limit": 1,
|
|
1926
2024
|
"sortBy": "startTimestamp",
|
|
1927
|
-
"
|
|
2025
|
+
"nextCursor": "arns",
|
|
1928
2026
|
"items": [
|
|
1929
2027
|
{
|
|
2028
|
+
"name": "arns",
|
|
1930
2029
|
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
|
|
1931
|
-
"
|
|
1932
|
-
"
|
|
2030
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2031
|
+
"startTimestamp": 1719356032297
|
|
1933
2032
|
}
|
|
1934
2033
|
]
|
|
1935
2034
|
}
|
|
@@ -1942,7 +2041,7 @@ const names = await ario.getPrimaryNames({
|
|
|
1942
2041
|
Retrieves the primary name for a given name or address.
|
|
1943
2042
|
|
|
1944
2043
|
```typescript
|
|
1945
|
-
const ario = ARIO.
|
|
2044
|
+
const ario = ARIO.init({ rpc });
|
|
1946
2045
|
const name = await ario.getPrimaryName({
|
|
1947
2046
|
name: "arns",
|
|
1948
2047
|
});
|
|
@@ -1957,9 +2056,10 @@ const name = await ario.getPrimaryName({
|
|
|
1957
2056
|
|
|
1958
2057
|
```json
|
|
1959
2058
|
{
|
|
2059
|
+
"name": "arns",
|
|
1960
2060
|
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
|
|
1961
|
-
"
|
|
1962
|
-
"
|
|
2061
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2062
|
+
"startTimestamp": 1719356032297
|
|
1963
2063
|
}
|
|
1964
2064
|
```
|
|
1965
2065
|
|
|
@@ -1972,9 +2072,8 @@ Sets an ArNS name already owned by the `signer` as their primary name. Note: `si
|
|
|
1972
2072
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1973
2073
|
|
|
1974
2074
|
```typescript
|
|
1975
|
-
const
|
|
1976
|
-
|
|
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
|
|
2075
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
2076
|
+
await ario.setPrimaryName({ name: 'my-arns-name' });
|
|
1978
2077
|
```
|
|
1979
2078
|
|
|
1980
2079
|
#### `requestPrimaryName({ name })`
|
|
@@ -1984,7 +2083,7 @@ Requests a primary name for the `signer`'s address. The request must be approved
|
|
|
1984
2083
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1985
2084
|
|
|
1986
2085
|
```typescript
|
|
1987
|
-
const ario = ARIO.
|
|
2086
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
1988
2087
|
const { id: txId } = await ario.requestPrimaryName({
|
|
1989
2088
|
name: "arns",
|
|
1990
2089
|
});
|
|
@@ -1995,7 +2094,7 @@ const { id: txId } = await ario.requestPrimaryName({
|
|
|
1995
2094
|
Retrieves the primary name request for a a wallet address.
|
|
1996
2095
|
|
|
1997
2096
|
```typescript
|
|
1998
|
-
const ario = ARIO.
|
|
2097
|
+
const ario = ARIO.init({ rpc });
|
|
1999
2098
|
const request = await ario.getPrimaryNameRequest({
|
|
2000
2099
|
initiator: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
|
|
2001
2100
|
});
|
|
@@ -2017,80 +2116,71 @@ const request = await ario.getPrimaryNameRequest({
|
|
|
2017
2116
|
|
|
2018
2117
|
### Configuration
|
|
2019
2118
|
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
import { ARIO , AOProcess } from '@ar.io/sdk';
|
|
2024
|
-
import { connect } from '@permaweb/aoconnect';
|
|
2025
|
-
|
|
2026
|
-
// provide a custom ao infrastructure and process id
|
|
2027
|
-
const ario = ARIO.mainnet({
|
|
2028
|
-
process: new AOProcess({
|
|
2029
|
-
processId: 'ARIO_PROCESS_ID'
|
|
2030
|
-
ao: connect({
|
|
2031
|
-
MODE: 'legacy',
|
|
2032
|
-
MU_URL: 'https://mu-testnet.xyz',
|
|
2033
|
-
CU_URL: 'https://cu-testnet.xyz',
|
|
2034
|
-
GRAPHQL_URL: 'https://arweave.net/graphql',
|
|
2035
|
-
GATEWAY_URL: 'https://arweave.net',
|
|
2036
|
-
})
|
|
2037
|
-
})
|
|
2038
|
-
});
|
|
2039
|
-
```
|
|
2119
|
+
`ARIO.init` accepts a `@solana/kit` RPC client plus optional program ID
|
|
2120
|
+
overrides for non-mainnet clusters. See [Networks](#networks) above for
|
|
2121
|
+
the full shape.
|
|
2040
2122
|
|
|
2041
2123
|
## ANT Contracts
|
|
2042
2124
|
|
|
2043
|
-
The ANT client class exposes APIs
|
|
2125
|
+
The ANT client class exposes APIs for Arweave Name Tokens. On Solana an
|
|
2126
|
+
ANT is a Metaplex Core asset; its `processId` is the asset's mint
|
|
2127
|
+
pubkey. The `ario-ant` program owns the on-chain records / controllers
|
|
2128
|
+
state attached to the asset.
|
|
2044
2129
|
|
|
2045
2130
|
### Initialize
|
|
2046
2131
|
|
|
2047
|
-
#### `init({ processId, signer })`
|
|
2132
|
+
#### `init({ processId, rpc, rpcSubscriptions?, signer? })`
|
|
2048
2133
|
|
|
2049
|
-
Factory
|
|
2134
|
+
Factory that creates a read-only or writeable ANT client. Providing
|
|
2135
|
+
`signer` and `rpcSubscriptions` enables write methods (`setRecord`,
|
|
2136
|
+
`transfer`, `addController`, etc.).
|
|
2050
2137
|
|
|
2051
2138
|
```typescript
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2139
|
+
import { ANT } from '@ar.io/sdk';
|
|
2140
|
+
import {
|
|
2141
|
+
createSolanaRpc,
|
|
2142
|
+
createSolanaRpcSubscriptions,
|
|
2143
|
+
} from '@solana/kit';
|
|
2144
|
+
|
|
2145
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
2146
|
+
|
|
2147
|
+
// Read-only
|
|
2148
|
+
const ant = await ANT.init({
|
|
2149
|
+
processId: '<MPL Core asset pubkey>',
|
|
2150
|
+
rpc,
|
|
2056
2151
|
});
|
|
2057
2152
|
|
|
2058
|
-
//
|
|
2059
|
-
const
|
|
2060
|
-
|
|
2061
|
-
|
|
2153
|
+
// Read + write
|
|
2154
|
+
const antWrite = await ANT.init({
|
|
2155
|
+
processId: '<MPL Core asset pubkey>',
|
|
2156
|
+
rpc,
|
|
2157
|
+
rpcSubscriptions: createSolanaRpcSubscriptions(
|
|
2158
|
+
'wss://api.mainnet-beta.solana.com',
|
|
2159
|
+
),
|
|
2160
|
+
signer,
|
|
2062
2161
|
});
|
|
2063
2162
|
```
|
|
2064
2163
|
|
|
2065
2164
|
### Spawn
|
|
2066
2165
|
|
|
2067
|
-
#### `spawn({
|
|
2068
|
-
|
|
2069
|
-
Spawns a new ANT (Arweave Name Token) process. This static function creates a new ANT process on the AO network and returns the process ID.
|
|
2166
|
+
#### `ANT.spawn({ rpc, rpcSubscriptions, signer, state })`
|
|
2070
2167
|
|
|
2071
|
-
|
|
2168
|
+
Static factory that mints a new MPL Core asset and initializes the
|
|
2169
|
+
`ario-ant` PDAs in a single transaction. Returns
|
|
2170
|
+
`{ processId, mint, signature }`.
|
|
2072
2171
|
|
|
2073
2172
|
```typescript
|
|
2074
|
-
import { ANT } from
|
|
2075
|
-
import { ArweaveSigner } from "@ar.io/sdk/node";
|
|
2173
|
+
import { ANT } from '@ar.io/sdk';
|
|
2076
2174
|
|
|
2077
|
-
const processId = await ANT.spawn({
|
|
2078
|
-
|
|
2175
|
+
const { processId, signature } = await ANT.spawn({
|
|
2176
|
+
rpc,
|
|
2177
|
+
rpcSubscriptions,
|
|
2178
|
+
signer,
|
|
2079
2179
|
state: {
|
|
2080
|
-
name:
|
|
2081
|
-
ticker:
|
|
2082
|
-
description:
|
|
2083
|
-
|
|
2084
|
-
});
|
|
2085
|
-
|
|
2086
|
-
// Using a custom module ID
|
|
2087
|
-
const processId = await ANT.spawn({
|
|
2088
|
-
signer: new ArweaveSigner(jwk),
|
|
2089
|
-
module: "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE", // Custom module ID
|
|
2090
|
-
state: {
|
|
2091
|
-
name: "My Custom Module ANT",
|
|
2092
|
-
ticker: "CUSTOM",
|
|
2093
|
-
description: "ANT using a specific module version",
|
|
2180
|
+
name: 'My ANT',
|
|
2181
|
+
ticker: 'MYANT',
|
|
2182
|
+
description: 'My ANT token',
|
|
2183
|
+
uri: 'ar://<metadata-tx-id>',
|
|
2094
2184
|
},
|
|
2095
2185
|
});
|
|
2096
2186
|
```
|
|
@@ -2098,25 +2188,34 @@ const processId = await ANT.spawn({
|
|
|
2098
2188
|
**CLI Usage:**
|
|
2099
2189
|
|
|
2100
2190
|
```bash
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2191
|
+
ar.io spawn-ant \
|
|
2192
|
+
--wallet-file wallet.json \
|
|
2193
|
+
--name "My ANT" \
|
|
2194
|
+
--ticker "MYANT" \
|
|
2195
|
+
--metadata-uri "ar://<metadata-tx-id>"
|
|
2106
2196
|
```
|
|
2107
2197
|
|
|
2108
2198
|
**Parameters:**
|
|
2109
2199
|
|
|
2110
|
-
- `
|
|
2111
|
-
- `
|
|
2112
|
-
- `
|
|
2113
|
-
- `
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
- `
|
|
2117
|
-
- `
|
|
2200
|
+
- `state.name: string` — display name of the ANT
|
|
2201
|
+
- `state.ticker?: string` — ticker symbol
|
|
2202
|
+
- `state.description?: string` — short description
|
|
2203
|
+
- `state.uri: string` — `ar://` URI of the Metaplex Core asset's JSON
|
|
2204
|
+
metadata. Build via `buildAntMetadata` from `@ar.io/sdk` and upload
|
|
2205
|
+
to Arweave (e.g. via `@ardrive/turbo-sdk`).
|
|
2206
|
+
- `state.keywords?: string[]`
|
|
2207
|
+
- `state.logo?: string` — Arweave TX ID of the logo
|
|
2208
|
+
- `state.transactionId?: string` — initial `@` record target
|
|
2118
2209
|
|
|
2119
|
-
**Returns:**
|
|
2210
|
+
**Returns:**
|
|
2211
|
+
|
|
2212
|
+
```ts
|
|
2213
|
+
{
|
|
2214
|
+
processId: string; // the MPL Core asset mint pubkey
|
|
2215
|
+
mint: Address;
|
|
2216
|
+
signature: string; // the Solana tx signature
|
|
2217
|
+
}
|
|
2218
|
+
```
|
|
2120
2219
|
|
|
2121
2220
|
### Versions
|
|
2122
2221
|
|
|
@@ -2187,61 +2286,6 @@ true
|
|
|
2187
2286
|
|
|
2188
2287
|
</details>
|
|
2189
2288
|
|
|
2190
|
-
#### `getANTVersions`
|
|
2191
|
-
|
|
2192
|
-
Static method that returns the full array of available ANT versions and the latest version from the ANT registry.
|
|
2193
|
-
|
|
2194
|
-
```typescript
|
|
2195
|
-
import { ANT } from "@ar.io/sdk";
|
|
2196
|
-
|
|
2197
|
-
// Get all available ANT versions
|
|
2198
|
-
const antVersions = ANT.versions;
|
|
2199
|
-
const versions = await antVersions.getANTVersions();
|
|
2200
|
-
```
|
|
2201
|
-
|
|
2202
|
-
Result:
|
|
2203
|
-
|
|
2204
|
-
```json
|
|
2205
|
-
{
|
|
2206
|
-
[
|
|
2207
|
-
{
|
|
2208
|
-
"moduleId": "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE",
|
|
2209
|
-
"version": "23",
|
|
2210
|
-
"releaseNotes": "Initial release of the ANT module.",
|
|
2211
|
-
"releaseDate": 1700000000000
|
|
2212
|
-
}
|
|
2213
|
-
// ...other versions
|
|
2214
|
-
],
|
|
2215
|
-
}
|
|
2216
|
-
```
|
|
2217
|
-
|
|
2218
|
-
#### `getLatestANTVersion()`
|
|
2219
|
-
|
|
2220
|
-
Static method that returns the latest ANT version from the ANT registry.
|
|
2221
|
-
|
|
2222
|
-
```typescript
|
|
2223
|
-
import { ANT } from "@ar.io/sdk";
|
|
2224
|
-
|
|
2225
|
-
// Get the latest ANT version
|
|
2226
|
-
import { ANT } from "@ar.io/sdk";
|
|
2227
|
-
|
|
2228
|
-
// Get all available ANT versions
|
|
2229
|
-
const antVersions = ANT.versions;
|
|
2230
|
-
const versions = await antVersions.getANTVersions();
|
|
2231
|
-
const latestVersion = await antVersions.getLatestANTVersion();
|
|
2232
|
-
```
|
|
2233
|
-
|
|
2234
|
-
Result:
|
|
2235
|
-
|
|
2236
|
-
```json
|
|
2237
|
-
{
|
|
2238
|
-
"moduleId": "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE",
|
|
2239
|
-
"version": "23",
|
|
2240
|
-
"releaseNotes": "Initial release of the ANT module.",
|
|
2241
|
-
"releaseDate": 1700000000000
|
|
2242
|
-
}
|
|
2243
|
-
```
|
|
2244
|
-
|
|
2245
2289
|
### State
|
|
2246
2290
|
|
|
2247
2291
|
#### `getInfo()`
|
|
@@ -2257,11 +2301,42 @@ const info = await ant.getInfo();
|
|
|
2257
2301
|
|
|
2258
2302
|
```json
|
|
2259
2303
|
{
|
|
2260
|
-
"
|
|
2261
|
-
"
|
|
2262
|
-
"
|
|
2263
|
-
"
|
|
2264
|
-
"
|
|
2304
|
+
"Name": "ArDrive",
|
|
2305
|
+
"Owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
2306
|
+
"Ticker": "ANT-ARDRIVE",
|
|
2307
|
+
"Total-Supply": "1",
|
|
2308
|
+
"Description": "This is the ANT for the ArDrive decentralized web app.",
|
|
2309
|
+
"Keywords": ["File-sharing", "Publishing", "dApp"],
|
|
2310
|
+
"Logo": "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A",
|
|
2311
|
+
"Denomination": "0",
|
|
2312
|
+
"Handlers": [
|
|
2313
|
+
"balance",
|
|
2314
|
+
"balances",
|
|
2315
|
+
"totalSupply",
|
|
2316
|
+
"info",
|
|
2317
|
+
"controllers",
|
|
2318
|
+
"record",
|
|
2319
|
+
"records",
|
|
2320
|
+
"state",
|
|
2321
|
+
"transfer",
|
|
2322
|
+
"addController",
|
|
2323
|
+
"removeController",
|
|
2324
|
+
"setRecord",
|
|
2325
|
+
"removeRecord",
|
|
2326
|
+
"setName",
|
|
2327
|
+
"setTicker",
|
|
2328
|
+
"setDescription",
|
|
2329
|
+
"setKeywords",
|
|
2330
|
+
"setLogo",
|
|
2331
|
+
"initializeState",
|
|
2332
|
+
"releaseName",
|
|
2333
|
+
"reassignName",
|
|
2334
|
+
"approvePrimaryName",
|
|
2335
|
+
"removePrimaryNames",
|
|
2336
|
+
"transferRecordOwnership",
|
|
2337
|
+
"_eval",
|
|
2338
|
+
"_default"
|
|
2339
|
+
]
|
|
2265
2340
|
}
|
|
2266
2341
|
```
|
|
2267
2342
|
|
|
@@ -2280,24 +2355,32 @@ const handlers = await ant.getHandlers();
|
|
|
2280
2355
|
|
|
2281
2356
|
```json
|
|
2282
2357
|
[
|
|
2283
|
-
"_eval",
|
|
2284
|
-
"_default",
|
|
2285
|
-
"transfer",
|
|
2286
2358
|
"balance",
|
|
2287
2359
|
"balances",
|
|
2288
2360
|
"totalSupply",
|
|
2289
2361
|
"info",
|
|
2362
|
+
"controllers",
|
|
2363
|
+
"record",
|
|
2364
|
+
"records",
|
|
2365
|
+
"state",
|
|
2366
|
+
"transfer",
|
|
2290
2367
|
"addController",
|
|
2291
2368
|
"removeController",
|
|
2292
|
-
"controllers",
|
|
2293
2369
|
"setRecord",
|
|
2294
2370
|
"removeRecord",
|
|
2295
|
-
"record",
|
|
2296
|
-
"records",
|
|
2297
2371
|
"setName",
|
|
2298
2372
|
"setTicker",
|
|
2373
|
+
"setDescription",
|
|
2374
|
+
"setKeywords",
|
|
2375
|
+
"setLogo",
|
|
2299
2376
|
"initializeState",
|
|
2300
|
-
"
|
|
2377
|
+
"releaseName",
|
|
2378
|
+
"reassignName",
|
|
2379
|
+
"approvePrimaryName",
|
|
2380
|
+
"removePrimaryNames",
|
|
2381
|
+
"transferRecordOwnership",
|
|
2382
|
+
"_eval",
|
|
2383
|
+
"_default"
|
|
2301
2384
|
]
|
|
2302
2385
|
```
|
|
2303
2386
|
|
|
@@ -2316,23 +2399,28 @@ const state = await ant.getState();
|
|
|
2316
2399
|
|
|
2317
2400
|
```json
|
|
2318
2401
|
{
|
|
2319
|
-
"
|
|
2320
|
-
"
|
|
2321
|
-
|
|
2322
|
-
|
|
2402
|
+
"Name": "ar.io Foundation",
|
|
2403
|
+
"Ticker": "ANT-AR-IO",
|
|
2404
|
+
"Description": "A friendly description for this ANT.",
|
|
2405
|
+
"Keywords": ["keyword1", "keyword2", "keyword3"],
|
|
2406
|
+
"Denomination": 0,
|
|
2407
|
+
"Owner": "98O1_xqDLrBKRfQPWjF5p7xZ4Jx6GM8P5PeJn26xwUY",
|
|
2323
2408
|
"Controllers": [],
|
|
2324
2409
|
"Records": {
|
|
2325
2410
|
"v1-0-0_whitepaper": {
|
|
2326
2411
|
"transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
|
|
2327
|
-
"ttlSeconds": 900
|
|
2412
|
+
"ttlSeconds": 900,
|
|
2413
|
+
"targetProtocol": 0
|
|
2328
2414
|
},
|
|
2329
2415
|
"@": {
|
|
2330
2416
|
"transactionId": "2rMLb2uHAyEt7jSu6bXtKx8e-jOfIf7E-DOgQnm8EtU",
|
|
2331
|
-
"ttlSeconds": 3600
|
|
2417
|
+
"ttlSeconds": 3600,
|
|
2418
|
+
"targetProtocol": 0
|
|
2332
2419
|
},
|
|
2333
2420
|
"alice": {
|
|
2334
2421
|
"transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
|
|
2335
2422
|
"ttlSeconds": 900,
|
|
2423
|
+
"targetProtocol": 0,
|
|
2336
2424
|
"owner": "alice-wallet-address-123...",
|
|
2337
2425
|
"displayName": "Alice's Portfolio",
|
|
2338
2426
|
"logo": "avatar-tx-id-456...",
|
|
@@ -2341,17 +2429,16 @@ const state = await ant.getState();
|
|
|
2341
2429
|
},
|
|
2342
2430
|
"whitepaper": {
|
|
2343
2431
|
"transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
|
|
2344
|
-
"ttlSeconds": 900
|
|
2432
|
+
"ttlSeconds": 900,
|
|
2433
|
+
"targetProtocol": 0
|
|
2345
2434
|
}
|
|
2346
2435
|
},
|
|
2347
|
-
"
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
"Keywords": ["keyword1", "keyword2", "keyword3"],
|
|
2436
|
+
"Balances": {
|
|
2437
|
+
"98O1_xqDLrBKRfQPWjF5p7xZ4Jx6GM8P5PeJn26xwUY": 1
|
|
2438
|
+
},
|
|
2351
2439
|
"Logo": "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A",
|
|
2352
|
-
"
|
|
2353
|
-
"
|
|
2354
|
-
"Owner": "98O1_xqDLrBKRfQPWjF5p7xZ4Jx6GM8P5PeJn26xwUY"
|
|
2440
|
+
"TotalSupply": 1,
|
|
2441
|
+
"Initialized": true
|
|
2355
2442
|
}
|
|
2356
2443
|
```
|
|
2357
2444
|
|
|
@@ -2440,24 +2527,32 @@ const records = await ant.getRecords();
|
|
|
2440
2527
|
{
|
|
2441
2528
|
"@": {
|
|
2442
2529
|
"transactionId": "UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk",
|
|
2443
|
-
"ttlSeconds": 3600
|
|
2530
|
+
"ttlSeconds": 3600,
|
|
2531
|
+
"targetProtocol": 0,
|
|
2532
|
+
"index": 0
|
|
2444
2533
|
},
|
|
2445
2534
|
"alice": {
|
|
2446
2535
|
"transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
|
|
2447
2536
|
"ttlSeconds": 900,
|
|
2537
|
+
"targetProtocol": 0,
|
|
2448
2538
|
"owner": "alice-wallet-address-123...",
|
|
2449
2539
|
"displayName": "Alice's Portfolio",
|
|
2450
2540
|
"logo": "avatar-tx-id-456...",
|
|
2451
2541
|
"description": "Personal portfolio and blog",
|
|
2452
|
-
"keywords": ["portfolio", "personal", "blog"]
|
|
2542
|
+
"keywords": ["portfolio", "personal", "blog"],
|
|
2543
|
+
"index": 1
|
|
2453
2544
|
},
|
|
2454
2545
|
"zed": {
|
|
2455
2546
|
"transactionId": "-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",
|
|
2456
|
-
"ttlSeconds": 900
|
|
2547
|
+
"ttlSeconds": 900,
|
|
2548
|
+
"targetProtocol": 0,
|
|
2549
|
+
"index": 2
|
|
2457
2550
|
},
|
|
2458
2551
|
"ardrive": {
|
|
2459
2552
|
"transactionId": "-cucucachoodwedwedoiwepodiwpodiwpoidpwoiedp",
|
|
2460
|
-
"ttlSeconds": 900
|
|
2553
|
+
"ttlSeconds": 900,
|
|
2554
|
+
"targetProtocol": 0,
|
|
2555
|
+
"index": 3
|
|
2461
2556
|
}
|
|
2462
2557
|
}
|
|
2463
2558
|
```
|
|
@@ -2479,6 +2574,7 @@ const record = await ant.getRecord({ undername: "dapp" });
|
|
|
2479
2574
|
{
|
|
2480
2575
|
"transactionId": "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
2481
2576
|
"ttlSeconds": 900,
|
|
2577
|
+
"targetProtocol": 0,
|
|
2482
2578
|
"owner": "alice-wallet-address-123...",
|
|
2483
2579
|
"displayName": "Alice's Site",
|
|
2484
2580
|
"logo": "avatar-tx-id-456...",
|
|
@@ -2793,115 +2889,28 @@ const { id: txId } = await ant.setLogo(
|
|
|
2793
2889
|
|
|
2794
2890
|
### ARIO Integrations
|
|
2795
2891
|
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
```typescript
|
|
2803
|
-
const { id: txId } = await ant.releaseName({
|
|
2804
|
-
name: "permalink",
|
|
2805
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
|
|
2806
|
-
});
|
|
2807
|
-
```
|
|
2808
|
-
|
|
2809
|
-
#### `reassignName({ name, arioProcessId, antProcessId })`
|
|
2810
|
-
|
|
2811
|
-
Reassigns a name to a new ANT. This can only be done by the current owner of the ANT.
|
|
2812
|
-
|
|
2813
|
-
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2814
|
-
|
|
2815
|
-
```typescript
|
|
2816
|
-
const { id: txId } = await ant.reassignName({
|
|
2817
|
-
name: "ardrive",
|
|
2818
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2819
|
-
antProcessId: NEW_ANT_PROCESS_ID, // the new ANT process id that will take over ownership of the name
|
|
2820
|
-
});
|
|
2821
|
-
```
|
|
2822
|
-
|
|
2823
|
-
#### `approvePrimaryNameRequest({ name, address, arioProcessId })`
|
|
2824
|
-
|
|
2825
|
-
Approves a primary name request for a given name or address.
|
|
2826
|
-
|
|
2827
|
-
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2828
|
-
|
|
2829
|
-
```typescript
|
|
2830
|
-
const { id: txId } = await ant.approvePrimaryNameRequest({
|
|
2831
|
-
name: "arns",
|
|
2832
|
-
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3", // must match the request initiator address
|
|
2833
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID, // the ARIO process id to use for the request
|
|
2834
|
-
});
|
|
2835
|
-
```
|
|
2836
|
-
|
|
2837
|
-
#### `removePrimaryNames({ names, arioProcessId, notifyOwners })`
|
|
2838
|
-
|
|
2839
|
-
Removes primary names from the ANT process.
|
|
2840
|
-
|
|
2841
|
-
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2842
|
-
|
|
2843
|
-
```typescript
|
|
2844
|
-
const { id: txId } = await ant.removePrimaryNames({
|
|
2845
|
-
names: ["arns", "test_arns"], // any primary names associated with a base name controlled by this ANT will be removed
|
|
2846
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2847
|
-
notifyOwners: true, // if true, the owners of the removed names will be send AO messages to notify them of the removal
|
|
2848
|
-
});
|
|
2849
|
-
```
|
|
2892
|
+
`releaseName`, `reassignName`, `approvePrimaryNameRequest`, and
|
|
2893
|
+
`removePrimaryNames` were AO-only orchestration helpers and have been
|
|
2894
|
+
removed. Their on-chain equivalents on Solana live on the `ario-arns`
|
|
2895
|
+
program and are exposed through the `ARIO` write client
|
|
2896
|
+
(`upgradeRecord`, `setPrimaryName`, etc.) or — for permissionless
|
|
2897
|
+
maintenance — through `SolanaARIOWriteable`'s prune helpers.
|
|
2850
2898
|
|
|
2851
2899
|
### Upgrade
|
|
2852
2900
|
|
|
2853
|
-
#### `upgrade(
|
|
2901
|
+
#### `upgrade()`
|
|
2854
2902
|
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2903
|
+
Migrates this ANT's on-chain state to the latest schema version (per-
|
|
2904
|
+
ANT data migration on Solana — no process forking, no name
|
|
2905
|
+
reassignment). Returns `{ id, needsMigration }`.
|
|
2858
2906
|
|
|
2859
2907
|
```typescript
|
|
2860
|
-
// Upgrade ANT and reassign all affiliated ArNS names to the new process
|
|
2861
2908
|
const result = await ant.upgrade();
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
names: ["ardrive", "example"],
|
|
2866
|
-
});
|
|
2867
|
-
|
|
2868
|
-
// with callbacks
|
|
2869
|
-
const result = await ant.upgrade({
|
|
2870
|
-
names: ["ardrive", "example"],
|
|
2871
|
-
onSigningProgress: (event, payload) => {
|
|
2872
|
-
console.log(`${event}:`, payload);
|
|
2873
|
-
if (event === "checking-version") {
|
|
2874
|
-
console.log(`Checking version: ${payload.antProcessId}`);
|
|
2875
|
-
}
|
|
2876
|
-
if (event === "fetching-affiliated-names") {
|
|
2877
|
-
console.log(`Fetching affiliated names: ${payload.arioProcessId}`);
|
|
2878
|
-
}
|
|
2879
|
-
if (event === "reassigning-name") {
|
|
2880
|
-
console.log(`Reassigning name: ${payload.name}`);
|
|
2881
|
-
}
|
|
2882
|
-
if (event === "validating-names") {
|
|
2883
|
-
console.log(`Validating names: ${payload.names}`);
|
|
2884
|
-
}
|
|
2885
|
-
// other callback events...
|
|
2886
|
-
},
|
|
2887
|
-
});
|
|
2888
|
-
|
|
2889
|
-
console.log(`Upgraded to process: ${result.forkedProcessId}`);
|
|
2890
|
-
console.log(`Successfully reassigned names: ${result.reassignedNames}`);
|
|
2891
|
-
console.log(`Failed to reassign names: ${result.failedReassignedNames}`);
|
|
2909
|
+
if (result.needsMigration) {
|
|
2910
|
+
console.log(`Migrated: ${result.id}`);
|
|
2911
|
+
}
|
|
2892
2912
|
```
|
|
2893
2913
|
|
|
2894
|
-
**Parameters:**
|
|
2895
|
-
|
|
2896
|
-
- `reassignAffiliatedNames?: boolean` - If true, reassigns all names associated with this process to the new forked process (defaults to true when names is empty)
|
|
2897
|
-
- `names?: string[]` - Optional array of specific names to reassign (cannot be used with `reassignAffiliatedNames: true`). These names must be affiliated with this ANT on the provided ARIO process.
|
|
2898
|
-
- `arioProcessId?: string` - Optional ARIO process ID (defaults to mainnet)
|
|
2899
|
-
- `antRegistryId?: string` - Optional ANT registry process ID used to resolve the latest version (defaults to mainnet registry)
|
|
2900
|
-
- `skipVersionCheck?: boolean` - Skip checking if ANT is already latest version (defaults to false)
|
|
2901
|
-
- `onSigningProgress?: Function` - Optional progress callback for tracking upgrade steps
|
|
2902
|
-
|
|
2903
|
-
**Returns:** `Promise<{ forkedProcessId: string, reassignedNames: Record<string, AoMessageResult>, failedReassignedNames: Record<string, { id?: string; error: Error }> }>`
|
|
2904
|
-
|
|
2905
2914
|
### Undername Ownership
|
|
2906
2915
|
|
|
2907
2916
|
NTs support ownership of undernames:
|
|
@@ -2954,9 +2963,11 @@ console.log(`Transaction ID: ${record.transactionId}`);
|
|
|
2954
2963
|
|
|
2955
2964
|
```typescript
|
|
2956
2965
|
// Alice (record owner) updating her own record
|
|
2957
|
-
const aliceAnt = ANT.init({
|
|
2958
|
-
processId:
|
|
2959
|
-
|
|
2966
|
+
const aliceAnt = await ANT.init({
|
|
2967
|
+
processId: 'ANT_MINT_PUBKEY',
|
|
2968
|
+
rpc,
|
|
2969
|
+
rpcSubscriptions,
|
|
2970
|
+
signer: aliceSigner, // Alice's @solana/kit signer
|
|
2960
2971
|
});
|
|
2961
2972
|
|
|
2962
2973
|
// ✅ CORRECT: Alice includes her own address as owner
|
|
@@ -3010,54 +3021,10 @@ console.log(recordAfter.owner); // undefined (controlled by ANT owner again)
|
|
|
3010
3021
|
|
|
3011
3022
|
### Static Methods
|
|
3012
3023
|
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
```typescript
|
|
3018
|
-
const newProcessId = await ANT.fork({
|
|
3019
|
-
signer: new ArweaveSigner(jwk),
|
|
3020
|
-
antProcessId: "existing-ant-process-id",
|
|
3021
|
-
// Optional: specify a specific module ID, defaults to latest from registry
|
|
3022
|
-
module: "new-module-id",
|
|
3023
|
-
onSigningProgress: (event, payload) => {
|
|
3024
|
-
console.log(`Fork progress: ${event}`);
|
|
3025
|
-
},
|
|
3026
|
-
});
|
|
3027
|
-
|
|
3028
|
-
console.log(`Forked ANT to new process: ${newProcessId}`);
|
|
3029
|
-
```
|
|
3030
|
-
|
|
3031
|
-
#### `ANT.upgrade({ signer, antProcessId, reassignAffiliatedNames?, names?, arioProcessId?, antRegistryId?, ao?, logger?, skipVersionCheck?, onSigningProgress?, hyperbeamUrl? })`
|
|
3032
|
-
|
|
3033
|
-
Static method to upgrade an ANT by forking it to the latest version and reassigning names.
|
|
3034
|
-
|
|
3035
|
-
```typescript
|
|
3036
|
-
// Upgrade and reassign all affiliated names
|
|
3037
|
-
const result = await ANT.upgrade({
|
|
3038
|
-
signer: new ArweaveSigner(jwk),
|
|
3039
|
-
antProcessId: "existing-ant-process-id",
|
|
3040
|
-
reassignAffiliatedNames: true,
|
|
3041
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
3042
|
-
});
|
|
3043
|
-
|
|
3044
|
-
// Upgrade and reassign specific names
|
|
3045
|
-
const result = await ANT.upgrade({
|
|
3046
|
-
signer: new ArweaveSigner(jwk),
|
|
3047
|
-
antProcessId: "existing-ant-process-id",
|
|
3048
|
-
names: ["ardrive", "example"],
|
|
3049
|
-
reassignAffiliatedNames: false,
|
|
3050
|
-
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
3051
|
-
});
|
|
3052
|
-
|
|
3053
|
-
console.log(`Upgraded to process: ${result.forkedProcessId}`);
|
|
3054
|
-
console.log(
|
|
3055
|
-
`Successfully reassigned names: ${Object.keys(result.reassignedNames)}`,
|
|
3056
|
-
);
|
|
3057
|
-
console.log(
|
|
3058
|
-
`Failed reassignments: ${Object.keys(result.failedReassignedNames)}`,
|
|
3059
|
-
);
|
|
3060
|
-
```
|
|
3024
|
+
`ANT.fork()` and the static `ANT.upgrade()` were AO-only (process
|
|
3025
|
+
forking + name reassignment). On Solana, schema migration is a
|
|
3026
|
+
per-asset CPI exposed as the instance method `ant.upgrade()` documented
|
|
3027
|
+
above; new ANTs are created with `ANT.spawn()`.
|
|
3061
3028
|
|
|
3062
3029
|
## Token Conversion
|
|
3063
3030
|
|
|
@@ -3111,10 +3078,9 @@ const customLogger: ILogger = {
|
|
|
3111
3078
|
},
|
|
3112
3079
|
};
|
|
3113
3080
|
|
|
3114
|
-
//
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
// or set it as the default logger in the entire SDK
|
|
3081
|
+
// Set it as the default logger across the entire SDK — every class
|
|
3082
|
+
// (ARIO, ANT, ANTRegistry, etc.) will route logs through it. `ARIO.init`
|
|
3083
|
+
// does not accept a per-instance logger.
|
|
3118
3084
|
Logger.default = customLogger;
|
|
3119
3085
|
```
|
|
3120
3086
|
|
|
@@ -3170,6 +3136,136 @@ In the example above, the query will return ArNS records where:
|
|
|
3170
3136
|
- The type is "lease" AND
|
|
3171
3137
|
- The processId is EITHER "ZkgLfyHALs5koxzojpcsEFAKA8fbpzP7l-tbM7wmQNM" OR "r61rbOjyXx3u644nGl9bkwLWlWmArMEzQgxBo2R-Vu0"
|
|
3172
3138
|
|
|
3139
|
+
## Advanced
|
|
3140
|
+
|
|
3141
|
+
### RPC Configuration
|
|
3142
|
+
|
|
3143
|
+
The SDK accepts any `@solana/kit` RPC client. For read-only usage, only
|
|
3144
|
+
`rpc` is required. Write operations additionally need `rpcSubscriptions`
|
|
3145
|
+
(WebSocket) for transaction confirmation and a `signer`.
|
|
3146
|
+
|
|
3147
|
+
#### Basic (read-only)
|
|
3148
|
+
|
|
3149
|
+
```ts
|
|
3150
|
+
import { ARIO } from '@ar.io/sdk';
|
|
3151
|
+
import { createSolanaRpc } from '@solana/kit';
|
|
3152
|
+
|
|
3153
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
3154
|
+
const ario = ARIO.init({ rpc });
|
|
3155
|
+
```
|
|
3156
|
+
|
|
3157
|
+
#### With writes (signer + WebSocket subscriptions)
|
|
3158
|
+
|
|
3159
|
+
```ts
|
|
3160
|
+
import { ARIO } from '@ar.io/sdk';
|
|
3161
|
+
import {
|
|
3162
|
+
createSolanaRpc,
|
|
3163
|
+
createSolanaRpcSubscriptions,
|
|
3164
|
+
createKeyPairSignerFromBytes,
|
|
3165
|
+
} from '@solana/kit';
|
|
3166
|
+
|
|
3167
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
3168
|
+
const rpcSubscriptions = createSolanaRpcSubscriptions(
|
|
3169
|
+
'wss://api.mainnet-beta.solana.com',
|
|
3170
|
+
);
|
|
3171
|
+
const signer = await createKeyPairSignerFromBytes(/* ... */);
|
|
3172
|
+
|
|
3173
|
+
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
|
|
3174
|
+
```
|
|
3175
|
+
|
|
3176
|
+
> **Note:** `rpcSubscriptions` opens a WebSocket connection and is only
|
|
3177
|
+
> needed for writes. If your RPC provider doesn't expose a WebSocket
|
|
3178
|
+
> endpoint, omit it and use the SDK in read-only mode.
|
|
3179
|
+
|
|
3180
|
+
### Circuit Breaker
|
|
3181
|
+
|
|
3182
|
+
The SDK ships an [opossum]-backed circuit breaker that wraps the RPC
|
|
3183
|
+
transport. When the primary endpoint starts failing (429 rate-limits,
|
|
3184
|
+
5xx errors, network timeouts) the circuit opens and subsequent calls
|
|
3185
|
+
route transparently to a fallback RPC until the primary recovers.
|
|
3186
|
+
|
|
3187
|
+
```ts
|
|
3188
|
+
import { ARIO, createCircuitBreakerRpc } from '@ar.io/sdk';
|
|
3189
|
+
|
|
3190
|
+
const rpc = createCircuitBreakerRpc({
|
|
3191
|
+
primaryUrl: 'https://my-premium-rpc.example.com',
|
|
3192
|
+
fallbackUrl: 'https://api.mainnet-beta.solana.com',
|
|
3193
|
+
});
|
|
3194
|
+
|
|
3195
|
+
const ario = ARIO.init({ rpc });
|
|
3196
|
+
```
|
|
3197
|
+
|
|
3198
|
+
Use `defaultFallbackUrl()` to auto-pick mainnet or devnet based on the
|
|
3199
|
+
primary URL:
|
|
3200
|
+
|
|
3201
|
+
```ts
|
|
3202
|
+
import {
|
|
3203
|
+
createCircuitBreakerRpc,
|
|
3204
|
+
defaultFallbackUrl,
|
|
3205
|
+
} from '@ar.io/sdk';
|
|
3206
|
+
|
|
3207
|
+
const primaryUrl = 'https://my-premium-rpc.example.com';
|
|
3208
|
+
const rpc = createCircuitBreakerRpc({
|
|
3209
|
+
primaryUrl,
|
|
3210
|
+
fallbackUrl: defaultFallbackUrl(primaryUrl), // → mainnet public RPC
|
|
3211
|
+
});
|
|
3212
|
+
```
|
|
3213
|
+
|
|
3214
|
+
Tuning knobs (all optional):
|
|
3215
|
+
|
|
3216
|
+
| Option | Default | Description |
|
|
3217
|
+
|---|---|---|
|
|
3218
|
+
| `timeout` | `10000` | ms before a single request is timed out (`false` to disable) |
|
|
3219
|
+
| `errorThresholdPercentage` | `50` | error % at which to open the circuit |
|
|
3220
|
+
| `resetTimeout` | `30000` | ms to wait before probing the primary again (half-open) |
|
|
3221
|
+
| `volumeThreshold` | `5` | minimum requests in the rolling window before the circuit can trip |
|
|
3222
|
+
|
|
3223
|
+
### Automatic Retries
|
|
3224
|
+
|
|
3225
|
+
All RPC **read** calls (account fetches, `getProgramAccounts`, etc.)
|
|
3226
|
+
automatically retry on transient transport errors with exponential
|
|
3227
|
+
back-off. Writes are **not** retried (to avoid double-sends).
|
|
3228
|
+
|
|
3229
|
+
Retried errors: HTTP 429/5xx, `fetch failed`, `ECONNRESET`,
|
|
3230
|
+
`ETIMEDOUT`, `AbortError` / timeouts. Non-retryable errors (account
|
|
3231
|
+
not found, invalid params, deserialization) throw immediately.
|
|
3232
|
+
|
|
3233
|
+
Defaults: **6 attempts**, 500 ms base delay, 5 s max delay. Override
|
|
3234
|
+
per-call with the exported `withRetry` helper:
|
|
3235
|
+
|
|
3236
|
+
```ts
|
|
3237
|
+
import { withRetry } from '@ar.io/sdk';
|
|
3238
|
+
|
|
3239
|
+
const result = await withRetry(() => rpc.getAccountInfo(addr).send(), {
|
|
3240
|
+
maxAttempts: 3,
|
|
3241
|
+
baseDelayMs: 1000,
|
|
3242
|
+
});
|
|
3243
|
+
```
|
|
3244
|
+
|
|
3245
|
+
### Generated instruction builders
|
|
3246
|
+
|
|
3247
|
+
For custom transaction building, import Codama-generated typed clients
|
|
3248
|
+
from [`@ar.io/solana-contracts`](https://www.npmjs.com/package/@ar.io/solana-contracts):
|
|
3249
|
+
|
|
3250
|
+
```ts
|
|
3251
|
+
import {
|
|
3252
|
+
getBuyNameInstructionAsync,
|
|
3253
|
+
ARIO_ARNS_PROGRAM_ADDRESS,
|
|
3254
|
+
} from '@ar.io/solana-contracts/arns';
|
|
3255
|
+
```
|
|
3256
|
+
|
|
3257
|
+
### Networks
|
|
3258
|
+
|
|
3259
|
+
| Network | RPC | Programs |
|
|
3260
|
+
|---|---|---|
|
|
3261
|
+
| Mainnet | not yet deployed | TBD |
|
|
3262
|
+
| Devnet | `https://api.devnet.solana.com` | See `src/solana/constants.ts` for current devnet program IDs |
|
|
3263
|
+
| Localnet | Surfpool — `https://github.com/solana-foundation/surfpool` | Localnet harness in `solana-ar-io` monorepo |
|
|
3264
|
+
|
|
3265
|
+
The migration tooling (snapshot exporter, batch importer, claim app)
|
|
3266
|
+
lives in the [`solana-ar-io`](https://github.com/ar-io/solana-ar-io)
|
|
3267
|
+
monorepo until cutover.
|
|
3268
|
+
|
|
3173
3269
|
## Resources
|
|
3174
3270
|
|
|
3175
3271
|
### Bundling
|
|
@@ -3187,12 +3283,6 @@ To run your own ar.io gateway, you can refer to the following resources:
|
|
|
3187
3283
|
|
|
3188
3284
|
Running your own gateway allows you to participate in the ar.io network, serve Arweave data, and potentially earn rewards. Make sure to follow the official documentation for the most up-to-date and accurate information on gateway operation.
|
|
3189
3285
|
|
|
3190
|
-
### AO
|
|
3191
|
-
|
|
3192
|
-
This library integrates with [AO], a decentralized compute platform built on Arweave. We utilize [AO Connect] to interact with AO processes and messages. This integration allows for seamless communication with the AO network, enabling developers to leverage decentralized computation and storage capabilities in their applications.
|
|
3193
|
-
|
|
3194
|
-
For more information on how to use AO and AO Connect within this library, please refer to our documentation and examples.
|
|
3195
|
-
|
|
3196
3286
|
## Developers
|
|
3197
3287
|
|
|
3198
3288
|
### Requirements
|
|
@@ -3213,7 +3303,6 @@ For more information on how to use AO and AO Connect within this library, please
|
|
|
3213
3303
|
- `yarn test:e2e` - runs e2e tests
|
|
3214
3304
|
- `yarn test:unit` - runs unit tests
|
|
3215
3305
|
- `yarn example:web` - opens up the example web page
|
|
3216
|
-
- `yarn example:cjs` - runs example CJS node script
|
|
3217
3306
|
- `yarn example:esm` - runs example ESM node script
|
|
3218
3307
|
- `yarn example:vite` - runs example Vite web page
|
|
3219
3308
|
|
|
@@ -3236,21 +3325,14 @@ For more information on how to contribute, please see [CONTRIBUTING.md].
|
|
|
3236
3325
|
<!-- ADD ALL LINK REFERENCES BELOW -->
|
|
3237
3326
|
|
|
3238
3327
|
[ar.io]: https://ar.io
|
|
3239
|
-
[permaweb/aoconnect]: https://github.com/permaweb/aoconnect
|
|
3240
|
-
[package.json]: ./package.json
|
|
3241
3328
|
[examples]: ./examples
|
|
3242
3329
|
[examples/webpack]: ./examples/webpack
|
|
3243
3330
|
[examples/vite]: ./examples/vite
|
|
3244
3331
|
[CONTRIBUTING.md]: ./CONTRIBUTING.md
|
|
3245
|
-
[AO Connect]: https://github.com/permaweb/ao/tree/main/connect
|
|
3246
|
-
[ARIO Testnet Process]: https://www.ao.link/#/entity/agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA
|
|
3247
|
-
[ARIO Network Spec]: https://github.com/ar-io/ar-io-network-process?tab=readme-ov-file#contract-spec
|
|
3248
|
-
[Winston]: https://www.npmjs.com/package/winston
|
|
3249
|
-
[AO]: https://github.com/permaweb/ao
|
|
3250
3332
|
[ar-io-node repository]: https://github.com/ar-io/ar-io-node
|
|
3251
3333
|
[ar.io Gateway Documentation]: https://docs.ar.io/gateways/ar-io-node/overview/
|
|
3252
3334
|
[ANS-104]: https://github.com/ArweaveTeam/arweave-standards/blob/master/ans/ANS-104.md
|
|
3253
|
-
[
|
|
3335
|
+
[opossum]: https://nodeshift.dev/opossum/
|
|
3254
3336
|
|
|
3255
3337
|
```
|
|
3256
3338
|
|