@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,373 @@
1
+ # Smart Contract Errors
2
+
3
+ Common errors when building, deploying, or calling Algorand smart contracts.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Logic Eval Errors](#logic-eval-errors)
8
+ - [Assert Failed](#assert-failed)
9
+ - [Opcode Budget Exceeded](#opcode-budget-exceeded)
10
+ - [Invalid Program](#invalid-program)
11
+ - [Stack Underflow](#stack-underflow)
12
+ - [Byte/Int Type Mismatch](#byteint-type-mismatch)
13
+ - [ABI Errors](#abi-errors)
14
+ - [Method Not Found](#method-not-found)
15
+ - [ABI Encoding Error](#abi-encoding-error)
16
+ - [Return Value Decoding Error](#return-value-decoding-error)
17
+ - [State Errors](#state-errors)
18
+ - [Global State Full](#global-state-full)
19
+ - [Local State Not Opted In](#local-state-not-opted-in)
20
+ - [Box Not Found](#box-not-found)
21
+ - [Box MBR Not Met](#box-mbr-not-met)
22
+ - [Inner Transaction Errors](#inner-transaction-errors)
23
+ - [Debugging Tips](#debugging-tips)
24
+
25
+ ## Logic Eval Errors
26
+
27
+ ### Assert Failed
28
+
29
+ ```
30
+ logic eval error: assert failed pc=123
31
+ ```
32
+
33
+ **Cause:** An `assert` statement evaluated to false.
34
+
35
+ **Debug with source maps (AlgoKit Utils):**
36
+
37
+ ```typescript
38
+ // TypeScript - errors include source location automatically
39
+ try {
40
+ await appClient.send.myMethod({ args: { value: 0 } })
41
+ } catch (e) {
42
+ // Error includes: "assert failed at contracts/my_contract.py:45"
43
+ console.error(e)
44
+ }
45
+ ```
46
+
47
+ ```python
48
+ # Python - LogicError includes source map info
49
+ from algokit_utils import LogicError
50
+
51
+ try:
52
+ app_client.send.my_method(value=0)
53
+ except LogicError as e:
54
+ print(e) # Shows: assert failed at contracts/my_contract.py:45
55
+ print(e.pc) # Program counter: 123
56
+ print(e.line) # Source line number
57
+ ```
58
+
59
+ **Common causes:**
60
+ - Input validation failed (e.g., `assert amount > 0`)
61
+ - Authorization check failed (e.g., `assert Txn.sender == self.owner`)
62
+ - State precondition not met (e.g., `assert self.is_initialized`)
63
+
64
+ **Fix:** Check the assertion condition and ensure inputs satisfy it.
65
+
66
+ ### Opcode Budget Exceeded
67
+
68
+ ```
69
+ logic eval error: dynamic cost budget exceeded
70
+ ```
71
+
72
+ **Cause:** Contract exceeded the 700 opcode budget per app call.
73
+
74
+ **Budget limits:**
75
+ | Context | Budget |
76
+ |---------|--------|
77
+ | Single app call | 700 opcodes |
78
+ | Max pooled (16 app calls) | 11,200 opcodes |
79
+ | Logic signature | 20,000 opcodes |
80
+
81
+ **Solutions:**
82
+
83
+ 1. **Pool budget with extra app calls:**
84
+ ```python
85
+ # Add dummy app calls to increase budget
86
+ algorand.new_group()
87
+ .add_app_call_method_call(actual_call_params)
88
+ .add_app_call(AppCallParams(
89
+ sender=sender,
90
+ app_id=app_id,
91
+ on_complete=OnComplete.NoOp,
92
+ args=[b"noop"] # Dummy call for budget
93
+ ))
94
+ .send()
95
+ ```
96
+
97
+ 2. **Optimize expensive operations:**
98
+ ```python
99
+ # EXPENSIVE - iteration over large data
100
+ for i in range(100):
101
+ process(data[i])
102
+
103
+ # CHEAPER - batch operations or use Box storage
104
+ box_data = Box(Bytes, key=b"data")
105
+ ```
106
+
107
+ 3. **Split across multiple calls:**
108
+ ```python
109
+ # Instead of one large operation, split into phases
110
+ @arc4.abimethod
111
+ def process_phase1(self) -> None: ...
112
+
113
+ @arc4.abimethod
114
+ def process_phase2(self) -> None: ...
115
+ ```
116
+
117
+ ### Invalid Program
118
+
119
+ ```
120
+ logic eval error: invalid program
121
+ ```
122
+
123
+ **Cause:** The TEAL program is malformed or uses unsupported opcodes.
124
+
125
+ **Common causes:**
126
+ - Compiling for wrong AVM version
127
+ - Using opcodes not supported on target network
128
+ - Corrupted approval/clear program bytes
129
+
130
+ **Fix:** Ensure compilation targets the correct AVM version.
131
+
132
+ ### Stack Underflow
133
+
134
+ ```
135
+ logic eval error: stack underflow
136
+ ```
137
+
138
+ **Cause:** Operation tried to pop from empty stack.
139
+
140
+ **In Algorand Python:** This usually indicates a bug in low-level operations. Check any `op.*` calls.
141
+
142
+ ### Byte/Int Type Mismatch
143
+
144
+ ```
145
+ logic eval error: assert failed: wanted type uint64 but got []byte
146
+ ```
147
+
148
+ **Cause:** Wrong type passed to an operation.
149
+
150
+ **Common in Algorand Python:**
151
+ ```python
152
+ # INCORRECT - String where UInt64 expected
153
+ assert payment.amount == "1000000"
154
+
155
+ # CORRECT - Use proper types
156
+ assert payment.amount == UInt64(1_000_000)
157
+ ```
158
+
159
+ ## ABI Errors
160
+
161
+ ### Method Not Found
162
+
163
+ ```
164
+ error: method "foo(uint64)void" not found
165
+ ```
166
+
167
+ **Cause:** Calling a method that doesn't exist in the contract ABI.
168
+
169
+ **Fix:**
170
+ 1. Regenerate the typed client after contract changes
171
+ 2. Check the method signature matches exactly
172
+ 3. Verify the contract was deployed with the latest code
173
+
174
+ ### ABI Encoding Error
175
+
176
+ ```
177
+ ABIEncodingError: value out of range for uint64
178
+ ```
179
+
180
+ **Cause:** Value doesn't fit the ABI type.
181
+
182
+ **Examples:**
183
+ ```python
184
+ # INCORRECT - Negative value for uint64
185
+ arc4.UInt64(-1)
186
+
187
+ # INCORRECT - Value too large
188
+ arc4.UInt8(256) # Max is 255
189
+
190
+ # CORRECT - Use appropriate type
191
+ arc4.UInt64(0)
192
+ arc4.UInt16(256)
193
+ ```
194
+
195
+ ### Return Value Decoding Error
196
+
197
+ ```
198
+ error: could not decode return value
199
+ ```
200
+
201
+ **Cause:** Method returned unexpected data format.
202
+
203
+ **Common causes:**
204
+ - Contract didn't log the return value properly
205
+ - Wrong return type in client
206
+ - Transaction failed before return
207
+
208
+ **Fix:** Check contract method has correct return annotation.
209
+
210
+ ## State Errors
211
+
212
+ ### Global State Full
213
+
214
+ ```
215
+ logic eval error: store global state: failed
216
+ ```
217
+
218
+ **Cause:** Exceeded declared global state schema.
219
+
220
+ **Fix:** Increase schema in contract deployment:
221
+ ```python
222
+ class MyContract(ARC4Contract):
223
+ # Declare more state slots in schema
224
+ @arc4.abimethod(create=True)
225
+ def create(self) -> None:
226
+ pass
227
+ ```
228
+
229
+ ### Local State Not Opted In
230
+
231
+ ```
232
+ logic eval error: application APPID not opted in
233
+ ```
234
+
235
+ **Cause:** Account hasn't opted into the application.
236
+
237
+ **Fix:** Opt in before accessing local state:
238
+ ```python
239
+ algorand.send.app_call(AppCallParams(
240
+ sender=user_address,
241
+ app_id=app_id,
242
+ on_complete=OnComplete.OptIn,
243
+ ))
244
+ ```
245
+
246
+ ### Box Not Found
247
+
248
+ ```
249
+ logic eval error: box not found
250
+ ```
251
+
252
+ **Cause:** Accessing a box that doesn't exist.
253
+
254
+ **Fix:** Create box before access or check existence:
255
+ ```python
256
+ # In contract - check if box exists
257
+ if self.my_box.exists:
258
+ value = self.my_box.value
259
+ else:
260
+ self.my_box.value = default_value
261
+ ```
262
+
263
+ ### Box MBR Not Met
264
+
265
+ ```
266
+ logic eval error: box create with insufficient funds
267
+ ```
268
+
269
+ **Cause:** App account lacks funds for box minimum balance requirement.
270
+
271
+ **MBR formula:** `2500 + (400 * (key_length + value_length))` microAlgos per box
272
+
273
+ **Fix:** Fund the app account:
274
+ ```python
275
+ algorand.send.payment(PaymentParams(
276
+ sender=funder.address,
277
+ receiver=app_client.app_address,
278
+ amount=AlgoAmount(algo=1), # Cover box MBR
279
+ ))
280
+ ```
281
+
282
+ ## Inner Transaction Errors
283
+
284
+ ### Insufficient Balance for Inner Txn
285
+
286
+ ```
287
+ logic eval error: insufficient balance
288
+ ```
289
+
290
+ **Cause:** App account lacks funds for inner transaction amount.
291
+
292
+ **Fix:** Fund the app account before inner transactions:
293
+ ```python
294
+ # Fund app before calling method with inner transactions
295
+ algorand.send.payment(PaymentParams(
296
+ sender=deployer.address,
297
+ receiver=app_client.app_address,
298
+ amount=AlgoAmount(algo=5),
299
+ ))
300
+ ```
301
+
302
+ ### Inner Transaction Limit
303
+
304
+ ```
305
+ logic eval error: too many inner transactions
306
+ ```
307
+
308
+ **Cause:** Exceeded 256 inner transactions per group.
309
+
310
+ **Fix:** Split operations across multiple outer transactions.
311
+
312
+ ### App Not Opted Into Asset
313
+
314
+ ```
315
+ logic eval error: asset ASSET_ID not opted in
316
+ ```
317
+
318
+ **Cause:** Contract account isn't opted into the asset.
319
+
320
+ **Fix:** Add opt-in method to contract:
321
+ ```python
322
+ @arc4.abimethod
323
+ def opt_in_to_asset(self, asset: Asset) -> None:
324
+ itxn.AssetTransfer(
325
+ xfer_asset=asset,
326
+ asset_receiver=Global.current_application_address,
327
+ asset_amount=0,
328
+ fee=0
329
+ ).submit()
330
+ ```
331
+
332
+ ## Debugging Tips
333
+
334
+ ### Enable Debug Logging
335
+
336
+ ```typescript
337
+ // TypeScript
338
+ import { Config } from '@algorandfoundation/algokit-utils'
339
+ Config.configure({ debug: true })
340
+ ```
341
+
342
+ ```python
343
+ # Python
344
+ import logging
345
+ logging.getLogger("algokit").setLevel(logging.DEBUG)
346
+ ```
347
+
348
+ ### Get Transaction Trace
349
+
350
+ ```typescript
351
+ // Simulate to get execution trace
352
+ const result = await algorand.newGroup()
353
+ .addAppCallMethodCall(params)
354
+ .simulate({ execTraceConfig: { enable: true } })
355
+
356
+ console.log(result.simulateResponse.txnGroups[0].txnResults[0].execTrace)
357
+ ```
358
+
359
+ ### Check Program Counter Location
360
+
361
+ When you see `pc=123`, use algokit to find the source:
362
+
363
+ ```bash
364
+ algokit compile contracts/my_contract.py --output-sourcemap
365
+ ```
366
+
367
+ Then map the PC to source using the generated `.map` file.
368
+
369
+ ## References
370
+
371
+ - [Debugging Smart Contracts](https://dev.algorand.co/concepts/smart-contracts/debugging/)
372
+ - [AVM Opcodes Reference](https://dev.algorand.co/reference/teal/opcodes/)
373
+ - [Error Handling in AlgoKit](https://dev.algorand.co/algokit/utils/typescript/debugging/)