@wowok/agent-mcp 2.2.11 → 2.2.13

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 (93) hide show
  1. package/dist/docs/index.d.ts +3 -0
  2. package/dist/docs/index.js +2 -0
  3. package/dist/docs/loader.d.ts +12 -0
  4. package/dist/docs/loader.js +177 -0
  5. package/dist/docs/search.d.ts +17 -0
  6. package/dist/docs/search.js +325 -0
  7. package/dist/docs/types.d.ts +55 -0
  8. package/dist/docs/types.js +1 -0
  9. package/dist/index.d.ts +12 -0
  10. package/dist/index.js +146 -39
  11. package/docs/README.md +249 -0
  12. package/docs/WIP.md +388 -0
  13. package/docs/WTS.md +536 -0
  14. package/docs/docs/account.md +914 -0
  15. package/docs/docs/allocation.md +635 -0
  16. package/docs/docs/arbitration.md +1804 -0
  17. package/docs/docs/arbitration_state_machine.md +270 -0
  18. package/docs/docs/contact.md +709 -0
  19. package/docs/docs/demand.md +948 -0
  20. package/docs/docs/guard.md +1465 -0
  21. package/docs/docs/localinfo.md +432 -0
  22. package/docs/docs/localmark.md +583 -0
  23. package/docs/docs/machine.md +2490 -0
  24. package/docs/docs/messenger.md +2098 -0
  25. package/docs/docs/onchain_events.md +267 -0
  26. package/docs/docs/order.md +1001 -0
  27. package/docs/docs/payment.md +512 -0
  28. package/docs/docs/permission.md +1438 -0
  29. package/docs/docs/personal.md +742 -0
  30. package/docs/docs/progress.md +1748 -0
  31. package/docs/docs/query.md +467 -0
  32. package/docs/docs/repository.md +1043 -0
  33. package/docs/docs/reward.md +833 -0
  34. package/docs/docs/service.md +2130 -0
  35. package/docs/docs/stage-01-introduction.md +243 -0
  36. package/docs/docs/stage-02-trust.md +302 -0
  37. package/docs/docs/stage-03-collaboration.md +337 -0
  38. package/docs/docs/stage-04-transaction.md +277 -0
  39. package/docs/docs/stage-05-business.md +151 -0
  40. package/docs/docs/stage-06-personal.md +203 -0
  41. package/docs/docs/stage-07-query.md +572 -0
  42. package/docs/docs/stage-08-examples.md +184 -0
  43. package/docs/docs/treasury.md +1149 -0
  44. package/docs/docs/wowok_buildin_info.md +740 -0
  45. package/docs/examples/Insurance/Insurance.md +594 -0
  46. package/docs/examples/Insurance/Insurance_TestResults.md +481 -0
  47. package/docs/examples/Insurance/insurance_complete_guard_v1.json +50 -0
  48. package/docs/examples/MyShop/MyShop.md +1353 -0
  49. package/docs/examples/MyShop/MyShop_TestResults.md +1003 -0
  50. package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +1898 -0
  51. package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +1297 -0
  52. package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +743 -0
  53. package/docs/examples/MyShop_Advanced/machine_nodes.json +222 -0
  54. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +776 -0
  55. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +599 -0
  56. package/docs/examples/Travel/Travel.md +1157 -0
  57. package/docs/examples/Travel/Travel_TestResults.md +743 -0
  58. package/docs/examples/Travel/calc-weather-timestamps.js +8 -0
  59. package/docs/examples/Travel/travel_machine_v2_export.json +104 -0
  60. package/docs/examples/Travel/weather_check_guard_v1.json +51 -0
  61. package/docs/skills/WOWOK.md +650 -0
  62. package/docs/skills/onchain_operations/_common.md +406 -0
  63. package/docs/skills/onchain_operations/_index.md +196 -0
  64. package/docs/skills/onchain_operations/allocation.md +28 -0
  65. package/docs/skills/onchain_operations/arbitration.md +106 -0
  66. package/docs/skills/onchain_operations/contact.md +40 -0
  67. package/docs/skills/onchain_operations/demand.md +53 -0
  68. package/docs/skills/onchain_operations/gen_passport.md +23 -0
  69. package/docs/skills/onchain_operations/guard.md +56 -0
  70. package/docs/skills/onchain_operations/machine.md +89 -0
  71. package/docs/skills/onchain_operations/order.md +56 -0
  72. package/docs/skills/onchain_operations/payment.md +24 -0
  73. package/docs/skills/onchain_operations/permission.md +68 -0
  74. package/docs/skills/onchain_operations/personal.md +58 -0
  75. package/docs/skills/onchain_operations/progress.md +38 -0
  76. package/docs/skills/onchain_operations/repository.md +70 -0
  77. package/docs/skills/onchain_operations/reward.md +38 -0
  78. package/docs/skills/onchain_operations/service.md +78 -0
  79. package/docs/skills/onchain_operations/treasury.md +68 -0
  80. package/docs/skills/schema-account_operation.md +402 -0
  81. package/docs/skills/schema-guard2file.md +153 -0
  82. package/docs/skills/schema-local_info_operation.md +160 -0
  83. package/docs/skills/schema-local_mark_operation.md +148 -0
  84. package/docs/skills/schema-machineNode2file.md +155 -0
  85. package/docs/skills/schema-messenger_operation.md +547 -0
  86. package/docs/skills/schema-onchain_events.md +201 -0
  87. package/docs/skills/schema-onchain_table_data.md +334 -0
  88. package/docs/skills/schema-query_toolkit.md +395 -0
  89. package/docs/skills/schema-wip_file.md +240 -0
  90. package/docs/skills/schema-wowok_buildin_info.md +296 -0
  91. package/docs/wip-examples/three_body.html +57 -0
  92. package/docs/wip-examples/three_body.wip +30 -0
  93. package/package.json +3 -2
