@5ive-tech/sdk 1.1.2 → 1.1.4
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 +14 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 5IVE SDK
|
|
2
2
|
|
|
3
3
|
Client-agnostic TypeScript SDK for interacting with 5ive DSL programs on Solana.
|
|
4
4
|
|
|
5
|
-
This README is for external developers using:
|
|
6
|
-
- `five-cli`
|
|
7
|
-
- `five-sdk`
|
|
8
|
-
- [5ive.tech](https://5ive.tech)
|
|
9
|
-
|
|
10
5
|
## Install
|
|
11
6
|
|
|
12
7
|
```bash
|
|
13
8
|
npm install @5ive-tech/sdk @solana/web3.js
|
|
14
9
|
```
|
|
15
10
|
|
|
16
|
-
Note: Some older examples may use `@5ive-tech/sdk`. Use the package name your registry currently publishes for your release channel.
|
|
17
|
-
|
|
18
11
|
## Quick Start
|
|
19
12
|
|
|
20
|
-
### 1
|
|
13
|
+
### 1) Compile to `.five`
|
|
21
14
|
|
|
22
15
|
```bash
|
|
23
|
-
|
|
16
|
+
5ive compile src/main.v -o build/my-program.five
|
|
24
17
|
```
|
|
25
18
|
|
|
26
|
-
### 1b
|
|
19
|
+
### 1b) Compile directly with SDK (optional)
|
|
27
20
|
|
|
28
21
|
```ts
|
|
29
22
|
import { FiveSDK } from '@5ive-tech/sdk';
|
|
@@ -63,7 +56,7 @@ const multi = await FiveSDK.compileModules(
|
|
|
63
56
|
);
|
|
64
57
|
```
|
|
65
58
|
|
|
66
|
-
### 2
|
|
59
|
+
### 2) Load ABI from `.five`
|
|
67
60
|
|
|
68
61
|
```ts
|
|
69
62
|
import fs from 'fs';
|
|
@@ -73,7 +66,7 @@ const fiveFileText = fs.readFileSync('build/my-program.five', 'utf-8');
|
|
|
73
66
|
const { abi } = await FiveSDK.loadFiveFile(fiveFileText);
|
|
74
67
|
```
|
|
75
68
|
|
|
76
|
-
### 3
|
|
69
|
+
### 3) Configure program ID resolution
|
|
77
70
|
|
|
78
71
|
On-chain instruction generation requires a resolvable Five VM program ID.
|
|
79
72
|
Resolution precedence:
|
|
@@ -88,7 +81,7 @@ import { FiveSDK } from '@5ive-tech/sdk';
|
|
|
88
81
|
FiveSDK.setDefaultProgramId('YourFiveVMProgramIdBase58');
|
|
89
82
|
```
|
|
90
83
|
|
|
91
|
-
### 4
|
|
84
|
+
### 4) Create `FiveProgram`
|
|
92
85
|
|
|
93
86
|
```ts
|
|
94
87
|
import { FiveProgram } from '@5ive-tech/sdk';
|
|
@@ -180,11 +173,11 @@ Recommended send pattern:
|
|
|
180
173
|
3. assert `meta.err` is null
|
|
181
174
|
4. record CU from `meta.computeUnitsConsumed`
|
|
182
175
|
|
|
183
|
-
## Advanced
|
|
176
|
+
## Advanced APIs (Optional)
|
|
184
177
|
|
|
185
178
|
Most builders should use `FiveProgram` first. Use these lower-level APIs when you need finer control.
|
|
186
179
|
|
|
187
|
-
###
|
|
180
|
+
### Local VM testing without RPC
|
|
188
181
|
|
|
189
182
|
```ts
|
|
190
183
|
const run = await FiveSDK.compileAndExecuteLocally(
|
|
@@ -195,7 +188,7 @@ const run = await FiveSDK.compileAndExecuteLocally(
|
|
|
195
188
|
);
|
|
196
189
|
```
|
|
197
190
|
|
|
198
|
-
###
|
|
191
|
+
### Instruction-only generation
|
|
199
192
|
|
|
200
193
|
```ts
|
|
201
194
|
const deploy = await FiveSDK.generateDeployInstruction(bytecode, deployerPubkeyBase58, {
|
|
@@ -212,7 +205,7 @@ const exec = await FiveSDK.generateExecuteInstruction(
|
|
|
212
205
|
);
|
|
213
206
|
```
|
|
214
207
|
|
|
215
|
-
###
|
|
208
|
+
### On-chain convenience helpers
|
|
216
209
|
|
|
217
210
|
```ts
|
|
218
211
|
const deployResult = await FiveSDK.deployToSolana(bytecode, connection, payerKeypair, {
|
|
@@ -230,7 +223,7 @@ const execResult = await FiveSDK.executeOnSolana(
|
|
|
230
223
|
);
|
|
231
224
|
```
|
|
232
225
|
|
|
233
|
-
###
|
|
226
|
+
### Metadata and decoding helpers
|
|
234
227
|
|
|
235
228
|
```ts
|
|
236
229
|
const meta = await FiveSDK.getScriptMetadataWithConnection(scriptAccountBase58, connection);
|
|
@@ -240,14 +233,14 @@ const account = await FiveSDK.fetchAccountAndDeserialize(scriptAccountBase58, co
|
|
|
240
233
|
});
|
|
241
234
|
```
|
|
242
235
|
|
|
243
|
-
###
|
|
236
|
+
### Namespace helpers (5NS)
|
|
244
237
|
|
|
245
238
|
```ts
|
|
246
239
|
const ns = FiveSDK.canonicalizeNamespace('@acme/payments');
|
|
247
240
|
const derived = await FiveSDK.deriveNamespaceAccounts(ns.canonical, 'YourFiveVMProgramIdBase58');
|
|
248
241
|
```
|
|
249
242
|
|
|
250
|
-
###
|
|
243
|
+
### Test utilities
|
|
251
244
|
|
|
252
245
|
```ts
|
|
253
246
|
import { FiveTestRunner } from '@5ive-tech/sdk';
|
|
@@ -255,14 +248,6 @@ import { FiveTestRunner } from '@5ive-tech/sdk';
|
|
|
255
248
|
const runner = new FiveTestRunner({ verbose: true, maxComputeUnits: 1_000_000 });
|
|
256
249
|
```
|
|
257
250
|
|
|
258
|
-
## Frontend Usage (`5ive.tech`)
|
|
259
|
-
|
|
260
|
-
For frontend integration patterns and UI workflows, use [5ive.tech](https://5ive.tech).
|
|
261
|
-
Typical flow:
|
|
262
|
-
1. compile/deploy with `five-cli`
|
|
263
|
-
2. use `five-sdk` in your app/backend to generate instructions
|
|
264
|
-
3. submit signed transactions from wallet-enabled frontend
|
|
265
|
-
|
|
266
251
|
## Troubleshooting
|
|
267
252
|
|
|
268
253
|
### `No program ID resolved for Five VM`
|
|
@@ -273,7 +258,3 @@ Use exact ABI function names (including namespace prefixes).
|
|
|
273
258
|
|
|
274
259
|
### `Missing required account` / `Missing required argument`
|
|
275
260
|
Provide all required fields in `.accounts(...)` and `.args(...)`.
|
|
276
|
-
|
|
277
|
-
## Next Doc
|
|
278
|
-
|
|
279
|
-
For API-level usage details, see `FIVEPROGRAM_USAGE_GUIDE.md`.
|