@goplausible/openclaw-algorand-plugin 0.5.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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/index.ts +361 -0
  4. package/lib/mcp-servers.ts +14 -0
  5. package/lib/x402-fetch.ts +213 -0
  6. package/memory/algorand-plugin.md +82 -0
  7. package/openclaw.plugin.json +30 -0
  8. package/package.json +41 -0
  9. package/setup.ts +80 -0
  10. package/skills/algorand-development/SKILL.md +90 -0
  11. package/skills/algorand-development/references/build-smart-contracts-reference.md +79 -0
  12. package/skills/algorand-development/references/build-smart-contracts.md +52 -0
  13. package/skills/algorand-development/references/create-project-reference.md +86 -0
  14. package/skills/algorand-development/references/create-project.md +89 -0
  15. package/skills/algorand-development/references/implement-arc-standards-arc32-arc56.md +396 -0
  16. package/skills/algorand-development/references/implement-arc-standards-arc4.md +265 -0
  17. package/skills/algorand-development/references/implement-arc-standards.md +92 -0
  18. package/skills/algorand-development/references/search-algorand-examples-reference.md +119 -0
  19. package/skills/algorand-development/references/search-algorand-examples.md +89 -0
  20. package/skills/algorand-development/references/troubleshoot-errors-contract.md +373 -0
  21. package/skills/algorand-development/references/troubleshoot-errors-transaction.md +599 -0
  22. package/skills/algorand-development/references/troubleshoot-errors.md +105 -0
  23. package/skills/algorand-development/references/use-algokit-cli-reference.md +228 -0
  24. package/skills/algorand-development/references/use-algokit-cli.md +64 -0
  25. package/skills/algorand-interaction/SKILL.md +223 -0
  26. package/skills/algorand-interaction/references/algorand-mcp.md +743 -0
  27. package/skills/algorand-interaction/references/examples-algorand-mcp.md +647 -0
  28. package/skills/algorand-python/SKILL.md +95 -0
  29. package/skills/algorand-python/references/build-smart-contracts-decorators.md +413 -0
  30. package/skills/algorand-python/references/build-smart-contracts-reference.md +55 -0
  31. package/skills/algorand-python/references/build-smart-contracts-storage.md +452 -0
  32. package/skills/algorand-python/references/build-smart-contracts-transactions.md +445 -0
  33. package/skills/algorand-python/references/build-smart-contracts-types.md +438 -0
  34. package/skills/algorand-python/references/build-smart-contracts.md +82 -0
  35. package/skills/algorand-python/references/create-project-reference.md +55 -0
  36. package/skills/algorand-python/references/create-project.md +75 -0
  37. package/skills/algorand-python/references/implement-arc-standards-arc32-arc56.md +101 -0
  38. package/skills/algorand-python/references/implement-arc-standards-arc4.md +154 -0
  39. package/skills/algorand-python/references/implement-arc-standards.md +39 -0
  40. package/skills/algorand-python/references/troubleshoot-errors-contract.md +355 -0
  41. package/skills/algorand-python/references/troubleshoot-errors-transaction.md +430 -0
  42. package/skills/algorand-python/references/troubleshoot-errors.md +46 -0
  43. package/skills/algorand-python/references/use-algokit-utils-reference.md +350 -0
  44. package/skills/algorand-python/references/use-algokit-utils.md +76 -0
  45. package/skills/algorand-typescript/SKILL.md +131 -0
  46. package/skills/algorand-typescript/references/algorand-ts-migration-from-beta.md +448 -0
  47. package/skills/algorand-typescript/references/algorand-ts-migration-from-tealscript.md +487 -0
  48. package/skills/algorand-typescript/references/algorand-ts-migration.md +102 -0
  49. package/skills/algorand-typescript/references/algorand-typescript-syntax-methods-and-abi.md +134 -0
  50. package/skills/algorand-typescript/references/algorand-typescript-syntax-reference.md +58 -0
  51. package/skills/algorand-typescript/references/algorand-typescript-syntax-storage.md +154 -0
  52. package/skills/algorand-typescript/references/algorand-typescript-syntax-transactions.md +187 -0
  53. package/skills/algorand-typescript/references/algorand-typescript-syntax-types-and-values.md +150 -0
  54. package/skills/algorand-typescript/references/algorand-typescript-syntax.md +84 -0
  55. package/skills/algorand-typescript/references/build-smart-contracts-reference.md +52 -0
  56. package/skills/algorand-typescript/references/build-smart-contracts.md +74 -0
  57. package/skills/algorand-typescript/references/call-smart-contracts-reference.md +237 -0
  58. package/skills/algorand-typescript/references/call-smart-contracts.md +183 -0
  59. package/skills/algorand-typescript/references/create-project-reference.md +53 -0
  60. package/skills/algorand-typescript/references/create-project.md +86 -0
  61. package/skills/algorand-typescript/references/deploy-react-frontend-examples.md +527 -0
  62. package/skills/algorand-typescript/references/deploy-react-frontend-reference.md +412 -0
  63. package/skills/algorand-typescript/references/deploy-react-frontend.md +239 -0
  64. package/skills/algorand-typescript/references/implement-arc-standards-arc32-arc56.md +73 -0
  65. package/skills/algorand-typescript/references/implement-arc-standards-arc4.md +126 -0
  66. package/skills/algorand-typescript/references/implement-arc-standards.md +44 -0
  67. package/skills/algorand-typescript/references/test-smart-contracts-examples.md +245 -0
  68. package/skills/algorand-typescript/references/test-smart-contracts-unit-tests.md +147 -0
  69. package/skills/algorand-typescript/references/test-smart-contracts.md +127 -0
  70. package/skills/algorand-typescript/references/troubleshoot-errors-contract.md +296 -0
  71. package/skills/algorand-typescript/references/troubleshoot-errors-transaction.md +438 -0
  72. package/skills/algorand-typescript/references/troubleshoot-errors.md +56 -0
  73. package/skills/algorand-typescript/references/use-algokit-utils-reference.md +342 -0
  74. package/skills/algorand-typescript/references/use-algokit-utils.md +74 -0
  75. package/skills/algorand-x402-python/SKILL.md +113 -0
  76. package/skills/algorand-x402-python/references/create-python-x402-client-examples.md +469 -0
  77. package/skills/algorand-x402-python/references/create-python-x402-client-reference.md +313 -0
  78. package/skills/algorand-x402-python/references/create-python-x402-client.md +207 -0
  79. package/skills/algorand-x402-python/references/create-python-x402-facilitator-examples.md +924 -0
  80. package/skills/algorand-x402-python/references/create-python-x402-facilitator-reference.md +629 -0
  81. package/skills/algorand-x402-python/references/create-python-x402-facilitator.md +408 -0
  82. package/skills/algorand-x402-python/references/create-python-x402-server-examples.md +703 -0
  83. package/skills/algorand-x402-python/references/create-python-x402-server-reference.md +303 -0
  84. package/skills/algorand-x402-python/references/create-python-x402-server.md +221 -0
  85. package/skills/algorand-x402-python/references/explain-algorand-x402-python-examples.md +605 -0
  86. package/skills/algorand-x402-python/references/explain-algorand-x402-python-reference.md +315 -0
  87. package/skills/algorand-x402-python/references/explain-algorand-x402-python.md +167 -0
  88. package/skills/algorand-x402-python/references/use-python-x402-core-avm-examples.md +554 -0
  89. package/skills/algorand-x402-python/references/use-python-x402-core-avm-reference.md +278 -0
  90. package/skills/algorand-x402-python/references/use-python-x402-core-avm.md +166 -0
  91. package/skills/algorand-x402-typescript/SKILL.md +129 -0
  92. package/skills/algorand-x402-typescript/references/create-typescript-x402-client-examples.md +879 -0
  93. package/skills/algorand-x402-typescript/references/create-typescript-x402-client-reference.md +371 -0
  94. package/skills/algorand-x402-typescript/references/create-typescript-x402-client.md +236 -0
  95. package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-examples.md +875 -0
  96. package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-reference.md +461 -0
  97. package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator.md +270 -0
  98. package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-examples.md +1181 -0
  99. package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-reference.md +360 -0
  100. package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs.md +251 -0
  101. package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-examples.md +870 -0
  102. package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-reference.md +323 -0
  103. package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall.md +281 -0
  104. package/skills/algorand-x402-typescript/references/create-typescript-x402-server-examples.md +1135 -0
  105. package/skills/algorand-x402-typescript/references/create-typescript-x402-server-reference.md +382 -0
  106. package/skills/algorand-x402-typescript/references/create-typescript-x402-server.md +216 -0
  107. package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-examples.md +616 -0
  108. package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-reference.md +323 -0
  109. package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript.md +232 -0
  110. package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-examples.md +1417 -0
  111. package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-reference.md +504 -0
  112. package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm.md +158 -0
