Skip to content

Commit 3a8aa9d

Browse files
committed
rebase
1 parent 755141a commit 3a8aa9d

310 files changed

Lines changed: 19231 additions & 13410 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/provable-sdk-tutorial-docs/SKILL.md

Lines changed: 121 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,79 @@
11
---
22
name: provable-sdk-tutorial-docs
3-
description: Use when writing tutorial documentation or create-leo-app examples for the Provable SDK (@provablehq/sdk). Covers how to structure runnable templates, write tutorial-style docs, and handle Node.js vs web runtime differences.
3+
description:
4+
Use when writing tutorial documentation or create-leo-app examples for the
5+
Provable SDK (@provablehq/sdk). Covers how to structure runnable templates,
6+
write tutorial-style docs, and handle Node.js vs web runtime differences.
47
---
58

69
# Provable SDK Tutorial Docs
710

811
## Overview
912

1013
This skill guides writing two interconnected artifacts for each SDK feature set:
14+
1115
1. A runnable **create-leo-app template** demonstrating the features
1216
2. **Tutorial documentation** that walks readers through the template
1317

14-
The template and tutorial are the same content expressed two ways — step numbers, section names, and code structure must correspond exactly.
18+
The template and tutorial are the same content expressed two ways — step
19+
numbers, section names, and code structure must correspond exactly.
1520

1621
---
1722

1823
## Step 0: Gather Inputs Before Writing Anything
1924

2025
Require the developer to specify:
2126

22-
| Input | Description |
23-
|-------|-------------|
24-
| **Feature bucket** | Explicit list of SDK features to demonstrate (e.g. "key caching, offline execution, deployment") |
25-
| **Target runtimes** | `node`, `web`, or `both` |
26-
| **Highlight areas** | What concepts readers should leave understanding — not just what the code does, but WHY |
27-
| **Complexity level** | beginner / intermediate / advanced — determines how much Aleo/ZK background to assume |
27+
| Input | Description |
28+
| -------------------- | ------------------------------------------------------------------------------------------------ |
29+
| **Feature bucket** | Explicit list of SDK features to demonstrate (e.g. "key caching, offline execution, deployment") |
30+
| **Target runtimes** | `node`, `web`, or `both` |
31+
| **Highlight areas** | What concepts readers should leave understanding — not just what the code does, but WHY |
32+
| **Complexity level** | beginner / intermediate / advanced — determines how much Aleo/ZK background to assume |
2833

2934
---
3035

3136
## SDK Runtime Context
3237

33-
Tutorials must open with context about why someone would use the SDK in this environment. Use the framing below as a guide.
38+
Tutorials must open with context about why someone would use the SDK in this
39+
environment. Use the framing below as a guide.
3440

3541
### Node.js
3642

3743
The SDK runs natively in Node — no WASM worker setup needed. Common use cases:
3844

39-
- **Backend servers** that execute web3 functions on behalf of users (e.g. building and submitting transactions server-side)
40-
- **Hardware wallets** that execute transactions in an offline setting on behalf of users
41-
- **Command-line tools** and scripts for account management, transaction creation, or record or chain data inspection, or specialized functions such as MPC computations run by web3 service providers
42-
- **Local testing and prototyping** local testing of dapps or web3 service prototypes
45+
- **Backend servers** that execute web3 functions on behalf of users (e.g.
46+
building and submitting transactions server-side)
47+
- **Hardware wallets** that execute transactions in an offline setting on behalf
48+
of users
49+
- **Command-line tools** and scripts for account management, transaction
50+
creation, or record or chain data inspection, or specialized functions such as
51+
MPC computations run by web3 service providers
52+
- **Local testing and prototyping** local testing of dapps or web3 service
53+
prototypes
4354

4455
### Web (Browser)
4556