@@ -0,0 +1,1149 @@
1
+
2
+ # Treasury Component (💰 Team Fund Vault Management)
3
+
4
+ ---
5
+
6
+ ## Component Overview
7
+
8
+ The Treasury component is used to create and manage team fund vaults, set deposit/withdrawal rules, etc. Treasury supports two operation modes: permission management through Permission objects, or verification through external Guard objects.
9
+
10
+ ---
11
+
12
+ ## Function List
13
+
14
+ | Function Name | Purpose | Usage Scenario | Significance |
15
+ |---------------|---------|----------------|-------------|
16
+ | **Create Treasury** | Establish new fund vault with access controls | Set up team budget vaults, project fund pools | Creates secure on-chain treasury with permission management |
17
+ | **Deposit Funds** | Add assets to Treasury balance | Contribute to team funds, deposit project budgets | Fills the treasury balance pool |
18
+ | **Withdraw Funds** | Remove assets from Treasury balance | Pay expenses, distribute bonuses, allocate funds | Releases funds from treasury to recipients |
19
+ | **Manage Deposit Guards** | Configure external Guard verification for deposits | Allow public deposits, controlled external contributions | Enables permissionless deposits with Guard validation |
20
+ | **Manage Withdrawal Guards** | Configure external Guard verification for withdrawals | Enable automated payouts, controlled external withdrawals | Enables permissionless withdrawals with Guard validation |
21
+ | **Receive Assets** | Process received CoinWrapper objects | Deposit incoming payments, collect fees | Automatically adds received assets to treasury balance |
22
+ | **Owner Receive** | Unwrap and send received assets to owner | Forward received tokens, process incoming payments | Delivers received assets to permission owner |
23
+
24
+ ---
25
+
26
+ ## Complete Tool Call Structure
27
+
28
+ Treasury operations use the following top-level structure:
29
+
30
+ ```json
31
+ {
32
+ "operation_type": "treasury",
33
+ "data": { ... }, // Treasury data definition
34
+ "env": { ... }, // Execution environment (optional)
35
+ "submission": { ... } // Submission data (optional)
36
+ }
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Schema Tree
42
+
43
+ ```
44
+ treasury (Treasury Object)
45
+ ├── operation_type: "treasury" (fixed value)
46
+ ├── data (Treasury data definition)
47
+ │ ├── object (object definition, required)
48
+ │ │ ├── name|id (reference existing object)
49
+ │ │ └── name|tags|type_parameter|permission (create new object)
50
+ │ ├── description (description, optional)
51
+ │ ├── receive (receive CoinWrapper, optional)
52
+ │ │ ├── Option 1: "recently" (string) - receive all recently received
53
+ │ │ └── Option 2: { balance, token_type, received } - specify received balance
54
+ │ │ ├── balance (number or string)
55
+ │ │ ├── token_type (string) - token type like "CoinWrapper<0x2::wow::WOW>"
56
+ │ │ └── received (array) - received CoinWrapper object records
57
+ │ │ └── [{ id: string, balance: number, payment: string }]
58
+ │ ├── deposit (deposit, optional)
59
+ │ │ ├── coin (asset, required)
60
+ │ │ │ ├── Option 1: { balance: number } - specify amount
61
+ │ │ │ └── Option 2: { coin: string } - use specified Coin object ID
62
+ │ │ ├── by_external_deposit_guard (string, optional) - Guard ID for external verification
63
+ │ │ ├── payment_info (required)
64
+ │ │ │ ├── for_object (string or null, optional) - Payment for a specific object ID
65
+ │ │ │ ├── for_guard (string or null, optional) - Payment to satisfy verification of a Guard object
66
+ │ │ │ ├── remark (string) - Payment record remark
67
+ │ │ │ └── index (number or string) - Payment record index
68
+ │ │ └── namedNewPayment (object, optional) - Create new Payment object after deposit
69
+ │ │ └── name (string, optional) - Name for the new Payment object
70
+ │ ├── withdraw (withdrawal, optional)
71
+ │ │ ├── amount (amount, required)
72
+ │ │ │ ├── Option 1: { fixed: number|string } - Fixed withdrawal amount (Permission only)
73
+ │ │ │ └── Option 2: { by_external_withdraw_guard: string } - Guard-verified withdrawal
74
+ │ │ ├── recipient (AccountOrMark_Address object, required) - Recipient ID
75
+ │ │ ├── payment_info (required)
76
+ │ │ │ ├── for_object (string or null, optional) - Payment for a specific object ID
77
+ │ │ │ ├── for_guard (string or null, optional) - Payment to satisfy verification of a Guard object
78
+ │ │ │ ├── remark (string) - Payment record remark
79
+ │ │ │ └── index (number or string) - Payment record index
80
+ │ │ └── namedNewPayment (object, optional) - Create new Payment object after withdrawal
81
+ │ │ └── name (string, optional) - Name for the new Payment object
82
+ │ ├── external_deposit_guard (optional)
83
+ │ │ ├── op (string) - Operation type: "add", "set", "remove", "clear"
84
+ │ │ └── guards (array, required for add/set/remove)
85
+ │ │ ├── For add/set: AmountFromDepositGuard
86
+ │ │ │ ├── guard (string) - Guard object ID or name
87
+ │ │ │ ├── identifier (number or null, optional) - Guard Table data index for amount
88
+ │ │ │ └── store_from_id (number or null, optional) - Guard table index for record storage
89
+ │ │ └── For remove: NameOrAddress (string) - Guard object ID or name only
90
+ │ ├── external_withdraw_guard (optional)
91
+ │ │ ├── op (string) - Operation type: "add", "set", "remove", "clear"
92
+ │ │ └── guards (array, required for add/set/remove)
93
+ │ │ ├── For add/set: AmountFromWithdrawGuard
94
+ │ │ │ ├── guard (string) - Guard object ID or name
95
+ │ │ │ ├── identifier (number, required) - Guard Table data index for amount
96
+ │ │ │ └── store_from_id (number or null, optional) - Guard table index for record storage
97
+ │ │ └── For remove: NameOrAddress (string) - Guard object ID or name only
98
+ │ ├── owner_receive (transfer received coins or NFT objects to owner, optional)
99
+ │ │ ├── Option 1: "recently" (string) - receive all recent objects
100
+ │ │ ├── Option 2: Array of received objects
101
+ │ │ │ └── [{ id: "object_id", type: "object_type" }]
102
+ │ │ └── Option 3: Received balance object
103
+ │ │ ├── balance (number or string)
104
+ │ │ ├── token_type (string)
105
+ │ │ └── received (array of received items)
106
+ │ └── um (Contact object, optional)
107
+ │ ├── Option 1: NamedObject (object) - create a named Contact object
108
+ │ │ ├── name (string, optional) - Contact object name
109
+ │ │ ├── tags (string[], optional) - object tags
110
+ │ │ ├── onChain (boolean, optional) - sync name to chain
111
+ │ │ └── replaceExistName (boolean, optional) - overwrite existing
112
+ │ └── Option 2: null (to unbind contact)
113
+ ├── env (optional, execution environment)
114
+ │ ├── account (string, optional) - account name or address, empty string for default
115
+ │ ├── network (string, optional) - "testnet" or "localnet"
116
+ │ ├── permission_guard (array, optional) - list of permission guard IDs
117
+ │ ├── no_cache (boolean, optional) - disable caching
118
+ │ └── referrer (string, optional) - referrer ID
119
+ └── submission (optional, submission data)
120
+ ├── type (string) - fixed value "submission"
121
+ ├── guard (array) - list of guards to verify
122
+ │ └── [{ object: "guard_id", impack: boolean }]
123
+ └── submission (array) - submission data for guards
124
+ └── [{ guard: "guard_id", submission: [guard_submission_items] }]
125
+ └── guard_submission_items
126
+ ├── identifier (number, 0-255) - Guard table item identifier
127
+ ├── b_submission (boolean) - whether this item requires submission
128
+ ├── value_type (number | string) - value type (e.g., 6 or "U64" for U64 type)
129
+ ├── **value (any) - submitted value**
130
+ └── name (string, optional) - item name
131
+ ```
132
+
133
+ ---
134
+
135
+ ### ⚠️ Important Note About Submission
136
+
137
+ If the execution returns a `submission` field in the response, it indicates that additional Guard verification data is required. You must:
138
+
139
+ 1. Complete all required submission data within the `submission` structure
140
+ 2. Resubmit the operation with the completed submission data
141
+ 3. **Do not modify any other parts of the structure** - only fill in the required submission values
142
+
143
+ The submission structure will specify which Guard objects need verification and what data needs to be provided for each Guard table item.
144
+
145
+ **Query Value Types**: Use the `wowok_buildin_info` tool with `{ "info": "value types" }` to query all supported value types with their numeric and string representations. This helps you understand what `value_type` values are valid for submission data.
146
+
147
+ ---
148
+
149
+ ## ⚠️ Critical Constraints and Error Codes
150
+
151
+ ### Error Code Reference
152
+
153
+ | Error Code | Constant | Description | Solution |
154
+ |------------|----------|-------------|----------|
155
+ | 5 | `E_IDENTIFIER_NOT_NUMBER_TYPE` | Guard identifier is not a numeric type | Ensure Guard table identifier uses U64 type, not Bool or other types |
156
+ | 6 | `E_DEPOSIT_INSUFFICIENT_AMOUNT` | Deposit amount is less than Guard required minimum | Deposit amount must be >= Guard identifier value |
157
+ | 7 | `E_WITHDRAW_INSUFFICIENT_AMOUNT` | Treasury balance is insufficient for withdrawal | Ensure Treasury has sufficient balance before withdrawal |
158
+
159
+ ### External Guard Requirements
160
+
161
+ When using external Guards for deposit/withdrawal:
162
+
163
+ 1. **Guard Type Requirements**:
164
+ - Guard's table identifier **must be U64 type** (not Bool, String, etc.)
165
+ - The identifier value represents the **maximum allowed amount** for the operation
166
+
167
+ 2. **Guard Creation Example**:
168
+ ```json
169
+ {
170
+ "operation_type": "guard",
171
+ "data": {
172
+ "namedNew": { "name": "my_guard" },
173
+ "table": [{ "identifier": 0, "b_submission": false, "value_type": "U64", "value": 1000000000 }],
174
+ "root": { "type": "node", "node": { "type": "logic_as_u256_greater_or_equal", "nodes": [...] } }
175
+ }
176
+ }
177
+ ```
178
+
179
+ 3. **Amount Constraints**:
180
+ - For deposit: `deposit.coin.balance` must be **>=** Guard's identifier value
181
+ - For withdrawal: Guard's identifier value specifies the **exact** withdrawal amount
182
+
183
+ ---
184
+
185
+ ## Sub-feature 1: Create New Treasury
186
+
187
+ ### Feature Description
188
+
189
+ Create a new Treasury object, can simultaneously create a new Permission object or reference an existing Permission.
190
+
191
+ ### Parameter Description
192
+
193
+ | Parameter Path | Type | Required | Description | Constraints |
194
+ |----------|------|------|------|------|
195
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
196
+ | `data.object` | object or string | Yes | Object definition | TypedPermissionObject |
197
+ | `data.description` | string | No | Treasury description | Max 4000 BCS characters |
198
+ | `env.account` | string | No | Use specified account | Empty string '' uses default account |
199
+ | `env.network` | enum | No | Network selection | "localnet" or "testnet" |
200
+
201
+ ### Important Notes
202
+
203
+ ⚠️ **Permission Object**: Treasury requires Permission to manage permissions, can create new or reference existing.
204
+
205
+ ⚠️ **External Guard**: Can set external verification rules through `external_deposit_guard` and `external_withdraw_guard`, allowing non-permission users to deposit/withdraw through Guard verification.
206
+
207
+ ---
208
+
209
+ ### Examples
210
+
211
+ #### Example 1.1: Create Minimal Treasury (name only)
212
+
213
+ **Prompt**: Create a Treasury named "team_treasury", use default account and network, no other configuration specified.
214
+
215
+ ```json
216
+ {
217
+ "operation_type": "treasury",
218
+ "data": {
219
+ "object": {
220
+ "name": "team_treasury"
221
+ }
222
+ },
223
+ "env": {
224
+ "network": "testnet"
225
+ }
226
+ }
227
+ ```
228
+
229
+ **Execution Result**:
230
+ ```json
231
+ {
232
+ "status": "success",
233
+ "objects": [
234
+ {
235
+ "type": "Permission",
236
+ "object": "0x53ad...08e7",
237
+ "version": "244384",
238
+ "change": "created"
239
+ },
240
+ {
241
+ "type": "Treasury",
242
+ "object": "0xbf0f...6249",
243
+ "version": "244384",
244
+ "change": "created"
245
+ }
246
+ ]
247
+ }
248
+ ```
249
+
250
+ ---
251
+
252
+ #### Example 1.2: Create Treasury with Tags
253
+
254
+ **Prompt**: Create a Treasury named "project_fund", add tags "project", "finance", and description "Project fund treasury for managing team finances".
255
+
256
+ ```json
257
+ {
258
+ "operation_type": "treasury",
259
+ "data": {
260
+ "object": {
261
+ "name": "project_fund",
262
+ "tags": ["project", "finance"]
263
+ },
264
+ "description": "Project fund treasury for managing team finances"
265
+ },
266
+ "env": {
267
+ "network": "testnet"
268
+ }
269
+ }
270
+ ```
271
+
272
+ **Execution Result**:
273
+ ```json
274
+ {
275
+ "status": "success",
276
+ "objects": [
277
+ {
278
+ "type": "Treasury",
279
+ "object": "0x20fd...393a",
280
+ "version": "251892",
281
+ "change": "created"
282
+ },
283
+ {
284
+ "type": "Permission",
285
+ "object": "0x677f...0767",
286
+ "version": "251892",
287
+ "change": "created"
288
+ }
289
+ ]
290
+ }
291
+ ```
292
+
293
+ ---
294
+
295
+ #### Example 1.3: Create Treasury and Set External Guards
296
+
297
+ **Prompt**: Create a Treasury named "community_fund", set external deposit Guard and external withdrawal Guard, allowing deposit/withdrawal operations through Guard verification.
298
+
299
+ ```json
300
+ {
301
+ "operation_type": "treasury",
302
+ "data": {
303
+ "object": {
304
+ "name": "community_fund",
305
+ "tags": ["community", "fund"]
306
+ },
307
+ "description": "Community fund treasury with external Guard access",
308
+ "external_deposit_guard": {
309
+ "op": "add",
310
+ "guards": [
311
+ {
312
+ "guard": "deposit_guard_u64",
313
+ "identifier": 0
314
+ }
315
+ ]
316
+ },
317
+ "external_withdraw_guard": {
318
+ "op": "add",
319
+ "guards": [
320
+ {
321
+ "guard": "withdraw_guard_u64",
322
+ "identifier": 0
323
+ }
324
+ ]
325
+ }
326
+ },
327
+ "env": {
328
+ "network": "testnet"
329
+ }
330
+ }
331
+ ```
332
+
333
+ **Execution Result**:
334
+ ```json
335
+ {
336
+ "status": "success",
337
+ "objects": [
338
+ {
339
+ "type": "Permission",
340
+ "object": "0x163e...c6a8",
341
+ "version": "258393",
342
+ "change": "created"
343
+ },
344
+ {
345
+ "type": "Treasury",
346
+ "object": "0x5b1a...3dbf",
347
+ "version": "258393",
348
+ "change": "created"
349
+ }
350
+ ]
351
+ }
352
+ ```
353
+
354
+ > **Important Constraints**:
355
+ > - Guard's table identifier must be **U64 type** . Error code 5 (`E_IDENTIFIER_NOT_NUMBER_TYPE`) will be returned if using non-numeric types
356
+ > - The identifier value in Guard table represents the **maximum allowed amount** for deposit/withdrawal
357
+
358
+ ---
359
+
360
+ ## Sub-feature 2: Deposit
361
+
362
+ ### Feature Description
363
+
364
+ Deposit assets into Treasury, supports verification through Permission or external Guard.
365
+
366
+ ### Parameter Description
367
+
368
+ | Parameter Path | Type | Required | Description | Constraints |
369
+ |----------|------|------|------|------|
370
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
371
+ | `data.object` | string | Yes | Treasury name or ID | |
372
+ | `data.deposit.coin` | object | Yes | Asset to deposit | { balance: number } or { coin: string } |
373
+ | `data.deposit.by_external_deposit_guard` | string | No | External Guard verification | Guard object ID or name |
374
+ | `data.deposit.payment_info` | object | Yes | Payment information | |
375
+ | `data.deposit.namedNewPayment` | object | No | Create new Payment object | |
376
+
377
+ ### Important Notes
378
+
379
+ ⚠️ **Two Deposit Methods**:
380
+ - Deposit through Permission (default, requires permission)
381
+ - Deposit through external Guard verification (use `by_external_deposit_guard`)
382
+
383
+ ---
384
+
385
+ ### Examples
386
+
387
+ #### Example 2.1: Deposit through Permission
388
+
389
+ **Prompt**: Deposit 100 WOW into "team_treasury", operate through Permission.
390
+
391
+ ```json
392
+ {
393
+ "operation_type": "treasury",
394
+ "data": {
395
+ "object": "team_treasury",
396
+ "deposit": {
397
+ "coin": {
398
+ "balance": 100000000000
399
+ },
400
+ "payment_info": {
401
+ "remark": "treasury operation",
402
+ "index": 1
403
+ }
404
+ }
405
+ },
406
+ "env": {
407
+ "network": "testnet"
408
+ }
409
+ }
410
+ ```
411
+
412
+ **Execution Result**:
413
+ ```json
414
+ {
415
+ "status": "success",
416
+ "objects": [
417
+ {
418
+ "type": "Treasury",
419
+ "object": "0xbf0f...6249",
420
+ "version": "244617",
421
+ "change": "mutated"
422
+ }
423
+ ]
424
+ }
425
+ ```
426
+
427
+ ---
428
+
429
+ #### Example 2.2: Deposit through External Guard
430
+
431
+ **Prompt**: Deposit 10 WOW into "community_fund", verify through external Guard "deposit_guard_u64", simultaneously create a Payment object named "deposit_payment".
432
+
433
+ ```json
434
+ {
435
+ "operation_type": "treasury",
436
+ "data": {
437
+ "object": "community_fund",
438
+ "deposit": {
439
+ "coin": {
440
+ "balance": 1000000000
441
+ },
442
+ "by_external_deposit_guard": "deposit_guard_u64",
443
+ "payment_info": {
444
+ "remark": "treasury operation",
445
+ "index": 1
446
+ },
447
+ "namedNewPayment": {
448
+ "name": "deposit_payment"
449
+ }
450
+ }
451
+ },
452
+ "env": {
453
+ "network": "testnet"
454
+ }
455
+ }
456
+ ```
457
+
458
+ **Execution Result**:
459
+ ```json
460
+ {
461
+ "status": "success",
462
+ "objects": [
463
+ {
464
+ "type": "Treasury",
465
+ "object": "0x5b1a...3dbf",
466
+ "version": "259562",
467
+ "change": "mutated"
468
+ },
469
+ {
470
+ "type": "Payment",
471
+ "object": "0x53a4...f121",
472
+ "change": "created"
473
+ }
474
+ ]
475
+ }
476
+ ```
477
+
478
+ > **Important Constraints**:
479
+ > - Deposit amount **must be >=** the value specified in Guard's identifier. Error code 6 (`E_DEPOSIT_INSUFFICIENT_AMOUNT`) will be returned if amount is insufficient
480
+ > - Guard verification creates a Payment object as transaction record
481
+ > - The `namedNewPayment` field allows naming the Payment object for later reference
482
+
483
+ ---
484
+
485
+ ## Sub-feature 3: Withdrawal
486
+
487
+ ### Feature Description
488
+
489
+ Withdraw assets from Treasury, supports fixed amount withdrawal through Permission, or withdrawal through external Guard verification.
490
+
491
+ ### Parameter Description
492
+
493
+ | Parameter Path | Type | Required | Description | Constraints |
494
+ |----------|------|------|------|------|
495
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
496
+ | `data.object` | string | Yes | Treasury name or ID | |
497
+ | `data.withdraw.amount` | object | Yes | Withdrawal amount | { fixed: number } or { by_external_withdraw_guard: string } |
498
+ | `data.withdraw.recipient` | object | Yes | Recipient | AccountOrMark_Address object |
499
+ | `data.withdraw.payment_info` | object | Yes | Payment information | |
500
+ | `data.withdraw.namedNewPayment` | object | No | Create new Payment object | |
501
+
502
+ ### Important Notes
503
+
504
+ ⚠️ **Two Withdrawal Methods**:
505
+ - Fixed amount withdrawal: Set through `amount.fixed`, must go through Permission
506
+ - Guard verification withdrawal: Set through `amount.by_external_withdraw_guard`, amount obtained from Guard table data
507
+
508
+ ⚠️ **Balance Requirements**:
509
+ - **Deposit**: Ensure account has sufficient WOW token balance to deposit
510
+ - **Withdraw**: Ensure Treasury has sufficient balance (greater than withdrawal amount). Error code 7 (`E_WITHDRAW_INSUFFICIENT_AMOUNT`) indicates insufficient Treasury balance
511
+ - Use `faucet` to obtain testnet WOW tokens for testing
512
+
513
+ ---
514
+
515
+ ### Examples
516
+
517
+ #### Example 3.1: Fixed Amount Withdrawal through Permission
518
+
519
+ **Prompt**: Withdraw 50 WOW from "team_treasury", through Permission, send to alice.
520
+
521
+ ```json
522
+ {
523
+ "operation_type": "treasury",
524
+ "data": {
525
+ "object": "team_treasury",
526
+ "withdraw": {
527
+ "amount": {
528
+ "fixed": 50000000000
529
+ },
530
+ "recipient": {
531
+ "name_or_address": "alice"
532
+ },
533
+ "payment_info": {
534
+ "remark": "treasury operation",
535
+ "index": 1
536
+ }
537
+ }
538
+ },
539
+ "env": {
540
+ "network": "testnet"
541
+ }
542
+ }
543
+ ```
544
+
545
+ **Execution Result** (after faucet and deposit):
546
+ ```json
547
+ {
548
+ "status": "success",
549
+ "objects": [
550
+ {
551
+ "type": "Treasury",
552
+ "object": "0xbf0f...6249",
553
+ "version": "249816",
554
+ "change": "mutated"
555
+ },
556
+ {
557
+ "type": "WReceivedObject",
558
+ "object": "0x7de4...7f82",
559
+ "change": "created",
560
+ "owner": "alice_address"
561
+ },
562
+ {
563
+ "type": "Payment",
564
+ "object": "0xfd7c...816e",
565
+ "change": "created"
566
+ }
567
+ ]
568
+ }
569
+ ```
570
+
571
+ > **Note**: Withdrawal creates a Payment object containing the withdrawn funds. The recipient needs to call `owner_receive` on the Treasury or query their received objects to access the funds.
572
+
573
+ ---
574
+
575
+ #### Example 3.2: Withdrawal through External Guard
576
+
577
+ **Prompt**: Withdraw from "community_fund", verify through external Guard "withdraw_guard_u64", send to bob, simultaneously create Payment object.
578
+
579
+ ```json
580
+ {
581
+ "operation_type": "treasury",
582
+ "data": {
583
+ "object": "community_fund",
584
+ "withdraw": {
585
+ "amount": {
586
+ "by_external_withdraw_guard": "withdraw_guard_u64"
587
+ },
588
+ "recipient": {
589
+ "name_or_address": "bob"
590
+ },
591
+ "payment_info": {
592
+ "remark": "treasury operation",
593
+ "index": 1
594
+ },
595
+ "namedNewPayment": {
596
+ "name": "withdraw_payment"
597
+ }
598
+ }
599
+ },
600
+ "env": {
601
+ "network": "testnet"
602
+ }
603
+ }
604
+ ```
605
+
606
+ **Execution Result**:
607
+ ```json
608
+ {
609
+ "status": "success",
610
+ "objects": [
611
+ {
612
+ "type": "Treasury",
613
+ "object": "0x5b1a...3dbf",
614
+ "version": "264087",
615
+ "change": "mutated"
616
+ },
617
+ {
618
+ "type": "WReceivedObject",
619
+ "object": "0x1094...a712",
620
+ "change": "created",
621
+ "owner": "bob_address"
622
+ },
623
+ {
624
+ "type": "Payment",
625
+ "object": "0x3198...b46e",
626
+ "change": "created"
627
+ }
628
+ ]
629
+ }
630
+ ```
631
+
632
+ > **Important Constraints**:
633
+ > - Withdrawal amount is **determined by Guard's identifier value**, not specified in the request
634
+ > - The Guard's identifier value (e.g., 500000000) becomes the exact withdrawal amount
635
+ > - Treasury must have sufficient balance to cover the Guard-specified amount
636
+
637
+ ---
638
+
639
+ ## Sub-feature 4: Manage External Deposit Guard
640
+
641
+ ### Feature Description
642
+
643
+ Manage Treasury's external deposit Guard list, supports add, set, remove, clear operations.
644
+
645
+ ### Parameter Description
646
+
647
+ | Parameter Path | Type | Required | Description | Constraints |
648
+ |----------|------|------|------|------|
649
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
650
+ | `data.object` | string | Yes | Treasury name or ID | |
651
+ | `data.external_deposit_guard.op` | string | Yes | Operation type | "add", "set", "remove", "clear" |
652
+ | `data.external_deposit_guard.guards` | array | No | Guard list | Required for add/set/remove |
653
+
654
+ ### AmountFromDepositGuard Structure
655
+
656
+ | Field | Type | Required | Description |
657
+ |-------|------|------|------|
658
+ | `guard` | string | Yes | Guard object ID or name |
659
+ | `identifier` | number or null | No | Guard Table data index, whose corresponding value is the storable amount. If null, deposit amount is unlimited |
660
+ | `store_from_id` | number or null | No | Guard table data index for record storage. The value at this index (address or number, including submitted values) will be stored in the record for Guard verification purposes, such as controlling operation frequency |
661
+
662
+ ### Important Notes
663
+
664
+ ⚠️ **External Guard Function**: Allows non-Permission users to deposit through Guard verification.
665
+
666
+ ⚠️ **identifier Parameter**: Corresponds to data index in Guard table, its value is depositable amount, null means unlimited.
667
+
668
+ ---
669
+
670
+ ### Examples
671
+
672
+ #### Example 4.1: Add External Deposit Guard
673
+
674
+ **Prompt**: Add external deposit Guard "deposit_guard_u64" to "team_treasury", identifier is 0, meaning depositable amount obtained from Guard table index 0.
675
+
676
+ ```json
677
+ {
678
+ "operation_type": "treasury",
679
+ "data": {
680
+ "object": "team_treasury",
681
+ "external_deposit_guard": {
682
+ "op": "add",
683
+ "guards": [
684
+ {
685
+ "guard": "deposit_guard_u64",
686
+ "identifier": 0
687
+ }
688
+ ]
689
+ }
690
+ },
691
+ "env": {
692
+ "network": "testnet"
693
+ }
694
+ }
695
+ ```
696
+
697
+ **Execution Result**:
698
+ ```json
699
+ {
700
+ "status": "success",
701
+ "objects": [
702
+ {
703
+ "type": "Treasury",
704
+ "object": "0xbf0f...6249",
705
+ "version": "265240",
706
+ "change": "mutated"
707
+ }
708
+ ]
709
+ }
710
+ ```
711
+
712
+ ---
713
+
714
+ #### Example 4.2: Add Unlimited Deposit Guard
715
+
716
+ **Prompt**: Add external deposit Guard "unlimited_deposit", identifier is null, meaning unlimited deposit amount.
717
+
718
+ ```json
719
+ {
720
+ "operation_type": "treasury",
721
+ "data": {
722
+ "object": "community_fund",
723
+ "external_deposit_guard": {
724
+ "op": "add",
725
+ "guards": [
726
+ {
727
+ "guard": "unlimited_deposit",
728
+ "identifier": null
729
+ }
730
+ ]
731
+ }
732
+ }
733
+ }
734
+ ```
735
+
736
+ ---
737
+
738
+ #### Example 4.3: Set External Deposit Guard (Replace)
739
+
740
+ **Prompt**: Set "community_fund" external deposit Guard list, replace existing list, only keep "new_deposit_guard".
741
+
742
+ ```json
743
+ {
744
+ "operation_type": "treasury",
745
+ "data": {
746
+ "object": "community_fund",
747
+ "external_deposit_guard": {
748
+ "op": "set",
749
+ "guards": [
750
+ {
751
+ "guard": "new_deposit_guard",
752
+ "identifier": 1
753
+ }
754
+ ]
755
+ }
756
+ }
757
+ }
758
+ ```
759
+
760
+ ---
761
+
762
+ #### Example 4.4: Remove External Deposit Guard
763
+
764
+ **Prompt**: Remove external deposit Guard named "deposit_guard_u64" from "community_fund".
765
+
766
+ ```json
767
+ {
768
+ "operation_type": "treasury",
769
+ "data": {
770
+ "object": "community_fund",
771
+ "external_deposit_guard": {
772
+ "op": "remove",
773
+ "guards": ["deposit_guard_u64"]
774
+ }
775
+ },
776
+ "env": {
777
+ "network": "testnet"
778
+ }
779
+ }
780
+ ```
781
+
782
+ **Execution Result**:
783
+ ```json
784
+ {
785
+ "status": "success",
786
+ "objects": [
787
+ {
788
+ "type": "Treasury",
789
+ "object": "0x5b1a...3dbf",
790
+ "version": "265243",
791
+ "change": "mutated"
792
+ }
793
+ ]
794
+ }
795
+ ```
796
+
797
+ ---
798
+
799
+ #### Example 4.5: Clear External Deposit Guard
800
+
801
+ **Prompt**: Clear all external deposit Guards of "team_treasury".
802
+
803
+ ```json
804
+ {
805
+ "operation_type": "treasury",
806
+ "data": {
807
+ "object": "team_treasury",
808
+ "external_deposit_guard": {
809
+ "op": "clear"
810
+ }
811
+ },
812
+ "env": {
813
+ "network": "testnet"
814
+ }
815
+ }
816
+ ```
817
+
818
+ **Execution Result**:
819
+ ```json
820
+ {
821
+ "status": "success",
822
+ "objects": [
823
+ {
824
+ "type": "Treasury",
825
+ "object": "0xbf0f...6249",
826
+ "version": "265241",
827
+ "change": "mutated"
828
+ }
829
+ ]
830
+ }
831
+ ```
832
+
833
+ ---
834
+
835
+ ## Sub-feature 5: Manage External Withdrawal Guard
836
+
837
+ ### Feature Description
838
+
839
+ Manage Treasury's external withdrawal Guard list, supports add, set, remove, clear operations.
840
+
841
+ ### Parameter Description
842
+
843
+ | Parameter Path | Type | Required | Description | Constraints |
844
+ |----------|------|------|------|------|
845
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
846
+ | `data.object` | string | Yes | Treasury name or ID | |
847
+ | `data.external_withdraw_guard.op` | string | Yes | Operation type | "add", "set", "remove", "clear" |
848
+ | `data.external_withdraw_guard.guards` | array | No | Guard list | Required for add/set/remove |
849
+
850
+ ### AmountFromWithdrawGuard Structure
851
+
852
+ | Field | Type | Required | Description |
853
+ |-------|------|------|------|
854
+ | `guard` | string | Yes | Guard object ID or name |
855
+ | `identifier` | number | Yes | Guard Table data index, whose corresponding value is the withdrawable amount |
856
+ | `store_from_id` | number or null | No | Guard table data index for record storage. The value at this index (address or number, including submitted values) will be stored in the record for Guard verification purposes, such as controlling operation frequency |
857
+
858
+ ### Important Notes
859
+
860
+ ⚠️ **External Guard Function**: Allows non-Permission users to withdraw through Guard verification.
861
+
862
+ ⚠️ **identifier Parameter**: Corresponds to data index in Guard table, its value is withdrawable amount.
863
+
864
+ ---
865
+
866
+ ### Examples
867
+
868
+ #### Example 5.1: Add External Withdrawal Guard
869
+
870
+ **Prompt**: Add external withdrawal Guard "approved_withdraw_guard" to "community_fund", identifier is 1, meaning withdrawable amount obtained from Guard table index 1.
871
+
872
+ ```json
873
+ {
874
+ "operation_type": "treasury",
875
+ "data": {
876
+ "object": "community_fund",
877
+ "external_withdraw_guard": {
878
+ "op": "add",
879
+ "guards": [
880
+ {
881
+ "guard": "approved_withdraw_guard",
882
+ "identifier": 1
883
+ }
884
+ ]
885
+ }
886
+ }
887
+ }
888
+ ```
889
+
890
+ ---
891
+
892
+ #### Example 5.2: Set External Withdrawal Guard (Replace)
893
+
894
+ **Prompt**: Set "community_fund" external withdrawal Guard list, replace existing list.
895
+
896
+ ```json
897
+ {
898
+ "operation_type": "treasury",
899
+ "data": {
900
+ "object": "community_fund",
901
+ "external_withdraw_guard": {
902
+ "op": "set",
903
+ "guards": [
904
+ {
905
+ "guard": "new_withdraw_guard",
906
+ "identifier": 2
907
+ }
908
+ ]
909
+ }
910
+ }
911
+ }
912
+ ```
913
+
914
+ ---
915
+
916
+ #### Example 5.3: Remove External Withdrawal Guard
917
+
918
+ **Prompt**: Remove external withdrawal Guard named "withdraw_guard_u64" from "community_fund".
919
+
920
+ ```json
921
+ {
922
+ "operation_type": "treasury",
923
+ "data": {
924
+ "object": "community_fund",
925
+ "external_withdraw_guard": {
926
+ "op": "remove",
927
+ "guards": ["withdraw_guard_u64"]
928
+ }
929
+ },
930
+ "env": {
931
+ "network": "testnet"
932
+ }
933
+ }
934
+ ```
935
+
936
+ **Execution Result**:
937
+ ```json
938
+ {
939
+ "status": "success",
940
+ "objects": [
941
+ {
942
+ "type": "Treasury",
943
+ "object": "0x5b1a...3dbf",
944
+ "version": "265244",
945
+ "change": "mutated"
946
+ }
947
+ ]
948
+ }
949
+ ```
950
+
951
+ ---
952
+
953
+ #### Example 5.4: Clear External Withdrawal Guard
954
+
955
+ **Prompt**: Clear all external withdrawal Guards of "team_treasury".
956
+
957
+ ```json
958
+ {
959
+ "operation_type": "treasury",
960
+ "data": {
961
+ "object": "team_treasury",
962
+ "external_withdraw_guard": {
963
+ "op": "clear"
964
+ }
965
+ },
966
+ "env": {
967
+ "network": "testnet"
968
+ }
969
+ }
970
+ ```
971
+
972
+ **Execution Result**:
973
+ ```json
974
+ {
975
+ "status": "success",
976
+ "objects": [
977
+ {
978
+ "type": "Treasury",
979
+ "object": "0xbf0f...6249",
980
+ "version": "265242",
981
+ "change": "mutated"
982
+ }
983
+ ]
984
+ }
985
+ ```
986
+
987
+ ---
988
+
989
+ ## Sub-feature 6: Receive and Manage Received Assets
990
+
991
+ ### Feature Description
992
+
993
+ Process CoinWrapper objects received by Treasury, can deposit to balance or unwrap and send to Permission owner.
994
+
995
+ ### Parameter Description
996
+
997
+ | Parameter Path | Type | Required | Description | Constraints |
998
+ |----------|------|------|------|------|
999
+ | `operation_type` | string | Yes | Operation type | Fixed value "treasury" |
1000
+ | `data.object` | string | Yes | Treasury name or ID | |
1001
+ | `data.receive` | string or object | No | Receive CoinWrapper | "recently" or ReceivedBalance object |
1002
+ | `data.owner_receive` | string or object | No | Unwrap and send to owner | "recently" or ReceivedObjects object |
1003
+
1004
+ ### Important Notes
1005
+
1006
+ ⚠️ **receive**: Deposit received CoinWrapper into Treasury balance.
1007
+
1008
+ ⚠️ **owner_receive**: Unwrap CoinWrapper and send to Permission owner.
1009
+
1010
+ ---
1011
+
1012
+ ### Examples
1013
+
1014
+ #### Example 6.1: Receive Recently Received CoinWrapper and Deposit to Balance
1015
+
1016
+ **Prompt**: Deposit recently received CoinWrapper of "team_treasury" into balance.
1017
+
1018
+ ```json
1019
+ {
1020
+ "operation_type": "treasury",
1021
+ "data": {
1022
+ "object": "team_treasury",
1023
+ "receive": "recently"
1024
+ }
1025
+ }
1026
+ ```
1027
+
1028
+ ---
1029
+
1030
+ #### Example 6.2: Unwrap CoinWrapper and Send to Owner
1031
+
1032
+ **Prompt**: Unwrap recently received CoinWrapper and other objects of "team_treasury", send to Permission owner.
1033
+
1034
+ ```json
1035
+ {
1036
+ "operation_type": "treasury",
1037
+ "data": {
1038
+ "object": "team_treasury",
1039
+ "owner_receive": "recently"
1040
+ }
1041
+ }
1042
+ ```
1043
+
1044
+ ---
1045
+
1046
+ ## Sub-feature 7: Operate Existing Treasury (Combined Operations)
1047
+
1048
+ ### Feature Description
1049
+
1050
+ Perform multiple operations on existing Treasury in a single transaction, such as simultaneous deposit and withdrawal, or simultaneous management of external Guards.
1051
+
1052
+ ### Important Notes
1053
+
1054
+ ⚠️ **Combined Operations**: Can combine multiple operations in the same transaction to improve efficiency.
1055
+
1056
+ ---
1057
+
1058
+ ### Example
1059
+
1060
+ #### Example 7.1: Combined Deposit and Withdrawal
1061
+
1062
+ **Prompt**: For "team_treasury": 1) Deposit 10 WOW, 2) Withdraw 0.5 WOW to alice, in the same transaction.
1063
+
1064
+ ```json
1065
+ {
1066
+ "operation_type": "treasury",
1067
+ "data": {
1068
+ "object": "team_treasury",
1069
+ "deposit": {
1070
+ "coin": {
1071
+ "balance": 1000000000
1072
+ },
1073
+ "payment_info": {
1074
+ "remark": "treasury operation",
1075
+ "index": 1
1076
+ }
1077
+ },
1078
+ "withdraw": {
1079
+ "amount": {
1080
+ "fixed": 500000000
1081
+ },
1082
+ "recipient": {
1083
+ "name_or_address": "alice"
1084
+ },
1085
+ "payment_info": {
1086
+ "remark": "treasury operation",
1087
+ "index": 1
1088
+ }
1089
+ }
1090
+ },
1091
+ "env": {
1092
+ "network": "testnet"
1093
+ }
1094
+ }
1095
+ ```
1096
+
1097
+ **Execution Result**:
1098
+ ```json
1099
+ {
1100
+ "status": "success",
1101
+ "objects": [
1102
+ {
1103
+ "type": "Treasury",
1104
+ "object": "0xbf0f...6249",
1105
+ "version": "254284",
1106
+ "change": "mutated"
1107
+ },
1108
+ {
1109
+ "type": "Payment",
1110
+ "object": "0x45d6...fccd",
1111
+ "change": "created"
1112
+ },
1113
+ {
1114
+ "type": "WReceivedObject",
1115
+ "object": "0xb74b...81d1",
1116
+ "change": "created",
1117
+ "owner": "alice_address"
1118
+ },
1119
+ {
1120
+ "type": "Payment",
1121
+ "object": "0xc462...16ac",
1122
+ "change": "created"
1123
+ }
1124
+ ]
1125
+ }
1126
+ ```
1127
+
1128
+ > **Note**: Combined operations execute atomically. If any operation fails, the entire transaction is rolled back.
1129
+
1130
+ ---
1131
+
1132
+ ## Important Notes
1133
+
1134
+ ⚠️ **Treasury operations require Permission or external Guard verification.**
1135
+
1136
+ ⚠️ **External Guard verification allows permissionless operations with validation rules.**
1137
+
1138
+ ---
1139
+
1140
+ ## Related Components
1141
+
1142
+ | Component | Description |
1143
+ |-----------|-------------|
1144
+ | **[Permission](permission.md)** | Permission management |
1145
+ | **[Guard](guard.md)** | Trust verification engine - validation rules for external operations |
1146
+ | **[Payment](payment.md)** | Direct coin transfers - payment tracking and management |
1147
+ | **[Allocation](allocation.md)** | Automatic fund distribution - auto-distribution of treasury funds |
1148
+ | **[Reward](reward.md)** | Marketing incentives - incentive pools linked to treasury |
1149
+