@arkiv-network/sdk 0.4.1 → 0.4.3
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 +34 -17
- package/dist/chains/index.d.ts +33 -33
- package/dist/chains/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,9 +32,9 @@ mkdir arkiv-sample
|
|
|
32
32
|
cd arkiv-sample
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Create an empty `
|
|
35
|
+
Create an empty `read_example.ts` file:
|
|
36
36
|
```bash
|
|
37
|
-
touch
|
|
37
|
+
touch read_example.ts
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
Initialize a new JavaScript/TypeScript project:
|
|
@@ -59,7 +59,7 @@ After this step, a `package.json` file will be created with content similar to:
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Modify the `"main"` entry to `"
|
|
62
|
+
Modify the `"main"` entry to `"read_example.ts"` and set `"type"` to `"module"` so your `package.json` looks like this:
|
|
63
63
|
|
|
64
64
|
```json
|
|
65
65
|
{
|
|
@@ -69,7 +69,7 @@ Modify the `"main"` entry to `"index.ts"` and set `"type"` to `"module"` so your
|
|
|
69
69
|
"license": "ISC",
|
|
70
70
|
"author": "",
|
|
71
71
|
"type": "module",
|
|
72
|
-
"main": "
|
|
72
|
+
"main": "read_example.ts",
|
|
73
73
|
"scripts": {
|
|
74
74
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
75
75
|
}
|
|
@@ -83,16 +83,20 @@ npm install @arkiv-network/sdk
|
|
|
83
83
|
This command will update your `package.json` with a section like:
|
|
84
84
|
```json
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@arkiv-network/sdk": "^0.4.
|
|
86
|
+
"@arkiv-network/sdk": "^0.4.2"
|
|
87
87
|
}
|
|
88
88
|
```
|
|
89
89
|
It will also create a `node_modules` directory with all dependencies installed.
|
|
90
90
|
|
|
91
91
|
### Public Client Example (Query Data)
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
You can now use Arkiv's public client to query data. Paste the following in `read_example.ts`:
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
|
+
import { createPublicClient, http } from "@arkiv-network/sdk"
|
|
97
|
+
import { mendoza } from "@arkiv-network/sdk/chains"
|
|
98
|
+
import { eq } from "@arkiv-network/sdk/query"
|
|
99
|
+
|
|
96
100
|
const publicClient = createPublicClient({
|
|
97
101
|
chain: mendoza, // "mendoza" is Arkiv's testnet, used during hackathons at DevConnect 2025 in Buenos Aires
|
|
98
102
|
transport: http(),
|
|
@@ -131,12 +135,12 @@ You have several options to run your TypeScript sample:
|
|
|
131
135
|
|
|
132
136
|
- **With Node.js (using experimental TypeScript support):**
|
|
133
137
|
```bash
|
|
134
|
-
node --experimental-strip-types
|
|
138
|
+
node --experimental-strip-types read_example.ts
|
|
135
139
|
```
|
|
136
140
|
|
|
137
141
|
- **With Bun (native TypeScript support):**
|
|
138
142
|
```bash
|
|
139
|
-
bun
|
|
143
|
+
bun read_example.ts
|
|
140
144
|
```
|
|
141
145
|
|
|
142
146
|
- **Classic Node.js (using transpilation to JavaScript):**
|
|
@@ -154,26 +158,22 @@ You have several options to run your TypeScript sample:
|
|
|
154
158
|
```bash
|
|
155
159
|
npx tsc --outDir dist
|
|
156
160
|
```
|
|
157
|
-
This creates a `dist` directory containing `
|
|
161
|
+
This creates a `dist` directory containing `read_example.js` (the transpiled code), along with corresponding type declaration and source map files.
|
|
158
162
|
4. Run the transpiled script:
|
|
159
163
|
```bash
|
|
160
|
-
node dist/
|
|
164
|
+
node dist/read_example.js
|
|
161
165
|
```
|
|
162
166
|
|
|
163
167
|
### Wallet Client Example (Create Entity)
|
|
164
168
|
|
|
165
|
-
Now
|
|
166
|
-
|
|
169
|
+
Now let's add storage (write) functionality.
|
|
170
|
+
Create a file named `write_example.ts` with the following content:
|
|
167
171
|
|
|
168
172
|
```typescript
|
|
169
173
|
import { createWalletClient } from '@arkiv-network/sdk';
|
|
170
174
|
import { ExpirationTime, jsonToPayload } from '@arkiv-network/sdk/utils';
|
|
171
175
|
import { privateKeyToAccount } from '@arkiv-network/sdk/accounts';
|
|
172
|
-
```
|
|
173
176
|
|
|
174
|
-
Then, add the following example below your query code to create an entity:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
177
|
// Create a wallet client with an account
|
|
178
178
|
const client = createWalletClient({
|
|
179
179
|
chain: mendoza,
|
|
@@ -205,6 +205,23 @@ const newEntity = await publicClient.getEntity(entityKey);
|
|
|
205
205
|
console.log('Entity:', newEntity);
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
+
Now you can run it in the same way as in the previous example:
|
|
209
|
+
- **With Node.js (using experimental TypeScript support):**
|
|
210
|
+
```bash
|
|
211
|
+
node --experimental-strip-types write_example.ts
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- **With Bun (native TypeScript support):**
|
|
215
|
+
```bash
|
|
216
|
+
bun write_example.ts
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
- **Classic Node.js (using transpilation to JavaScript):**
|
|
220
|
+
```bash
|
|
221
|
+
npx tsc --outDir dist
|
|
222
|
+
node dist/write_exmaple.js
|
|
223
|
+
```
|
|
224
|
+
|
|
208
225
|
**Note:**
|
|
209
226
|
You must provide your own private key with a minimum balance on the Arkiv L3 network.
|
|
210
227
|
You can generate a private key using any tool, for example: https://vanity-eth.tk/
|
|
@@ -217,7 +234,7 @@ For quick testing, you may use this example key:
|
|
|
217
234
|
```
|
|
218
235
|
However, funds may not always be available for this key.
|
|
219
236
|
|
|
220
|
-
|
|
237
|
+
Sample code can also be found in the [`sample`](./sample) directory of this repository.
|
|
221
238
|
|
|
222
239
|
## Package Distribution
|
|
223
240
|
|
package/dist/chains/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem8 from "viem";
|
|
2
2
|
|
|
3
3
|
//#region src/chains/kaolin.d.ts
|
|
4
4
|
declare const kaolin: {
|
|
@@ -11,13 +11,13 @@ declare const kaolin: {
|
|
|
11
11
|
};
|
|
12
12
|
blockTime?: number | undefined | undefined;
|
|
13
13
|
contracts?: {
|
|
14
|
-
[x: string]:
|
|
15
|
-
[sourceId: number]:
|
|
14
|
+
[x: string]: viem8.ChainContract | {
|
|
15
|
+
[sourceId: number]: viem8.ChainContract | undefined;
|
|
16
16
|
} | undefined;
|
|
17
|
-
ensRegistry?:
|
|
18
|
-
ensUniversalResolver?:
|
|
19
|
-
multicall3?:
|
|
20
|
-
erc6492Verifier?:
|
|
17
|
+
ensRegistry?: viem8.ChainContract | undefined;
|
|
18
|
+
ensUniversalResolver?: viem8.ChainContract | undefined;
|
|
19
|
+
multicall3?: viem8.ChainContract | undefined;
|
|
20
|
+
erc6492Verifier?: viem8.ChainContract | undefined;
|
|
21
21
|
} | undefined;
|
|
22
22
|
ensTlds?: readonly string[] | undefined;
|
|
23
23
|
id: 60138453025;
|
|
@@ -37,9 +37,9 @@ declare const kaolin: {
|
|
|
37
37
|
sourceId?: number | undefined | undefined;
|
|
38
38
|
testnet: true;
|
|
39
39
|
custom?: Record<string, unknown> | undefined;
|
|
40
|
-
fees?:
|
|
40
|
+
fees?: viem8.ChainFees<undefined> | undefined;
|
|
41
41
|
formatters?: undefined;
|
|
42
|
-
serializers?:
|
|
42
|
+
serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
|
|
43
43
|
readonly network: "kaolin";
|
|
44
44
|
};
|
|
45
45
|
//#endregion
|
|
@@ -59,13 +59,13 @@ declare const localhost: {
|
|
|
59
59
|
} | undefined | undefined;
|
|
60
60
|
blockTime?: number | undefined | undefined;
|
|
61
61
|
contracts?: {
|
|
62
|
-
[x: string]:
|
|
63
|
-
[sourceId: number]:
|
|
62
|
+
[x: string]: viem8.ChainContract | {
|
|
63
|
+
[sourceId: number]: viem8.ChainContract | undefined;
|
|
64
64
|
} | undefined;
|
|
65
|
-
ensRegistry?:
|
|
66
|
-
ensUniversalResolver?:
|
|
67
|
-
multicall3?:
|
|
68
|
-
erc6492Verifier?:
|
|
65
|
+
ensRegistry?: viem8.ChainContract | undefined;
|
|
66
|
+
ensUniversalResolver?: viem8.ChainContract | undefined;
|
|
67
|
+
multicall3?: viem8.ChainContract | undefined;
|
|
68
|
+
erc6492Verifier?: viem8.ChainContract | undefined;
|
|
69
69
|
} | undefined;
|
|
70
70
|
ensTlds?: readonly string[] | undefined;
|
|
71
71
|
id: 1337;
|
|
@@ -84,9 +84,9 @@ declare const localhost: {
|
|
|
84
84
|
sourceId?: number | undefined | undefined;
|
|
85
85
|
testnet?: boolean | undefined | undefined;
|
|
86
86
|
custom?: Record<string, unknown> | undefined;
|
|
87
|
-
fees?:
|
|
87
|
+
fees?: viem8.ChainFees<undefined> | undefined;
|
|
88
88
|
formatters?: undefined;
|
|
89
|
-
serializers?:
|
|
89
|
+
serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
|
|
90
90
|
};
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/chains/marketplace.d.ts
|
|
@@ -100,13 +100,13 @@ declare const marketplace: {
|
|
|
100
100
|
};
|
|
101
101
|
blockTime?: number | undefined | undefined;
|
|
102
102
|
contracts?: {
|
|
103
|
-
[x: string]:
|
|
104
|
-
[sourceId: number]:
|
|
103
|
+
[x: string]: viem8.ChainContract | {
|
|
104
|
+
[sourceId: number]: viem8.ChainContract | undefined;
|
|
105
105
|
} | undefined;
|
|
106
|
-
ensRegistry?:
|
|
107
|
-
ensUniversalResolver?:
|
|
108
|
-
multicall3?:
|
|
109
|
-
erc6492Verifier?:
|
|
106
|
+
ensRegistry?: viem8.ChainContract | undefined;
|
|
107
|
+
ensUniversalResolver?: viem8.ChainContract | undefined;
|
|
108
|
+
multicall3?: viem8.ChainContract | undefined;
|
|
109
|
+
erc6492Verifier?: viem8.ChainContract | undefined;
|
|
110
110
|
} | undefined;
|
|
111
111
|
ensTlds?: readonly string[] | undefined;
|
|
112
112
|
id: 60138453027;
|
|
@@ -126,9 +126,9 @@ declare const marketplace: {
|
|
|
126
126
|
sourceId?: number | undefined | undefined;
|
|
127
127
|
testnet: true;
|
|
128
128
|
custom?: Record<string, unknown> | undefined;
|
|
129
|
-
fees?:
|
|
129
|
+
fees?: viem8.ChainFees<undefined> | undefined;
|
|
130
130
|
formatters?: undefined;
|
|
131
|
-
serializers?:
|
|
131
|
+
serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
|
|
132
132
|
readonly network: "marketplace";
|
|
133
133
|
};
|
|
134
134
|
//#endregion
|
|
@@ -143,13 +143,13 @@ declare const mendoza: {
|
|
|
143
143
|
};
|
|
144
144
|
blockTime?: number | undefined | undefined;
|
|
145
145
|
contracts?: {
|
|
146
|
-
[x: string]:
|
|
147
|
-
[sourceId: number]:
|
|
146
|
+
[x: string]: viem8.ChainContract | {
|
|
147
|
+
[sourceId: number]: viem8.ChainContract | undefined;
|
|
148
148
|
} | undefined;
|
|
149
|
-
ensRegistry?:
|
|
150
|
-
ensUniversalResolver?:
|
|
151
|
-
multicall3?:
|
|
152
|
-
erc6492Verifier?:
|
|
149
|
+
ensRegistry?: viem8.ChainContract | undefined;
|
|
150
|
+
ensUniversalResolver?: viem8.ChainContract | undefined;
|
|
151
|
+
multicall3?: viem8.ChainContract | undefined;
|
|
152
|
+
erc6492Verifier?: viem8.ChainContract | undefined;
|
|
153
153
|
} | undefined;
|
|
154
154
|
ensTlds?: readonly string[] | undefined;
|
|
155
155
|
id: 60138453056;
|
|
@@ -169,9 +169,9 @@ declare const mendoza: {
|
|
|
169
169
|
sourceId?: number | undefined | undefined;
|
|
170
170
|
testnet: true;
|
|
171
171
|
custom?: Record<string, unknown> | undefined;
|
|
172
|
-
fees?:
|
|
172
|
+
fees?: viem8.ChainFees<undefined> | undefined;
|
|
173
173
|
formatters?: undefined;
|
|
174
|
-
serializers?:
|
|
174
|
+
serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
|
|
175
175
|
readonly network: "mendoza";
|
|
176
176
|
};
|
|
177
177
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts","../../src/chains/mendoza.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;MAAA,SAuBX,IAAA,EAAA,uBAAA;MAAA,SAAA,GAAA,EAAA,6CAAA;;;;;;iBAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts","../../src/chains/mendoza.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;MAAA,SAuBX,IAAA,EAAA,uBAAA;MAAA,SAAA,GAAA,EAAA,6CAAA;;;;;;iBAAA,KAAA,CAAA,aAAA;;;;;;;;ECvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cDvBW;;;MDAA,IAuBX,EAAA,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCZA,KAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,wBAAA,SAAA;IAAA,oBAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;ICXW,SAAA,OAuBX,EAAA;MAAA,SAAA,IAAA,EAAA,SAAA,CAAA,uBAAA,CAAA;;;;;;;;;;;;cAvBW;;;MFAA,SAuBX,IAAA,EAAA,4BAAA;MAAA,SAAA,GAAA,EAAA,kDAAA;;;;;;iBEAA,KAAA,CAAA,aAAA;;;;;;;;EDvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cCvBW;;;MHAA,SAuBX,IAAA,EAAA,wBAAA;MAAA,SAAA,GAAA,EAAA,8CAAA;;;;;;iBGAA,KAAA,CAAA,aAAA;;;;;;;;EFvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA"}
|