@veil-cash/sdk 0.6.2 → 0.6.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 +8 -6
- package/SDK.md +63 -5
- package/dist/cli/index.cjs +372 -283
- package/dist/index.cjs +141 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -64
- package/dist/index.d.ts +139 -64
- package/dist/index.js +118 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/skills/veil/SKILL.md +6 -4
- package/skills/veil/reference.md +5 -5
- package/src/abi.ts +8 -0
- package/src/balance.ts +48 -0
- package/src/cli/commands/deposit.ts +61 -15
- package/src/ffjavascript.d.ts +28 -0
- package/src/index.ts +2 -1
- package/src/keypair.ts +2 -4
- package/src/prover.ts +108 -36
- package/src/subaccount.ts +2 -0
- package/src/transaction.ts +8 -2
- package/src/transfer.ts +5 -1
- package/src/types.ts +21 -0
- package/src/utils.ts +12 -5
- package/src/utxo.ts +1 -0
- package/src/withdraw.ts +2 -0
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ veil subaccount recover --slot 0 --asset usdc --to 0xRecipientAddress --amount 2
|
|
|
93
93
|
|
|
94
94
|
# 9. Use JSON or unsigned modes when you need automation
|
|
95
95
|
veil status --json
|
|
96
|
-
veil deposit ETH 0.1 --unsigned
|
|
96
|
+
veil deposit ETH 0.1 --unsigned --address 0x...
|
|
97
97
|
veil subaccount status --slot 0 --json
|
|
98
98
|
```
|
|
99
99
|
|
|
@@ -142,13 +142,14 @@ SIGNER_ADDRESS=0x... veil register --unsigned
|
|
|
142
142
|
|
|
143
143
|
In `--unsigned` mode, `--address` is optional when `SIGNER_ADDRESS` is set. `veil register --force` checks on-chain state first and emits a `changeDepositKey` payload only if the address is already registered; otherwise it emits a normal `register` payload.
|
|
144
144
|
|
|
145
|
-
Deposit ETH or USDC into Veil. The amount you specify is the **net** amount that arrives in your Veil balance.
|
|
145
|
+
Deposit ETH or USDC into Veil. The amount you specify is the **net** amount that arrives in your Veil balance. A 0.3% protocol fee is normally added on top, but each address gets free daily deposits (fee waived). The CLI checks automatically:
|
|
146
146
|
|
|
147
147
|
```bash
|
|
148
|
-
veil deposit ETH 0.1 # 0.1 ETH lands in pool
|
|
149
|
-
veil deposit USDC 100 # 100 USDC lands in pool
|
|
148
|
+
veil deposit ETH 0.1 # 0.1 ETH lands in pool (free or ~0.1003 ETH sent)
|
|
149
|
+
veil deposit USDC 100 # 100 USDC lands in pool (free or ~100.30 USDC sent)
|
|
150
150
|
veil deposit ETH 0.1 --json
|
|
151
|
-
veil deposit ETH 0.1 --unsigned
|
|
151
|
+
veil deposit ETH 0.1 --unsigned --address 0x...
|
|
152
|
+
SIGNER_ADDRESS=0x... veil deposit ETH 0.1 --unsigned
|
|
152
153
|
```
|
|
153
154
|
|
|
154
155
|
### Balances
|
|
@@ -287,6 +288,7 @@ Commands print human-readable success output by default. Errors are standardized
|
|
|
287
288
|
The CLI is the main entrypoint for most users. If you are integrating Veil programmatically, use the dedicated SDK guide:
|
|
288
289
|
|
|
289
290
|
- [SDK Quick Start and API Reference](./SDK.md)
|
|
291
|
+
- [Browser proof generation](./SDK.md#browser-proof-generation)
|
|
290
292
|
- [AI agent and signer integration notes](./SDK.md#for-ai-agents)
|
|
291
293
|
|
|
292
294
|
## Deposit Flow
|
|
@@ -295,7 +297,7 @@ The CLI is the main entrypoint for most users. If you are integrating Veil progr
|
|
|
295
297
|
2. **Derive Keypair**: Run `veil init` to derive and save your Veil keypair
|
|
296
298
|
3. **Register**: Run `veil register` to link your deposit key on-chain (one-time)
|
|
297
299
|
4. **Check Status**: Run `veil status` to verify your setup
|
|
298
|
-
5. **Deposit**: Run `veil deposit <asset> <amount>` — the amount is what lands in your balance (e.g., `veil deposit ETH 0.1` deposits 0.1 ETH; the 0.3%
|
|
300
|
+
5. **Deposit**: Run `veil deposit <asset> <amount>` — the amount is what lands in your balance (e.g., `veil deposit ETH 0.1` deposits 0.1 ETH; the fee is waived if you have daily free deposits remaining, otherwise 0.3% is added automatically)
|
|
299
301
|
6. **Wait**: The Veil deposit engine processes your deposit
|
|
300
302
|
7. **Done**: Your deposit is accepted into the privacy pool
|
|
301
303
|
|
package/SDK.md
CHANGED
|
@@ -109,6 +109,11 @@ keypair.privkey; // '0x...'
|
|
|
109
109
|
|
|
110
110
|
### Transaction Builders
|
|
111
111
|
|
|
112
|
+
> **Daily free deposits**: Each address gets a configurable number of fee-free
|
|
113
|
+
> deposits per UTC day. The CLI handles this automatically. If you use the
|
|
114
|
+
> builders programmatically, call `getDailyFreeRemaining()` first — when the
|
|
115
|
+
> user has free slots, pass the net amount directly (no fee markup needed).
|
|
116
|
+
|
|
112
117
|
```typescript
|
|
113
118
|
import {
|
|
114
119
|
buildRegisterTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx,
|
|
@@ -177,12 +182,57 @@ const mergeResult = await mergeUtxos({
|
|
|
177
182
|
});
|
|
178
183
|
```
|
|
179
184
|
|
|
185
|
+
### Browser Proof Generation
|
|
186
|
+
|
|
187
|
+
`withdraw()`, `transfer()`, `mergeUtxos()`, `mergeSubaccount()`, `buildWithdrawProof()`,
|
|
188
|
+
`buildTransferProof()`, and `prepareTransaction()` can generate proofs in browser
|
|
189
|
+
runtimes.
|
|
190
|
+
|
|
191
|
+
In Node, the SDK uses the packaged `keys/` directory by default. In browsers,
|
|
192
|
+
the SDK defaults to same-origin hosted proving keys:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
/keys/transaction2.wasm
|
|
196
|
+
/keys/transaction2.zkey
|
|
197
|
+
/keys/transaction16.wasm
|
|
198
|
+
/keys/transaction16.zkey
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
For most web apps, copy the SDK `keys/` files into your app's public assets
|
|
202
|
+
directory. For example, in Next.js/Vite, serving them from `public/keys` makes
|
|
203
|
+
the default path work.
|
|
204
|
+
|
|
205
|
+
If you host keys elsewhere, pass `provingKeyPath`:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
await withdraw({
|
|
209
|
+
amount: '0.05',
|
|
210
|
+
recipient: '0xRecipientAddress',
|
|
211
|
+
keypair,
|
|
212
|
+
provingKeyPath: 'https://cdn.example.com/veil-keys',
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await transfer({
|
|
216
|
+
amount: '0.02',
|
|
217
|
+
recipientAddress: '0xRecipientAddress',
|
|
218
|
+
senderKeypair: keypair,
|
|
219
|
+
provingKeyPath: (circuitName) => `/static/zk/${circuitName}`,
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`provingKeyPath` may be a directory/base URL (`/keys`) or a resolver returning
|
|
224
|
+
the circuit base path without the `.wasm` / `.zkey` extension.
|
|
225
|
+
|
|
226
|
+
This removes Node `fs` key lookup from the browser proof path. Some bundlers
|
|
227
|
+
may still require standard Node-core polyfills for existing legacy dependencies
|
|
228
|
+
such as `circomlib`, `eth-sig-util`, and `fixed-merkle-tree`.
|
|
229
|
+
|
|
180
230
|
### Balance Queries
|
|
181
231
|
|
|
182
232
|
Balance functions accept an optional `pool` parameter (`'eth'` | `'usdc'`), defaulting to `'eth'`.
|
|
183
233
|
|
|
184
234
|
```typescript
|
|
185
|
-
import { getQueueBalance, getPrivateBalance } from '@veil-cash/sdk';
|
|
235
|
+
import { getQueueBalance, getPrivateBalance, getDailyFreeRemaining } from '@veil-cash/sdk';
|
|
186
236
|
|
|
187
237
|
// Check ETH queue balance (pending deposits)
|
|
188
238
|
const queueBalance = await getQueueBalance({
|
|
@@ -195,6 +245,13 @@ const privateBalance = await getPrivateBalance({
|
|
|
195
245
|
keypair,
|
|
196
246
|
pool: 'usdc',
|
|
197
247
|
});
|
|
248
|
+
|
|
249
|
+
// Check how many fee-free deposits the user has left today
|
|
250
|
+
const freeRemaining = await getDailyFreeRemaining({
|
|
251
|
+
address: '0x...',
|
|
252
|
+
pool: 'eth', // default
|
|
253
|
+
});
|
|
254
|
+
// freeRemaining: number — 0 when all free slots are used or the feature is disabled
|
|
198
255
|
```
|
|
199
256
|
|
|
200
257
|
### Subaccounts
|
|
@@ -291,8 +348,8 @@ veil init --json
|
|
|
291
348
|
|
|
292
349
|
# Get unsigned transaction payloads for agent signing
|
|
293
350
|
SIGNER_ADDRESS=0x... veil register --unsigned
|
|
294
|
-
veil deposit ETH 0.1 --unsigned
|
|
295
|
-
veil deposit USDC 100 --unsigned # Outputs approve + deposit payloads
|
|
351
|
+
SIGNER_ADDRESS=0x... veil deposit ETH 0.1 --unsigned
|
|
352
|
+
veil deposit USDC 100 --unsigned --address 0x... # Outputs approve + deposit payloads
|
|
296
353
|
|
|
297
354
|
# Request machine-readable status or balances
|
|
298
355
|
veil balance --json
|
|
@@ -344,12 +401,13 @@ Use `--unsigned` to get signer-compatible transaction payloads:
|
|
|
344
401
|
```bash
|
|
345
402
|
SIGNER_ADDRESS=0x... veil register --unsigned
|
|
346
403
|
SIGNER_ADDRESS=0x... veil register --unsigned --force
|
|
347
|
-
veil deposit ETH 0.1 --unsigned
|
|
404
|
+
SIGNER_ADDRESS=0x... veil deposit ETH 0.1 --unsigned
|
|
405
|
+
veil deposit ETH 0.1 --unsigned --address 0x...
|
|
348
406
|
# {"to":"0x...","data":"0x...","value":"100000000000000000","chainId":8453}
|
|
349
407
|
```
|
|
350
408
|
|
|
351
409
|
The `--unsigned` flag outputs a standard `{to, data, value, chainId}` payload compatible with any signer that accepts arbitrary transactions.
|
|
352
|
-
When `SIGNER_ADDRESS` is set, `veil register --unsigned` no longer
|
|
410
|
+
When `SIGNER_ADDRESS` is set, `veil register --unsigned` and `veil deposit --unsigned` no longer require the `--address` flag.
|
|
353
411
|
For `veil register --unsigned --force`, the CLI checks on-chain registration state first and emits `changeDepositKey` only when the address is already registered; otherwise it falls back to `register`.
|
|
354
412
|
|
|
355
413
|
### Programmatic SDK Usage
|