@@ -0,0 +1,647 @@
1
+ # Algorand MCP — Workflow Examples
2
+
3
+ > All examples use `network: "testnet"` unless noted. For mainnet, change to `"mainnet"` and confirm with user.
4
+ > USDC ASA ID: 31566704 (6 decimals). 1 ALGO = 1,000,000 microAlgos.
5
+
6
+ ---
7
+
8
+ ## Session Start
9
+
10
+ ### Step 1: Verify wallet
11
+ ```
12
+ wallet_get_info { "network": "testnet" }
13
+ ```
14
+
15
+ ### Step 2: If no account exists
16
+ ```
17
+ wallet_add_account {
18
+ "nickname": "my-wallet",
19
+ "allowance": 5000000,
20
+ "dailyAllowance": 10000000
21
+ }
22
+ ```
23
+
24
+ ### Step 3: If account needs funding
25
+ ```
26
+ generate_algorand_uri {
27
+ "address": "[wallet_address]",
28
+ "amount": 5000000,
29
+ "note": "Fund testnet account"
30
+ }
31
+ ```
32
+ Or direct user to: https://lora.algokit.io/testnet/fund
33
+
34
+ ### Step 4: If account needs USDC funding
35
+ ```
36
+ generate_algorand_uri {
37
+ "address": "[wallet_address]",
38
+ "asset": 10458941, // USDC on testnet
39
+ "amount": 1000000, // 1 USDC with 6 decimals
40
+ "note": "Fund testnet account with USDC"
41
+ }
42
+ ```
43
+ Or direct user to: https://faucet.circle.com/
44
+
45
+ ---
46
+
47
+ ## ALGO Payment Workflow
48
+
49
+ ### Step 1: Get wallet info
50
+ ```
51
+ wallet_get_info { "network": "testnet" }
52
+ ```
53
+
54
+ ### Step 2: Create payment transaction
55
+ ```
56
+ make_payment_txn {
57
+ "from": "[sender_address]",
58
+ "to": "[receiver_address]",
59
+ "amount": 1000000,
60
+ "note": "Payment of 1 ALGO",
61
+ "network": "testnet"
62
+ }
63
+ ```
64
+ > Amount in microAlgos: 1 ALGO = 1,000,000
65
+
66
+ ### Step 3: Sign the transaction
67
+ ```
68
+ wallet_sign_transaction {
69
+ "transaction": { "...transaction object from step 2..." },
70
+ "network": "testnet"
71
+ }
72
+ ```
73
+
74
+ ### Step 4: Submit the transaction
75
+ ```
76
+ send_raw_transaction {
77
+ "signedTxns": ["[base64_blob_from_step_3]"],
78
+ "network": "testnet"
79
+ }
80
+ ```
81
+
82
+ ### Step 5: Verify (optional)
83
+ ```
84
+ api_indexer_lookup_transaction_by_id {
85
+ "txId": "[txID_from_step_3]",
86
+ "network": "testnet"
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Asset Opt-In Workflow (One-Step)
93
+
94
+ The simplest way to opt-in to an asset:
95
+
96
+ ```
97
+ wallet_optin_asset {
98
+ "assetId": 31566704,
99
+ "network": "testnet"
100
+ }
101
+ ```
102
+
103
+ This creates, signs, and submits the opt-in transaction in a single call.
104
+
105
+ ---
106
+
107
+ ## Asset Opt-In Workflow (Manual)
108
+
109
+ ### Step 1: Check if already opted in
110
+ ```
111
+ api_algod_get_account_asset_info {
112
+ "address": "[sender_address]",
113
+ "assetId": 31566704,
114
+ "network": "testnet"
115
+ }
116
+ ```
117
+
118
+ ### Step 2: Create opt-in transaction (0-amount self-transfer)
119
+ ```
120
+ make_asset_transfer_txn {
121
+ "from": "[sender_address]",
122
+ "to": "[sender_address]",
123
+ "assetIndex": 31566704,
124
+ "amount": 0,
125
+ "network": "testnet"
126
+ }
127
+ ```
128
+
129
+ ### Step 3: Sign
130
+ ```
131
+ wallet_sign_transaction {
132
+ "transaction": { "...transaction from step 2..." },
133
+ "network": "testnet"
134
+ }
135
+ ```
136
+
137
+ ### Step 4: Submit
138
+ ```
139
+ send_raw_transaction {
140
+ "signedTxns": ["[base64_blob_from_step_3]"],
141
+ "network": "testnet"
142
+ }
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Asset Transfer Workflow (USDC Example)
148
+
149
+ ### Step 1: Get wallet info
150
+ ```
151
+ wallet_get_info { "network": "testnet" }
152
+ ```
153
+
154
+ ### Step 2: Get asset info (verify decimals)
155
+ ```
156
+ api_algod_get_asset_by_id {
157
+ "assetId": 31566704,
158
+ "network": "testnet"
159
+ }
160
+ ```
161
+
162
+ ### Step 3: Check sender's asset balance
163
+ ```
164
+ api_algod_get_account_asset_info {
165
+ "address": "[sender_address]",
166
+ "assetId": 31566704,
167
+ "network": "testnet"
168
+ }
169
+ ```
170
+
171
+ ### Step 4: Verify recipient has opted in
172
+ ```
173
+ api_algod_get_account_asset_info {
174
+ "address": "[recipient_address]",
175
+ "assetId": 31566704,
176
+ "network": "testnet"
177
+ }
178
+ ```
179
+
180
+ ### Step 5: Create transfer (1 USDC = 1,000,000 with 6 decimals)
181
+ ```
182
+ make_asset_transfer_txn {
183
+ "from": "[sender_address]",
184
+ "to": "[recipient_address]",
185
+ "assetIndex": 31566704,
186
+ "amount": 1000000,
187
+ "network": "testnet"
188
+ }
189
+ ```
190
+
191
+ ### Step 6: Sign
192
+ ```
193
+ wallet_sign_transaction {
194
+ "transaction": { "...transaction from step 5..." },
195
+ "network": "testnet"
196
+ }
197
+ ```
198
+
199
+ ### Step 7: Submit
200
+ ```
201
+ send_raw_transaction {
202
+ "signedTxns": ["[base64_blob_from_step_6]"],
203
+ "network": "testnet"
204
+ }
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Atomic Group Transaction Workflow
210
+
211
+ ### Step 1: Build individual transactions
212
+ ```
213
+ make_payment_txn {
214
+ "from": "[address_A]",
215
+ "to": "[address_B]",
216
+ "amount": 1000000,
217
+ "network": "testnet"
218
+ }
219
+ ```
220
+ ```
221
+ make_asset_transfer_txn {
222
+ "from": "[address_B]",
223
+ "to": "[address_A]",
224
+ "assetIndex": 31566704,
225
+ "amount": 500000,
226
+ "network": "testnet"
227
+ }
228
+ ```
229
+
230
+ ### Step 2: Assign group ID
231
+ ```
232
+ assign_group_id {
233
+ "transactions": [txn1_from_step1, txn2_from_step1]
234
+ }
235
+ ```
236
+
237
+ ### Step 3: Sign group with wallet
238
+ ```
239
+ wallet_sign_transaction_group {
240
+ "transactions": [grouped_txn1, grouped_txn2],
241
+ "network": "testnet"
242
+ }
243
+ ```
244
+
245
+ ### Step 4: Submit
246
+ ```
247
+ send_raw_transaction {
248
+ "signedTxns": ["[blob1]", "[blob2]"],
249
+ "network": "testnet"
250
+ }
251
+ ```
252
+
253
+ > Atomic groups are all-or-nothing: either all transactions succeed or none do.
254
+
255
+ ---
256
+
257
+ ## Create an ASA (Algorand Standard Asset)
258
+
259
+ ### Step 1: Create the asset
260
+ ```
261
+ make_asset_create_txn {
262
+ "from": "[creator_address]",
263
+ "total": 1000000000,
264
+ "decimals": 6,
265
+ "defaultFrozen": false,
266
+ "unitName": "MYT",
267
+ "assetName": "My Token",
268
+ "assetURL": "https://example.com/my-token",
269
+ "manager": "[creator_address]",
270
+ "reserve": "[creator_address]",
271
+ "freeze": "[creator_address]",
272
+ "clawback": "[creator_address]",
273
+ "network": "testnet"
274
+ }
275
+ ```
276
+
277
+ ### Step 2: Sign
278
+ ```
279
+ wallet_sign_transaction {
280
+ "transaction": { "...transaction from step 1..." },
281
+ "network": "testnet"
282
+ }
283
+ ```
284
+
285
+ ### Step 3: Submit
286
+ ```
287
+ send_raw_transaction {
288
+ "signedTxns": ["[base64_blob]"],
289
+ "network": "testnet"
290
+ }
291
+ ```
292
+
293
+ ### Step 4: Look up the created asset
294
+ ```
295
+ api_algod_get_pending_transaction {
296
+ "txId": "[txID_from_step_2]",
297
+ "network": "testnet"
298
+ }
299
+ ```
300
+ > The `asset-index` field in the response contains the new ASA ID.
301
+
302
+ ---
303
+
304
+ ## Deploy a Smart Contract
305
+
306
+ ### Step 1: Compile approval program
307
+ ```
308
+ compile_teal {
309
+ "source": "#pragma version 10\nint 1\nreturn",
310
+ "network": "testnet"
311
+ }
312
+ ```
313
+
314
+ ### Step 2: Compile clear program
315
+ ```
316
+ compile_teal {
317
+ "source": "#pragma version 10\nint 1\nreturn",
318
+ "network": "testnet"
319
+ }
320
+ ```
321
+
322
+ ### Step 3: Create the application
323
+ ```
324
+ make_app_create_txn {
325
+ "from": "[creator_address]",
326
+ "approvalProgram": "[base64_from_step_1]",
327
+ "clearProgram": "[base64_from_step_2]",
328
+ "numGlobalByteSlices": 1,
329
+ "numGlobalInts": 1,
330
+ "numLocalByteSlices": 0,
331
+ "numLocalInts": 0,
332
+ "network": "testnet"
333
+ }
334
+ ```
335
+
336
+ ### Step 4: Sign and submit
337
+ ```
338
+ wallet_sign_transaction {
339
+ "transaction": { "...transaction from step 3..." },
340
+ "network": "testnet"
341
+ }
342
+ ```
343
+ ```
344
+ send_raw_transaction {
345
+ "signedTxns": ["[base64_blob]"],
346
+ "network": "testnet"
347
+ }
348
+ ```
349
+
350
+ ---
351
+
352
+ ## NFD Lookup
353
+
354
+ ### Look up an NFD name
355
+ ```
356
+ api_nfd_get_nfd {
357
+ "nameOrID": "example.algo",
358
+ "view": "full",
359
+ "network": "mainnet"
360
+ }
361
+ ```
362
+
363
+ ### Get NFDs for an address
364
+ ```
365
+ api_nfd_get_nfds_for_addresses {
366
+ "address": ["ALGO_ADDRESS"],
367
+ "view": "brief",
368
+ "network": "mainnet"
369
+ }
370
+ ```
371
+
372
+ > **CRITICAL**: When sending to an NFD, always use the `depositAccount` field from the response, NOT other address fields.
373
+
374
+ ---
375
+
376
+ ## Tinyman Swap Quote
377
+
378
+ ### Get a swap quote (ALGO → USDC)
379
+ ```
380
+ api_tinyman_get_swap_quote {
381
+ "asset1Id": 0,
382
+ "asset2Id": 31566704,
383
+ "amount": 1000000,
384
+ "network": "mainnet"
385
+ }
386
+ ```
387
+ > Asset ID 0 = ALGO
388
+
389
+ ### Get pool info
390
+ ```
391
+ api_tinyman_get_pool {
392
+ "asset1Id": 0,
393
+ "asset2Id": 31566704,
394
+ "version": "v2",
395
+ "network": "mainnet"
396
+ }
397
+ ```
398
+
399
+ ---
400
+
401
+ ## Using the Knowledge Base
402
+
403
+ ### Get a specific document
404
+ ```
405
+ get_knowledge_doc {
406
+ "documents": ["arcs:specs:arc-0003.md"]
407
+ }
408
+ ```
409
+
410
+ ### Knowledge categories
411
+ - `arcs` — Algorand Request for Comments
412
+ - `sdks` — Software Development Kits
413
+ - `algokit` — AlgoKit
414
+ - `algokit-utils` — AlgoKit Utils
415
+ - `tealscript` — TEALScript
416
+ - `puya` — Puya compiler
417
+ - `liquid-auth` — Liquid Auth
418
+ - `python` — Python Development
419
+ - `developers` — Developer Documentation
420
+ - `clis` — CLI Tools
421
+ - `nodes` — Node Management
422
+ - `details` — Developer Details
423
+
424
+ ---
425
+
426
+ ## Compile and Disassemble TEAL
427
+
428
+ ### Compile TEAL
429
+ ```
430
+ compile_teal {
431
+ "source": "#pragma version 10\nint 1\nreturn",
432
+ "network": "testnet"
433
+ }
434
+ ```
435
+
436
+ ### Disassemble TEAL bytecode
437
+ ```
438
+ disassemble_teal {
439
+ "bytecode": "[base64_bytecode_from_compile]",
440
+ "network": "testnet"
441
+ }
442
+ ```
443
+
444
+ ---
445
+
446
+ ## Encode/Decode Objects (msgpack)
447
+
448
+ ### Encode to msgpack
449
+ ```
450
+ encode_obj {
451
+ "obj": { "key": "value", "num": 42 }
452
+ }
453
+ ```
454
+
455
+ ### Decode from msgpack
456
+ ```
457
+ decode_obj {
458
+ "bytes": "[base64_msgpack_string]"
459
+ }
460
+ ```
461
+
462
+ ---
463
+
464
+ ## Using External Keys (Non-Wallet Signing)
465
+
466
+ When a user provides their own secret key instead of using the wallet:
467
+
468
+ ### Step 1: Build transaction
469
+ ```
470
+ make_payment_txn {
471
+ "from": "[sender_address]",
472
+ "to": "[receiver_address]",
473
+ "amount": 1000000,
474
+ "network": "testnet"
475
+ }
476
+ ```
477
+
478
+ ### Step 2: Sign with external key
479
+ ```
480
+ sign_transaction {
481
+ "transaction": { "...transaction from step 1..." },
482
+ "sk": "[hex_encoded_secret_key]"
483
+ }
484
+ ```
485
+
486
+ ### Step 3: Submit
487
+ ```
488
+ send_raw_transaction {
489
+ "signedTxns": ["[base64_blob_from_step_2]"],
490
+ "network": "testnet"
491
+ }
492
+ ```
493
+
494
+ ---
495
+
496
+ ## Top-Up QR Code (Insufficient Funds)
497
+
498
+ When balance is insufficient, generate an ARC-26 QR code for easy funding:
499
+
500
+ ```
501
+ generate_algorand_uri {
502
+ "address": "[wallet_address]",
503
+ "amount": 5000000,
504
+ "note": "Fund account for transaction"
505
+ }
506
+ ```
507
+
508
+ The response includes a URI string and SVG QR code that can be scanned with any Algorand-compatible wallet.
509
+
510
+ ---
511
+
512
+ ## Simulate Before Submitting
513
+
514
+ ### Simulate a transaction to check for errors
515
+ ```
516
+ simulate_transactions {
517
+ "txnGroups": [ "...transaction group..." ],
518
+ "allowEmptySignatures": true,
519
+ "allowMoreLogging": true,
520
+ "network": "testnet"
521
+ }
522
+ ```
523
+
524
+ This lets you verify a transaction will succeed before actually submitting it.
525
+
526
+ ---
527
+
528
+ ## x402 Payment Workflow
529
+
530
+ When `x402_fetch` returns a 402 response, follow these steps to pay for the resource.
531
+
532
+ ### Understanding the 402 Response
533
+
534
+ The 402 response contains an `accepts` array. Each entry has:
535
+ - `scheme` — payment scheme (e.g., `"exact"`)
536
+ - `network` — CAIP-2 network identifier
537
+ - `maxAmountRequired` — amount to pay (in base units)
538
+ - `asset` — `"0"` for native ALGO, or ASA ID as string
539
+ - `payTo` — recipient address
540
+ - `extra.feePayer` — facilitator address that pays transaction fees
541
+
542
+ ### CAIP-2 Network Mapping
543
+
544
+ | CAIP-2 Identifier | Network |
545
+ |--------------------|---------|
546
+ | `algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=` | `testnet` |
547
+ | `algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=` | `mainnet` |
548
+
549
+ ### Step 1: Check wallet
550
+ ```
551
+ wallet_get_info { "network": "<network>" }
552
+ ```
553
+
554
+ ### Step 2: Build fee payer transaction
555
+
556
+ The facilitator sponsors fees for the entire group. Set `fee: 2000` (covers both transactions at 1000 each) and `flatFee: true` to prevent the SDK from overriding:
557
+ ```
558
+ make_payment_txn {
559
+ "from": "<feePayer>",
560
+ "to": "<feePayer>",
561
+ "amount": 0,
562
+ "fee": 2000,
563
+ "flatFee": true,
564
+ "network": "<network>"
565
+ }
566
+ ```
567
+
568
+ ### Step 3: Build payment transaction
569
+
570
+ The payment transaction fee is 0 since the facilitator covers it. Set `flatFee: true` to prevent the SDK from adding a fee:
571
+
572
+ **For native ALGO (asset = "0"):**
573
+ ```
574
+ make_payment_txn {
575
+ "from": "<your_address>",
576
+ "to": "<payTo>",
577
+ "amount": <maxAmountRequired>,
578
+ "fee": 0,
579
+ "flatFee": true,
580
+ "network": "<network>"
581
+ }
582
+ ```
583
+
584
+ **For ASA (asset is an ASA ID):**
585
+ ```
586
+ make_asset_transfer_txn {
587
+ "from": "<your_address>",
588
+ "to": "<payTo>",
589
+ "assetIndex": <asset>,
590
+ "amount": <maxAmountRequired>,
591
+ "fee": 0,
592
+ "flatFee": true,
593
+ "network": "<network>"
594
+ }
595
+ ```
596
+
597
+ ### Step 4: Group the transactions
598
+ ```
599
+ assign_group_id {
600
+ "transactions": [fee_payer_txn, payment_txn]
601
+ }
602
+ ```
603
+
604
+ ### Step 5: Sign ONLY the payment transaction (index 1)
605
+ ```
606
+ wallet_sign_transaction {
607
+ "transaction": <grouped_payment_txn>,
608
+ "network": "<network>"
609
+ }
610
+ ```
611
+ > Leave the fee payer transaction (index 0) unsigned — the facilitator signs it server-side.
612
+
613
+ ### Step 6: Encode the unsigned fee payer transaction
614
+
615
+ Convert the grouped fee payer transaction (index 0) to base64 bytes:
616
+ ```
617
+ encode_unsigned_transaction {
618
+ "transaction": <grouped_fee_payer_txn>
619
+ }
620
+ ```
621
+ > This produces the canonical `algosdk.encodeUnsignedTransaction()` base64 encoding needed for the PAYMENT-SIGNATURE payload.
622
+
623
+ ### Step 7: Construct the PAYMENT-SIGNATURE payload
624
+
625
+ Build this JSON string:
626
+ ```json
627
+ {
628
+ "x402Version": 2,
629
+ "scheme": "exact",
630
+ "network": "<CAIP-2 network identifier from accepts>",
631
+ "payload": {
632
+ "paymentGroup": ["<base64 from encode_unsigned_transaction>", "<base64 from wallet_sign_transaction>"],
633
+ "paymentIndex": 1
634
+ },
635
+ "accepted": <the exact accepts[] entry you chose to pay with — copy it verbatim as an object>
636
+ }
637
+ ```
638
+
639
+ > **Critical**: The `accepted` field is REQUIRED. It must be an exact copy of the `accepts[]` entry you chose (including all fields: scheme, network, price, payTo, asset, maxAmountRequired, extra, etc.). Without it, the server cannot match your payment to a requirement and will reject with 402.
640
+
641
+ ### Step 8: Retry with payment
642
+
643
+ Call `x402_fetch` again with `paymentHeader` set to the JSON string from Step 7.
644
+ The `x402_fetch` tool will base64-encode it and send it as the `PAYMENT-SIGNATURE` header.
645
+ The server verifies the payment, submits the transaction group, and returns the resource.
646
+
647
+ > **Important**: The `paymentGroup` array order must match: index 0 = unsigned fee payer txn, index 1 = signed payment txn. The `paymentIndex` indicates which transaction carries the actual payment.