@silkysquad/silk 1.0.0

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/SKILL.md ADDED
@@ -0,0 +1,698 @@
1
+ ---
2
+ name: silk
3
+ version: 0.1.0
4
+ description: Agent payments on Solana. Send and receive USDC with cancellable escrow transfers. Optional on-chain accounts with policy-enforced spending limits for human-delegated automation.
5
+ homepage: https://silkyway.ai
6
+ metadata: {"category":"payments","api_base":"https://api.silkyway.ai","author":"silkysquad","openclaw":{"requires":{"bins":["silk"]},"install":[{"id":"silk-npm","kind":"node","label":"Silk CLI","package":"@silkyway/silk"}]}}
7
+ ---
8
+
9
+ # Silkyway
10
+
11
+ Agent payments on Solana. Send and receive USDC — non-custodial, on-chain.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @silkyway/silk
17
+ ```
18
+
19
+ Requires Node.js 18+.
20
+
21
+ ## Setup
22
+
23
+ ```bash
24
+ # 1. Initialize (creates wallet and agent ID)
25
+ silk init
26
+
27
+ # 2. Check your wallet address
28
+ silk wallet list
29
+ ```
30
+
31
+ Your wallet and agent ID are saved at `~/.config/silk/config.json`. Your private key never leaves your machine. `silk init` is idempotent — safe to run multiple times.
32
+
33
+ ### Cluster configuration
34
+
35
+ Default cluster is `mainnet-beta` (real USDC). Switch to `devnet` for testing with free tokens.
36
+
37
+ ```bash
38
+ silk config set-cluster devnet # test tokens
39
+ silk config set-cluster mainnet-beta # real USDC
40
+ silk config get-cluster # show current
41
+ ```
42
+
43
+ | Cluster | API Base URL | Network |
44
+ |---------|-------------|---------|
45
+ | `mainnet-beta` | `https://api.silkyway.ai` | Mainnet (real USDC) |
46
+ | `devnet` | `https://devnet-api.silkyway.ai` | Devnet (test USDC) |
47
+
48
+ ### Fund your wallet (devnet)
49
+
50
+ On devnet, use the faucet — it gives you 0.1 SOL (for transaction fees) + 100 USDC:
51
+
52
+ ```bash
53
+ silk config set-cluster devnet
54
+ silk wallet fund
55
+ silk balance
56
+ ```
57
+
58
+ On mainnet, send SOL and USDC to your wallet address manually. SOL is required for Solana transaction fees.
59
+
60
+ ## Sending Payments
61
+
62
+ ```bash
63
+ silk pay <recipient> <amount> [--memo <text>]
64
+ ```
65
+
66
+ This locks USDC into on-chain escrow. The recipient claims it with `silk claim`, or you cancel for a full refund with `silk cancel`.
67
+
68
+ The output includes a **claim link** (`claimUrl`) — a URL you can share with the recipient's human. They open it in a browser, connect their wallet, and claim the payment. This is the easiest way for a non-technical recipient to claim.
69
+
70
+ ```bash
71
+ # Send 10 USDC
72
+ silk pay 7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx 10 --memo "Payment for code review"
73
+
74
+ # Output includes claimUrl — share it with the recipient
75
+ # Example: https://app.silkyway.so/transfers/9aE5kBqRvF3...?cluster=devnet
76
+
77
+ # Check your balance
78
+ silk balance
79
+
80
+ # View your transfers
81
+ silk payments list
82
+ silk payments get <transfer-pda>
83
+ ```
84
+
85
+ ### Claiming a payment
86
+
87
+ If someone sent you a payment:
88
+
89
+ ```bash
90
+ silk payments list
91
+ silk claim <transfer-pda>
92
+ ```
93
+
94
+ ### Cancelling a payment
95
+
96
+ Cancel a payment you sent (before the recipient claims it):
97
+
98
+ ```bash
99
+ silk cancel <transfer-pda>
100
+ ```
101
+
102
+ ## Address Book
103
+
104
+ Save contacts so you can send payments by name instead of address.
105
+
106
+ ```bash
107
+ silk contacts add alice 7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx
108
+ silk contacts list
109
+ silk contacts get alice
110
+ silk contacts remove alice
111
+ ```
112
+
113
+ Once saved, use names anywhere you'd use an address:
114
+
115
+ ```bash
116
+ silk pay alice 10 --memo "Thanks for the review"
117
+ silk account send alice 5
118
+ ```
119
+
120
+ Contact names are case-insensitive and stored lowercase. Saved at `~/.config/silk/contacts.json`.
121
+
122
+ ## Multi-Wallet Support
123
+
124
+ ```bash
125
+ silk wallet create second-wallet
126
+ silk wallet fund --wallet second-wallet
127
+ silk wallet list
128
+ ```
129
+
130
+ Use `--wallet <label>` on any command to select a non-default wallet:
131
+
132
+ ```bash
133
+ silk pay <address> 10 --wallet second-wallet
134
+ silk balance --wallet second-wallet
135
+ ```
136
+
137
+ ## Support Chat
138
+
139
+ ```bash
140
+ silk chat "How do I send a payment?"
141
+ ```
142
+
143
+ A persistent `agentId` (UUID) is auto-generated on first use for session continuity.
144
+
145
+ ## On-Chain Accounts (Optional)
146
+
147
+ A Silkyway account is an on-chain wallet — like a bank account — that a human owner creates and funds with USDC. The owner can add agents as **operators** with per-transaction spending limits enforced on-chain. This is useful for automations, recurring payments, or any scenario where a human wants to delegate spending authority to an agent with guardrails.
148
+
149
+ You don't need an account to use Silkyway. Escrow payments (`silk pay`) work with just a wallet. Accounts are an optional upgrade when your human wants to give you direct spending access with on-chain controls.
150
+
151
+ **Key concepts:**
152
+ - **Owner** — The human who creates and funds the account. Full control: can transfer any amount, pause the account, add/remove operators.
153
+ - **Operator** — You (the agent). Authorized to send tokens from the account, subject to a per-transaction limit set by the owner.
154
+ - **Per-transaction limit** — Maximum USDC you can send in one transaction. Enforced on-chain — the Solana program rejects transactions that exceed it. A limit of 0 means unlimited.
155
+ - **Pause** — The owner can pause the account, blocking all operator transfers until unpaused. You cannot unpause it.
156
+
157
+ ### Setting up an account
158
+
159
+ Your human creates the account — you cannot create it yourself.
160
+
161
+ 1. Share the setup URL with your human (replace with your address from `silk wallet list`):
162
+ ```
163
+ https://app.silkyway.ai/account/setup?agent=YOUR_WALLET_ADDRESS
164
+ ```
165
+ They'll connect their wallet, set your spending limit, and fund the account.
166
+
167
+ **Important:** Your human must select the same network (mainnet/devnet) on the setup page as your CLI cluster. If you're on devnet, tell them to switch to devnet before creating the account.
168
+
169
+ 2. After your human creates the account, sync it:
170
+ ```bash
171
+ silk account sync
172
+ ```
173
+
174
+ 3. Check your status and send payments:
175
+ ```bash
176
+ silk account status
177
+ silk account send <recipient> <amount>
178
+ ```
179
+
180
+ If the amount exceeds your per-transaction limit, the transaction is **rejected on-chain** with `ExceedsPerTxLimit`. If the account is paused, you get `AccountPaused`.
181
+
182
+ If `silk account sync` returns "No account found", your human hasn't created the account yet — share the setup URL with them.
183
+
184
+ ### Accounts vs escrow payments
185
+
186
+ | | Accounts | Escrow (`silk pay`) |
187
+ |---|---|---|
188
+ | **Setup required** | Human creates account + adds you as operator | None — just a funded wallet |
189
+ | **Spending limits** | Per-transaction limit enforced on-chain | No limits |
190
+ | **Recipient claims?** | No — direct transfer, tokens arrive immediately | Yes — recipient must `silk claim` |
191
+ | **Cancellable?** | No — transfer is instant | Yes — sender can cancel before claim |
192
+ | **Best for** | Ongoing payments with human oversight | One-off payments between parties |
193
+
194
+ If your human has set up an account for you, prefer `silk account send` — it's simpler (no claim step) and your human controls the spending limits.
195
+
196
+ ## CLI Reference
197
+
198
+ | Command | Description |
199
+ |---------|-------------|
200
+ | `silk init` | Initialize CLI (create wallet, agent ID, and contacts file) |
201
+ | `silk wallet create [label]` | Create a new wallet |
202
+ | `silk wallet list` | List all wallets with addresses |
203
+ | `silk wallet fund [--sol] [--usdc] [--wallet <label>]` | Fund wallet from devnet faucet |
204
+ | `silk balance [--wallet <label>]` | Show SOL and USDC balances |
205
+ | `silk pay <recipient> <amount> [--memo <text>] [--wallet <label>]` | Send USDC payment into escrow |
206
+ | `silk claim <transfer-pda> [--wallet <label>]` | Claim a received payment |
207
+ | `silk cancel <transfer-pda> [--wallet <label>]` | Cancel a sent payment |
208
+ | `silk payments list [--wallet <label>]` | List transfers |
209
+ | `silk payments get <transfer-pda>` | Get transfer details |
210
+ | `silk contacts add <name> <address>` | Save a contact to the address book |
211
+ | `silk contacts remove <name>` | Remove a contact |
212
+ | `silk contacts list` | List all saved contacts |
213
+ | `silk contacts get <name>` | Look up a contact's address |
214
+ | `silk account sync [--wallet <label>] [--account <pda>]` | Discover and sync your on-chain account |
215
+ | `silk account status [--wallet <label>]` | Show account balance, spending limit, and pause state |
216
+ | `silk account send <recipient> <amount> [--memo <text>] [--wallet <label>]` | Send from account (policy-enforced on-chain) |
217
+ | `silk chat <message>` | Ask Silkyway support agent a question |
218
+ | `silk config set-cluster <cluster>` | Set cluster (`mainnet-beta` or `devnet`) |
219
+ | `silk config get-cluster` | Show current cluster and API URL |
220
+ | `silk config reset-cluster` | Reset cluster to default (`mainnet-beta`) |
221
+
222
+ Use `--wallet <label>` on any command to select a non-default wallet. Recipients accept contact names or Solana addresses.
223
+
224
+ ## How Transactions Work
225
+
226
+ Silkyway is non-custodial — your private keys never leave your machine.
227
+
228
+ Every payment follows a build-sign-submit flow:
229
+
230
+ 1. **Build** — The SDK calls an API endpoint with payment details. The backend builds an unsigned Solana transaction and returns it as base64.
231
+ 2. **Sign** — The SDK signs the transaction locally using your private key.
232
+ 3. **Submit** — The SDK sends the signed transaction to the backend, which forwards it to Solana.
233
+
234
+ The backend handles Solana complexity (PDA derivation, instruction building, blockhash management). It never sees your private key — all authorization is enforced on-chain by the Solana program.
235
+
236
+ ## API Endpoints
237
+
238
+ Base URL: `https://api.silkyway.ai` (mainnet) or `https://devnet-api.silkyway.ai` (devnet)
239
+
240
+ All requests use `Content-Type: application/json`.
241
+
242
+ ### Escrow Endpoints
243
+
244
+ ### POST /api/tx/create-transfer
245
+
246
+ Build an unsigned create_transfer transaction. Locks USDC into escrow.
247
+
248
+ **Request:**
249
+ ```json
250
+ {
251
+ "sender": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
252
+ "recipient": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
253
+ "amount": 10.00,
254
+ "token": "usdc",
255
+ "memo": "Payment for code review"
256
+ }
257
+ ```
258
+
259
+ | Field | Type | Required | Description |
260
+ |-------|------|----------|-------------|
261
+ | `sender` | string | yes | Sender's Solana public key |
262
+ | `recipient` | string | yes | Recipient's Solana public key |
263
+ | `amount` | number | yes | Amount in token units (e.g. `10.00` = 10 USDC) |
264
+ | `token` | string | yes | Token symbol (e.g. `"usdc"`) |
265
+ | `memo` | string | no | Human-readable memo |
266
+ | `claimableAfter` | number | no | Unix timestamp — recipient cannot claim before this time |
267
+
268
+ You can also pass `mint` (token mint pubkey) or `poolPda` directly instead of `token`, but `token` is the simplest option.
269
+
270
+ **Response:**
271
+ ```json
272
+ {
273
+ "ok": true,
274
+ "data": {
275
+ "transaction": "AQAAAAAAAAAAAAAA...base64...AAAAAAA=",
276
+ "transferPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
277
+ "nonce": "1738900000000",
278
+ "message": "Sign and submit via POST /api/tx/submit"
279
+ }
280
+ }
281
+ ```
282
+
283
+ The `transferPda` is the on-chain address for this escrow. Save it — you need it to claim or cancel.
284
+
285
+ ### POST /api/tx/claim-transfer
286
+
287
+ Build an unsigned claim_transfer transaction. Moves USDC from escrow to the recipient's wallet.
288
+
289
+ Only the designated recipient can claim. If `claimableAfter` was set, the claim will fail before that time.
290
+
291
+ **Request:**
292
+ ```json
293
+ {
294
+ "transferPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
295
+ "claimer": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx"
296
+ }
297
+ ```
298
+
299
+ | Field | Type | Required | Description |
300
+ |-------|------|----------|-------------|
301
+ | `transferPda` | string | yes | The transfer's on-chain PDA |
302
+ | `claimer` | string | yes | Recipient's Solana public key |
303
+
304
+ **Response:**
305
+ ```json
306
+ {
307
+ "ok": true,
308
+ "data": {
309
+ "transaction": "AQAAAAAAAAAAAAAA...base64...AAAAAAA=",
310
+ "message": "Sign and submit via POST /api/tx/submit"
311
+ }
312
+ }
313
+ ```
314
+
315
+ **Common errors:**
316
+ - `ClaimTooEarly` (6003) — `claimableAfter` hasn't passed yet
317
+ - `TransferAlreadyClaimed` (6000) — already claimed
318
+ - `TransferAlreadyCancelled` (6001) — sender cancelled first
319
+ - `Unauthorized` (6004) — claimer is not the designated recipient
320
+
321
+ ### POST /api/tx/cancel-transfer
322
+
323
+ Build an unsigned cancel_transfer transaction. Refunds USDC from escrow back to the sender.
324
+
325
+ Only the original sender can cancel, and only while the transfer is still `ACTIVE` (not yet claimed).
326
+
327
+ **Request:**
328
+ ```json
329
+ {
330
+ "transferPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
331
+ "canceller": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp"
332
+ }
333
+ ```
334
+
335
+ | Field | Type | Required | Description |
336
+ |-------|------|----------|-------------|
337
+ | `transferPda` | string | yes | The transfer's on-chain PDA |
338
+ | `canceller` | string | yes | Sender's Solana public key |
339
+
340
+ **Response:**
341
+ ```json
342
+ {
343
+ "ok": true,
344
+ "data": {
345
+ "transaction": "AQAAAAAAAAAAAAAA...base64...AAAAAAA=",
346
+ "message": "Sign and submit via POST /api/tx/submit"
347
+ }
348
+ }
349
+ ```
350
+
351
+ **Common errors:**
352
+ - `TransferAlreadyClaimed` (6000) — recipient already claimed
353
+ - `TransferAlreadyCancelled` (6001) — already cancelled
354
+ - `Unauthorized` (6004) — canceller is not the original sender
355
+
356
+ ### POST /api/tx/submit
357
+
358
+ Submit a signed transaction to Solana.
359
+
360
+ **Request:**
361
+ ```json
362
+ {
363
+ "signedTx": "AQAAAAAAAAAAAAAA...base64-signed...AAAAAAA="
364
+ }
365
+ ```
366
+
367
+ **Response:**
368
+ ```json
369
+ {
370
+ "ok": true,
371
+ "data": {
372
+ "txid": "5UfDuXsrhFnxGZmyJxNR8z7Ee5JDFrgWHKPdTEJvoTpB3Qw8mKz4GQN1sxZWoGL"
373
+ }
374
+ }
375
+ ```
376
+
377
+ ### GET /api/transfers/:pda
378
+
379
+ Get details for a single transfer.
380
+
381
+ **Example:** `GET /api/transfers/9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4`
382
+
383
+ **Response:**
384
+ ```json
385
+ {
386
+ "ok": true,
387
+ "data": {
388
+ "transfer": {
389
+ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
390
+ "transferPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
391
+ "sender": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
392
+ "recipient": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
393
+ "amount": "10000000",
394
+ "amountRaw": "10000000",
395
+ "status": "ACTIVE",
396
+ "memo": "Payment for code review",
397
+ "createTxid": "5UfDuXsrhFnxGZmyJxNR8z7Ee5JDFrgWHKPdTEJvoTpB",
398
+ "claimTxid": null,
399
+ "cancelTxid": null,
400
+ "claimableAfter": null,
401
+ "claimableUntil": null,
402
+ "createdAt": "2025-02-07T12:00:00.000Z",
403
+ "updatedAt": "2025-02-07T12:00:00.000Z",
404
+ "token": { "mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", "symbol": "USDC", "decimals": 6 },
405
+ "pool": { "poolPda": "3Fk8vMYJbCbEB2jzRCdRG9rFJhN2TCmPia9BjEKpTk5R", "feeBps": 50 }
406
+ }
407
+ }
408
+ }
409
+ ```
410
+
411
+ Note: `amount` is in raw token units. USDC has 6 decimals, so `"10000000"` = 10.00 USDC.
412
+
413
+ ### GET /api/transfers?wallet=\<pubkey\>
414
+
415
+ List all transfers where the wallet is sender or recipient.
416
+
417
+ **Example:** `GET /api/transfers?wallet=BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp`
418
+
419
+ **Response:**
420
+ ```json
421
+ {
422
+ "ok": true,
423
+ "data": {
424
+ "transfers": [
425
+ {
426
+ "transferPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
427
+ "sender": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
428
+ "recipient": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
429
+ "amount": "10000000",
430
+ "status": "ACTIVE",
431
+ "memo": "Payment for code review",
432
+ "createdAt": "2025-02-07T12:00:00.000Z",
433
+ "token": { "mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", "symbol": "USDC", "decimals": 6 },
434
+ "pool": { "poolPda": "3Fk8vMYJbCbEB2jzRCdRG9rFJhN2TCmPia9BjEKpTk5R", "feeBps": 50 }
435
+ }
436
+ ]
437
+ }
438
+ }
439
+ ```
440
+
441
+ ### POST /api/tx/faucet
442
+
443
+ Airdrop devnet SOL or USDC. Devnet only.
444
+
445
+ **Request:**
446
+ ```json
447
+ {
448
+ "wallet": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
449
+ "token": "usdc"
450
+ }
451
+ ```
452
+
453
+ `token` is optional. Omit or use `"sol"` for SOL airdrop, `"usdc"` for USDC mint.
454
+
455
+ **Response:**
456
+ ```json
457
+ {
458
+ "ok": true,
459
+ "data": {
460
+ "amount": 0.1,
461
+ "txid": "5UfDuXsrhFnxGZmyJxNR8z7Ee5JDFrgWHKPdTEJvoTpB3Qw8mKz4GQN1sxZWoGL"
462
+ }
463
+ }
464
+ ```
465
+
466
+ ### Account Endpoints
467
+
468
+ #### GET /api/account/by-operator/:pubkey
469
+
470
+ Find accounts where your wallet is an operator. Used by `silk account sync`.
471
+
472
+ **Example:** `GET /api/account/by-operator/7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx`
473
+
474
+ **Response:**
475
+ ```json
476
+ {
477
+ "ok": true,
478
+ "data": {
479
+ "accounts": [
480
+ {
481
+ "pda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
482
+ "owner": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
483
+ "mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
484
+ "mintDecimals": 6,
485
+ "isPaused": false,
486
+ "balance": 10000000,
487
+ "operatorSlot": {
488
+ "index": 0,
489
+ "perTxLimit": 5000000,
490
+ "dailyLimit": 0
491
+ }
492
+ }
493
+ ]
494
+ }
495
+ }
496
+ ```
497
+
498
+ Returns an empty array if no accounts found — this means your human hasn't set up your account yet.
499
+
500
+ #### GET /api/account/:pda
501
+
502
+ Get full account details. Used by `silk account status`.
503
+
504
+ **Example:** `GET /api/account/9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4`
505
+
506
+ **Response:**
507
+ ```json
508
+ {
509
+ "ok": true,
510
+ "data": {
511
+ "pda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
512
+ "owner": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
513
+ "mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
514
+ "mintDecimals": 6,
515
+ "isPaused": false,
516
+ "balance": 10000000,
517
+ "operators": [
518
+ {
519
+ "pubkey": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
520
+ "perTxLimit": 5000000,
521
+ "dailyLimit": 0
522
+ }
523
+ ]
524
+ }
525
+ }
526
+ ```
527
+
528
+ Note: `balance` and `perTxLimit` are in raw token units. USDC has 6 decimals, so `5000000` = $5.00.
529
+
530
+ #### POST /api/account/transfer
531
+
532
+ Build an unsigned transfer transaction from a Silkyway account. Used by `silk account send`.
533
+
534
+ **Request:**
535
+ ```json
536
+ {
537
+ "signer": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
538
+ "accountPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
539
+ "recipient": "Dg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx7xKXz9BpR3mFV",
540
+ "amount": 3000000
541
+ }
542
+ ```
543
+
544
+ | Field | Type | Required | Description |
545
+ |-------|------|----------|-------------|
546
+ | `signer` | string | yes | Your wallet address (operator) |
547
+ | `accountPda` | string | yes | The account's on-chain PDA |
548
+ | `recipient` | string | yes | Recipient's Solana public key |
549
+ | `amount` | number | yes | Amount in raw token units (e.g. `3000000` = 3.00 USDC) |
550
+
551
+ **Response:**
552
+ ```json
553
+ {
554
+ "ok": true,
555
+ "data": {
556
+ "transaction": "AQAAAAAAAAAAAAAA...base64...AAAAAAA="
557
+ }
558
+ }
559
+ ```
560
+
561
+ Sign and submit the returned transaction via `POST /api/tx/submit`.
562
+
563
+ **Common errors:**
564
+ - `ExceedsPerTxLimit` — Amount exceeds your per-transaction spending limit
565
+ - `AccountPaused` — Account is paused by the owner; operator transfers blocked
566
+ - `Unauthorized` — Signer is not the owner or an operator on this account
567
+
568
+ #### POST /api/account/create
569
+
570
+ Build an unsigned create-account transaction. Used by the setup page (human-facing, not typically called by agents).
571
+
572
+ **Request:**
573
+ ```json
574
+ {
575
+ "owner": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
576
+ "mint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
577
+ "operator": "7xKXz9BpR3mFVDg2Thh3AG6sFRPqNrDJ4bHUkR8Y7vNx",
578
+ "perTxLimit": 5000000
579
+ }
580
+ ```
581
+
582
+ #### POST /api/account/deposit
583
+
584
+ Build an unsigned deposit transaction. Used by the setup page to fund the account.
585
+
586
+ **Request:**
587
+ ```json
588
+ {
589
+ "depositor": "BrKz4GQN1sxZWoGLbNTojp4G3JCFLRkSYk3mSRWhKsXp",
590
+ "accountPda": "9aE5kBqRvF3mNcXz8BpR3mFVDg2Thh3AG6sFRPqNrDJ4",
591
+ "amount": 10000000
592
+ }
593
+ ```
594
+
595
+ ### POST /chat
596
+
597
+ Send a message to the Silkyway support agent. Returns an AI-generated response.
598
+
599
+ **Request:**
600
+ ```json
601
+ {
602
+ "agentId": "uuid-v4",
603
+ "message": "How do I send a payment?"
604
+ }
605
+ ```
606
+
607
+ | Field | Type | Required | Description |
608
+ |-------|------|----------|-------------|
609
+ | `agentId` | string | yes | UUID v4 identifying the agent (auto-generated by the SDK) |
610
+ | `message` | string | yes | The question to ask |
611
+
612
+ **Response (200):**
613
+ ```json
614
+ {
615
+ "ok": true,
616
+ "data": {
617
+ "message": "Use silk pay...",
618
+ "agentId": "uuid-v4"
619
+ }
620
+ }
621
+ ```
622
+
623
+ ## Transfer Statuses
624
+
625
+ | Status | Description |
626
+ |--------|-------------|
627
+ | `ACTIVE` | Tokens locked in escrow, awaiting claim or cancellation |
628
+ | `CLAIMED` | Recipient claimed the tokens |
629
+ | `CANCELLED` | Sender cancelled and reclaimed the tokens |
630
+ | `EXPIRED` | Transfer expired past its `claimableUntil` window |
631
+
632
+ ## Error Codes
633
+
634
+ ### Escrow Program Errors (Handshake)
635
+
636
+ | Code | Name | Description |
637
+ |------|------|-------------|
638
+ | 6000 | `TransferAlreadyClaimed` | Transfer has already been claimed |
639
+ | 6001 | `TransferAlreadyCancelled` | Transfer has already been cancelled |
640
+ | 6002 | `TransferExpired` | Transfer has expired |
641
+ | 6003 | `ClaimTooEarly` | Cannot claim before `claimableAfter` timestamp |
642
+ | 6004 | `Unauthorized` | Signer is not authorized for this action |
643
+ | 6005 | `PoolPaused` | The token's escrow pool is temporarily paused — try again later |
644
+ | 6006 | `InsufficientFunds` | Sender has insufficient token balance |
645
+
646
+ ### Account Program Errors (Silkysig)
647
+
648
+ | Code | Name | Description |
649
+ |------|------|-------------|
650
+ | 6000 | `Unauthorized` | Signer is not the owner or an operator on this account |
651
+ | 6001 | `ExceedsPerTxLimit` | Transfer amount exceeds operator's per-transaction spending limit |
652
+ | 6002 | `ExceedsDailyLimit` | Transfer exceeds operator daily limit (not yet enforced) |
653
+ | 6003 | `AccountPaused` | Account is paused — operator transfers blocked until owner unpauses |
654
+ | 6004 | `MaxOperatorsReached` | Account already has 3 operators (maximum) |
655
+ | 6005 | `OperatorNotFound` | Specified operator not found on account |
656
+ | 6006 | `OperatorAlreadyExists` | Operator is already on this account |
657
+ | 6007 | `InsufficientBalance` | Account doesn't have enough tokens for this transfer |
658
+ | 6008 | `MathOverflow` | Arithmetic overflow in calculation |
659
+
660
+ ### API Errors
661
+
662
+ | Error | HTTP | Description |
663
+ |-------|------|-------------|
664
+ | `INVALID_PUBKEY` | 400 | Invalid Solana public key format |
665
+ | `INVALID_AMOUNT` | 400 | Amount must be positive |
666
+ | `MISSING_FIELD` | 400 | Required field not provided |
667
+ | `TRANSFER_NOT_FOUND` | 404 | No transfer found for the given PDA |
668
+ | `POOL_NOT_FOUND` | 404 | No escrow pool found for this token |
669
+ | `TOKEN_NOT_FOUND` | 400 | Token symbol or mint not recognized |
670
+ | `TX_FAILED` | 400 | Transaction simulation or submission failed |
671
+ | `RATE_LIMITED` | 429 | Too many faucet requests |
672
+ | `FAUCET_FAILED` | 400 | Faucet airdrop failed |
673
+
674
+ ## Response Format
675
+
676
+ **Success:**
677
+ ```json
678
+ {
679
+ "ok": true,
680
+ "data": { ... }
681
+ }
682
+ ```
683
+
684
+ **Error:**
685
+ ```json
686
+ {
687
+ "ok": false,
688
+ "error": "ERROR_CODE",
689
+ "message": "Human-readable description"
690
+ }
691
+ ```
692
+
693
+ ## Security
694
+
695
+ - **Non-custodial** — the backend builds unsigned transactions; you sign locally with your private key before submitting
696
+ - Private keys are never transmitted to the server
697
+ - All authorization is enforced on-chain by the Solana program, not by the backend
698
+ - Keys are stored locally at `~/.config/silk/config.json` — never share this file
package/index.js ADDED
@@ -0,0 +1 @@
1
+ console.log('Happy developing ✨')
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@silkysquad/silk",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "private": false
10
+ }