@arkiv-network/sdk 0.4.2 → 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 +29 -16
- package/dist/utils/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
|
}
|
|
@@ -90,7 +90,7 @@ 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
96
|
import { createPublicClient, http } from "@arkiv-network/sdk"
|
|
@@ -135,12 +135,12 @@ You have several options to run your TypeScript sample:
|
|
|
135
135
|
|
|
136
136
|
- **With Node.js (using experimental TypeScript support):**
|
|
137
137
|
```bash
|
|
138
|
-
node --experimental-strip-types
|
|
138
|
+
node --experimental-strip-types read_example.ts
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
- **With Bun (native TypeScript support):**
|
|
142
142
|
```bash
|
|
143
|
-
bun
|
|
143
|
+
bun read_example.ts
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
- **Classic Node.js (using transpilation to JavaScript):**
|
|
@@ -158,26 +158,22 @@ You have several options to run your TypeScript sample:
|
|
|
158
158
|
```bash
|
|
159
159
|
npx tsc --outDir dist
|
|
160
160
|
```
|
|
161
|
-
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.
|
|
162
162
|
4. Run the transpiled script:
|
|
163
163
|
```bash
|
|
164
|
-
node dist/
|
|
164
|
+
node dist/read_example.js
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
### Wallet Client Example (Create Entity)
|
|
168
168
|
|
|
169
|
-
Now
|
|
170
|
-
|
|
169
|
+
Now let's add storage (write) functionality.
|
|
170
|
+
Create a file named `write_example.ts` with the following content:
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
import { createWalletClient } from '@arkiv-network/sdk';
|
|
174
174
|
import { ExpirationTime, jsonToPayload } from '@arkiv-network/sdk/utils';
|
|
175
175
|
import { privateKeyToAccount } from '@arkiv-network/sdk/accounts';
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Then, add the following example below your query code to create an entity:
|
|
179
176
|
|
|
180
|
-
```typescript
|
|
181
177
|
// Create a wallet client with an account
|
|
182
178
|
const client = createWalletClient({
|
|
183
179
|
chain: mendoza,
|
|
@@ -209,6 +205,23 @@ const newEntity = await publicClient.getEntity(entityKey);
|
|
|
209
205
|
console.log('Entity:', newEntity);
|
|
210
206
|
```
|
|
211
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
|
+
|
|
212
225
|
**Note:**
|
|
213
226
|
You must provide your own private key with a minimum balance on the Arkiv L3 network.
|
|
214
227
|
You can generate a private key using any tool, for example: https://vanity-eth.tk/
|
|
@@ -221,7 +234,7 @@ For quick testing, you may use this example key:
|
|
|
221
234
|
```
|
|
222
235
|
However, funds may not always be available for this key.
|
|
223
236
|
|
|
224
|
-
|
|
237
|
+
Sample code can also be found in the [`sample`](./sample) directory of this repository.
|
|
225
238
|
|
|
226
239
|
## Package Distribution
|
|
227
240
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts","../../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;ECTP,SAAA,EAAA,CAAA,KAAa,EAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts","../../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;ECTP,SAAA,EAAA,CAAA,KAAa,EAAA,MAAA,EAAgB,GAAA,MAAA;EAI7B,UAAA,EAAA,CAAA,MAAe,EAAA,MAAA,EAAgB,GAAA,MAAA;mBDK5B;;;;iBCTH,aAAA,gBAA6B;iBAI7B,eAAA,gBAA+B"}
|