46-
In browser contexts, the SDK is most commonly used to **supplement features that wallet adapters don't yet provide**. The [aleo-wallet-adapter](https://github.com/ProvableHQ/aleo-dev-toolkit/tree/master/packages/aleo-wallet-adaptor) handles account management and basic transaction signing — developers reach for the SDK directly when they need:
57+
In browser contexts, the SDK is most commonly used to **supplement features that
58+
wallet adapters don't yet provide**. The
59+
[aleo-wallet-adapter](https://github.com/ProvableHQ/aleo-dev-toolkit/tree/master/packages/aleo-wallet-adaptor)
60+
handles account management and basic transaction signing — developers reach for
61+
the SDK directly when they need:
4762

48-
- Cryptographic hashing (BHP, Pedersen, Poseidon) and mathematics (cryptographic math using the Aleo finite field and groups)
49-
- Program and program data introspection (parsing program source, inspecting program functions, records and mappings)
50-
- Arbitrary encryption, decryption and signature operations not exposed by the wallet.
63+
- Cryptographic hashing (BHP, Pedersen, Poseidon) and mathematics (cryptographic
64+
math using the Aleo finite field and groups)
65+
- Program and program data introspection (parsing program source, inspecting
66+
program functions, records and mappings)
67+
- Arbitrary encryption, decryption and signature operations not exposed by the
68+
wallet.
5169

52-
**Web tutorials must recommend using `aleo-wallet-adapter` alongside the SDK** for account/signing concerns, transaction execution and should show how the two integrate where relevant. Do not suggest the SDK replaces the wallet adapter on the web.
70+
**Web tutorials must recommend using `aleo-wallet-adapter` alongside the SDK**
71+
for account/signing concerns, transaction execution and should show how the two
72+
integrate where relevant. Do not suggest the SDK replaces the wallet adapter on
73+
the web.
5374

54-
WASM runs in a Web Worker in browsers, this is optional but highly recommend. Every web template should at least suggestion the worker pattern.
75+
WASM runs in a Web Worker in browsers, this is optional but highly recommend.
76+
Every web template should at least suggestion the worker pattern.
5577

5678
---
5779

@@ -66,33 +88,42 @@ package.json # yarn start runs src/index.ts
6688
.env.example # Any required secrets or endpoints
6789
```
6890

69-
- Use top-level `await`, initialize thread pool at the top: `await initThreadPool();`
91+
- Use top-level `await`, initialize thread pool at the top:
92+
`await initThreadPool();`
7093
- Organize into named async functions, one per feature.
7194
- Use section headers matching tutorial step numbers:
7295

7396
- ```ts
7497
// --- STEP 1: Initialize key provider and cache keys. --- //
7598
```
76-
- `yarn start` must run successfully without modification (offline features) or with only `.env` filled in (network features)
99+
- `yarn start` must run successfully without modification (offline features) or
100+
with only `.env` filled in (network features)
77101

78102
### Web templates (`template-react-*-ts`)
79103

80104
The wallet adapter has this API here:
81-
* https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/core/src/adapter.ts
82-
* https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/core/src/account.ts
105+
106+
- https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/core/src/adapter.ts
107+
- https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/core/src/account.ts
83108

84109
and for web examples, this should be used to do the following.
110+
85111
1. Executing transactions (via the `executeTransaction` method)
86112
2. Creating new accounts (via the `createAccount` method)
87113
3. Polling transaction status (via the `transactionStatus` method)
88-
4. Decrypting ciphertexts from transition inputs and outputs (via the `decrypt` method). Note this does not do arbitrary encryption and decryption schemes, only decryption of transition inputs and outputs.
114+
4. Decrypting ciphertexts from transition inputs and outputs (via the `decrypt`
115+
method). Note this does not do arbitrary encryption and decryption schemes,
116+
only decryption of transition inputs and outputs.
89117
5. Record scans via the (via the `requestRecords` method)
90118
6. Executing deployments (via the `executeDeployment` method)
91119

92-
React environments should look here for context on how to invoke wallets via react: https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/react/src/WalletProvider.tsx
120+
React environments should look here for context on how to invoke wallets via
121+
react:
122+
https://github.com/ProvableHQ/aleo-dev-toolkit/blob/master/packages/aleo-wallet-adaptor/react/src/WalletProvider.tsx
93123

94-
For most create leo app examples (for now) there should be the ability to execute any of the above functions optionally
95-
via the wallet AND via native SDK methods (where the wallet is preferred).
124+
For most create leo app examples (for now) there should be the ability to
125+
execute any of the above functions optionally via the wallet AND via native SDK
126+
methods (where the wallet is preferred).
96127

97128
```
98129
src/
@@ -103,22 +134,29 @@ vite.config.ts
103134
.env.example
104135
```
105136

106-
- All `@provablehq/sdk` imports and calls live in `AleoWorker.ts` — never in `App.tsx`
107-
- Expose worker methods via Comlink; `App.tsx` or any other file calls them like async functions
137+
- All `@provablehq/sdk` imports and calls live in `AleoWorker.ts` — never in
138+
`App.tsx`
139+
- Expose worker methods via Comlink; `App.tsx` or any other file calls them like
140+
async functions
108141
- `initThreadPool()` runs inside the worker, not in the main thread
109-
- Show loading/progress state in the UI for any proving operation (these take time)
110-
- Use `aleo-wallet-adapter` for account connection; the SDK worker handles the supplemental operations
142+
- Show loading/progress state in the UI for any proving operation (these take
143+
time)
144+
- Use `aleo-wallet-adapter` for account connection; the SDK worker handles the
145+
supplemental operations
111146

112147
### Both runtimes
113148

114-
- Imports are always network-specific: `@provablehq/sdk/testnet.js` or `/mainnet.js` — never the bare package
115-
- Each feature in the bucket gets its own clearly named function — no interleaved logic
116-
- Error handling must be explicit; ZK errors are opaque, surface them with context:
117-
```ts
118-
} catch (e) {
119-
throw new KeySynthesisError(`Failed to synthesize keys: ${e}`);
120-
}
121-
```
149+
- Imports are always network-specific: `@provablehq/sdk/testnet.js` or
150+
`/mainnet.js` — never the bare package
151+
- Each feature in the bucket gets its own clearly named function — no
152+
interleaved logic
153+
- Error handling must be explicit; ZK errors are opaque, surface them with
154+
context:
155+
```ts
156+
} catch (e) {
157+
throw new KeySynthesisError(`Failed to synthesize keys: ${e}`);
158+
}
159+
```
122160

123161
---
124162

@@ -127,9 +165,12 @@ vite.config.ts
127165
For each feature in the bucket:
128166

129167
1. Show the **minimal working example** first, then advanced usage
130-
2. Cover **both node and web** unless the feature is inherently platform-specific
131-
3. State the **expected output** — what does `yarn start` print? What does the UI show?
132-
4. Explain **why** non-obvious SDK calls exist (see Code-Doc Correspondence below)
168+
2. Cover **both node and web** unless the feature is inherently
169+
platform-specific
170+
3. State the **expected output**what does `yarn start` print? What does the
171+
UI show?
172+
4. Explain **why** non-obvious SDK calls exist (see Code-Doc Correspondence
173+
below)
133174

134175
---
135176

@@ -138,54 +179,78 @@ For each feature in the bucket:
138179
Every tutorial follows this shape:
139180

140181
### 1. Overview (1 paragraph)
141-
What the reader will build. Which features from the bucket are covered. Link to the template.
182+
183+
What the reader will build. Which features from the bucket are covered. Link to
184+
the template.
142185

143186
### 2. Runtime context (12 sentences)
144-
Why a developer would use the SDK in this runtime for this use case. Reference the framing from the Runtime Context section above. For web tutorials, mention `aleo-wallet-adapter` and its relationship to the SDK.
187+
188+
Why a developer would use the SDK in this runtime for this use case. Reference
189+
the framing from the Runtime Context section above. For web tutorials, mention
190+
`aleo-wallet-adapter` and its relationship to the SDK.
145191

146192
### 3. Prerequisites
193+
147194
- Node version
148195
- Aleo credits (if network calls are involved)
149196
- Required `.env` values and where to get them
150197
- For web: note that `aleo-wallet-adapter` is needed for account connection
151198

152199
### 4. Concepts
153-
Plain-English explanation of each feature before showing code. This is where Highlight Areas from the developer's inputs go. Assume only the complexity level specified — don't assume ZK/cryptography knowledge for beginner tutorials.
200+
201+
Plain-English explanation of each feature before showing code. This is where
202+
Highlight Areas from the developer's inputs go. Assume only the complexity level
203+
specifieddon't assume ZK/cryptography knowledge for beginner tutorials.
154204

155205
### 5. Step-by-step walkthrough
156-
One section per step, numbered to match the template's section headers. For each step:
206+
207+
One section per step, numbered to match the template's section headers. For each
208+
step:
209+
157210
- What the code does
158211
- **Why** it does it (not just what)
159212
- The relevant code snippet
160213

161214
### 6. Running it
215+
162216
Exact commands. Expected output copied from an actual run.
163217

164218
### 7. Next steps
165-
Links to related templates, the wallet adapter docs (web only), and relevant SDK API docs.
219+
220+
Links to related templates, the wallet adapter docs (web only), and relevant SDK
221+
API docs.
166222

167223
### Tone
168-
Third person replacing "you" with appropriate 3rd party nouns, tutorial style: "callers should notice...", "this tells the SDK to...", "here the keys are cached because...". Not API reference style. Not first person.
224+
225+
Third person replacing "you" with appropriate 3rd party nouns, tutorial style:
226+
"callers should notice...", "this tells the SDK to...", "here the keys are
227+
cached because...". Not API reference style. Not first person.
169228

170229
---
171230

172231
## Code-Doc Correspondence Rules
173232

174-
- Step numbers in template comments **must match** step numbers in the tutorial — they are the same document expressed two ways
175-
- Every non-obvious SDK call in the template requires a "why" explanation in the tutorial. Examples of calls that always need a "why":
176-
- `initThreadPool()` — why it exists, what happens without it
177-
- `keyProvider.cacheKeys(...)` — why caching matters (proving key synthesis is slow)
178-
- `OfflineQuery` — what it replaces and when to use it
179-
- `buildDeploymentTransaction` vs `deploy` — the distinction between building and submitting
180-
- **No unexplained magic**: if a call is in the template, it is explained in the tutorial
233+
- Step numbers in template comments **must match** step numbers in the tutorial
234+
they are the same document expressed two ways
235+
- Every non-obvious SDK call in the template requires a "why" explanation in the
236+
tutorial. Examples of calls that always need a "why":
237+
- `initThreadPool()`why it exists, what happens without it
238+
- `keyProvider.cacheKeys(...)`why caching matters (proving key synthesis
239+
is slow)
240+
- `OfflineQuery`what it replaces and when to use it
241+
- `buildDeploymentTransaction` vs `deploy`the distinction between
242+
building and submitting
243+
- **No unexplained magic**: if a call is in the template, it is explained in the
244+
tutorial
181245

182246
---
183247

184248
## Quality Checklist
185249

186250
Before the tutorial is done:
187251

188-
- [ ] Template runs with `yarn start` without modification (or only `.env` needed)
252+
- [ ] Template runs with `yarn start` without modification (or only `.env`
253+
needed)
189254
- [ ] Every feature in the bucket is implemented in each target runtime
190255
- [ ] Step numbers align between template comments and tutorial sections
191256
- [ ] Expected output is shown in the tutorial (copied from a real run)

0 commit comments

Comments
 (0)