@wowok/agent-mcp 2.2.13 → 2.2.15

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 (126) hide show
  1. package/README.md +19 -11
  2. package/dist/index.js +44 -100
  3. package/dist/schema/query/index.js +1 -1
  4. package/dist/schema-query/index.d.ts +29 -0
  5. package/dist/schema-query/index.js +149 -0
  6. package/dist/schemas/account_operation.schema.json +255 -0
  7. package/dist/schemas/guard2file.schema.json +71 -0
  8. package/dist/schemas/index.json +139 -0
  9. package/dist/schemas/local_info_operation.schema.json +142 -0
  10. package/dist/schemas/local_mark_operation.schema.json +119 -0
  11. package/dist/schemas/machineNode2file.schema.json +71 -0
  12. package/dist/schemas/messenger_operation.schema.json +1393 -0
  13. package/dist/schemas/onchain_events.schema.json +113 -0
  14. package/dist/schemas/onchain_operations.schema.json +376 -0
  15. package/dist/schemas/onchain_operations_allocation.schema.json +914 -0
  16. package/dist/schemas/onchain_operations_arbitration.schema.json +1166 -0
  17. package/dist/schemas/onchain_operations_contact.schema.json +853 -0
  18. package/dist/schemas/onchain_operations_demand.schema.json +984 -0
  19. package/dist/schemas/onchain_operations_gen_passport.schema.json +1141 -0
  20. package/dist/schemas/onchain_operations_guard.schema.json +713 -0
  21. package/dist/schemas/onchain_operations_machine.schema.json +1347 -0
  22. package/dist/schemas/onchain_operations_order.schema.json +830 -0
  23. package/dist/schemas/onchain_operations_payment.schema.json +717 -0
  24. package/dist/schemas/onchain_operations_permission.schema.json +1088 -0
  25. package/dist/schemas/onchain_operations_personal.schema.json +1282 -0
  26. package/dist/schemas/onchain_operations_progress.schema.json +751 -0
  27. package/dist/schemas/onchain_operations_repository.schema.json +1572 -0
  28. package/dist/schemas/onchain_operations_reward.schema.json +955 -0
  29. package/dist/schemas/onchain_operations_service.schema.json +1411 -0
  30. package/dist/schemas/onchain_operations_treasury.schema.json +1155 -0
  31. package/dist/schemas/onchain_table_data.schema.json +35 -0
  32. package/dist/schemas/query_toolkit.schema.json +32 -0
  33. package/dist/schemas/schema_query.schema.json +33 -0
  34. package/dist/schemas/wip_file.schema.json +27 -0
  35. package/dist/schemas/wowok_buildin_info.schema.json +487 -0
  36. package/package.json +7 -5
  37. package/dist/docs/index.d.ts +0 -3
  38. package/dist/docs/index.js +0 -2
  39. package/dist/docs/loader.d.ts +0 -12
  40. package/dist/docs/loader.js +0 -177
  41. package/dist/docs/search.d.ts +0 -17
  42. package/dist/docs/search.js +0 -325
  43. package/dist/docs/types.d.ts +0 -55
  44. package/dist/docs/types.js +0 -1
  45. package/docs/README.md +0 -249
  46. package/docs/WIP.md +0 -388
  47. package/docs/WTS.md +0 -536
  48. package/docs/docs/account.md +0 -914
  49. package/docs/docs/allocation.md +0 -635
  50. package/docs/docs/arbitration.md +0 -1804
  51. package/docs/docs/arbitration_state_machine.md +0 -270
  52. package/docs/docs/contact.md +0 -709
  53. package/docs/docs/demand.md +0 -948
  54. package/docs/docs/guard.md +0 -1465
  55. package/docs/docs/localinfo.md +0 -432
  56. package/docs/docs/localmark.md +0 -583
  57. package/docs/docs/machine.md +0 -2490
  58. package/docs/docs/messenger.md +0 -2098
  59. package/docs/docs/onchain_events.md +0 -267
  60. package/docs/docs/order.md +0 -1001
  61. package/docs/docs/payment.md +0 -512
  62. package/docs/docs/permission.md +0 -1438
  63. package/docs/docs/personal.md +0 -742
  64. package/docs/docs/progress.md +0 -1748
  65. package/docs/docs/query.md +0 -467
  66. package/docs/docs/repository.md +0 -1043
  67. package/docs/docs/reward.md +0 -833
  68. package/docs/docs/service.md +0 -2130
  69. package/docs/docs/stage-01-introduction.md +0 -243
  70. package/docs/docs/stage-02-trust.md +0 -302
  71. package/docs/docs/stage-03-collaboration.md +0 -337
  72. package/docs/docs/stage-04-transaction.md +0 -277
  73. package/docs/docs/stage-05-business.md +0 -151
  74. package/docs/docs/stage-06-personal.md +0 -203
  75. package/docs/docs/stage-07-query.md +0 -572
  76. package/docs/docs/stage-08-examples.md +0 -184
  77. package/docs/docs/treasury.md +0 -1149
  78. package/docs/docs/wowok_buildin_info.md +0 -740
  79. package/docs/examples/Insurance/Insurance.md +0 -594
  80. package/docs/examples/Insurance/Insurance_TestResults.md +0 -481
  81. package/docs/examples/Insurance/insurance_complete_guard_v1.json +0 -50
  82. package/docs/examples/MyShop/MyShop.md +0 -1353
  83. package/docs/examples/MyShop/MyShop_TestResults.md +0 -1003
  84. package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +0 -1898
  85. package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +0 -1297
  86. package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +0 -743
  87. package/docs/examples/MyShop_Advanced/machine_nodes.json +0 -222
  88. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +0 -776
  89. package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +0 -599
  90. package/docs/examples/Travel/Travel.md +0 -1157
  91. package/docs/examples/Travel/Travel_TestResults.md +0 -743
  92. package/docs/examples/Travel/calc-weather-timestamps.js +0 -8
  93. package/docs/examples/Travel/travel_machine_v2_export.json +0 -104
  94. package/docs/examples/Travel/weather_check_guard_v1.json +0 -51
  95. package/docs/skills/WOWOK.md +0 -650
  96. package/docs/skills/onchain_operations/_common.md +0 -406
  97. package/docs/skills/onchain_operations/_index.md +0 -196
  98. package/docs/skills/onchain_operations/allocation.md +0 -28
  99. package/docs/skills/onchain_operations/arbitration.md +0 -106
  100. package/docs/skills/onchain_operations/contact.md +0 -40
  101. package/docs/skills/onchain_operations/demand.md +0 -53
  102. package/docs/skills/onchain_operations/gen_passport.md +0 -23
  103. package/docs/skills/onchain_operations/guard.md +0 -56
  104. package/docs/skills/onchain_operations/machine.md +0 -89
  105. package/docs/skills/onchain_operations/order.md +0 -56
  106. package/docs/skills/onchain_operations/payment.md +0 -24
  107. package/docs/skills/onchain_operations/permission.md +0 -68
  108. package/docs/skills/onchain_operations/personal.md +0 -58
  109. package/docs/skills/onchain_operations/progress.md +0 -38
  110. package/docs/skills/onchain_operations/repository.md +0 -70
  111. package/docs/skills/onchain_operations/reward.md +0 -38
  112. package/docs/skills/onchain_operations/service.md +0 -78
  113. package/docs/skills/onchain_operations/treasury.md +0 -68
  114. package/docs/skills/schema-account_operation.md +0 -402
  115. package/docs/skills/schema-guard2file.md +0 -153
  116. package/docs/skills/schema-local_info_operation.md +0 -160
  117. package/docs/skills/schema-local_mark_operation.md +0 -148
  118. package/docs/skills/schema-machineNode2file.md +0 -155
  119. package/docs/skills/schema-messenger_operation.md +0 -547
  120. package/docs/skills/schema-onchain_events.md +0 -201
  121. package/docs/skills/schema-onchain_table_data.md +0 -334
  122. package/docs/skills/schema-query_toolkit.md +0 -395
  123. package/docs/skills/schema-wip_file.md +0 -240
  124. package/docs/skills/schema-wowok_buildin_info.md +0 -296
  125. package/docs/wip-examples/three_body.html +0 -57
  126. package/docs/wip-examples/three_body.wip +0 -30
@@ -1,833 +0,0 @@
1
-
2
- # Reward Component (🏆 Reward Pool)
3
-
4
- ---
5
-
6
- ## Component Overview
7
-
8
- Reward is WoWok's reward pool component, used to create reward pools, set reward rules, and distribute rewards. Reward is usually bound to Service and triggered by Guard verification.
9
-
10
- ---
11
-
12
- ## Function List
13
-
14
- | Function Name | Purpose | Usage Scenario | Significance |
15
- |---------------|---------|----------------|-------------|
16
- | **Create Reward** | Establish new reward pool with access controls | Set up user incentive programs, referral rewards | Creates secure on-chain reward pool with permission management |
17
- | **Add Funds** | Deposit assets into reward pool balance | Fund incentive programs, top up reward budget | Fills the reward pool balance |
18
- | **Claim Reward** | Verify Guard and distribute reward | Trigger reward payout, complete incentive conditions | Executes reward distribution when Guard verification passes |
19
- | **Add Reward Guards** | Configure Guard-based reward rules | Set up conditional rewards, referral incentives | Defines reward eligibility with Guard validation |
20
- | **Remove Expired Guards** | Clean up expired reward rules | Maintain active reward rules, reduce bloat | Keeps reward pool configuration clean |
21
- | **Set Guard Expiration** | Lock reward rule modifications | Prevent rule changes during active campaigns | Ensures reward rules remain stable |
22
- | **Receive Balance** | Process received CoinWrapper objects | Collect incoming payments, top up pool | Automatically adds received assets to pending balance |
23
- | **Owner Receive** | Unwrap and send received assets to owner | Forward received tokens, process payments | Delivers received assets to permission owner |
24
-
25
- ---
26
-
27
- ## Complete Tool Call Structure
28
-
29
- Reward operations use the following top-level structure:
30
-
31
- ```json
32
- {
33
- "operation_type": "reward",
34
- "data": { ... }, // Reward data definition
35
- "env": { ... }, // Execution environment (optional)
36
- "submission": { ... } // Submission data (optional)
37
- }
38
- ```
39
-
40
- ---
41
-
42
- ## Schema Tree
43
-
44
- ```
45
- reward (Reward Object)
46
- ├── operation_type: "reward" (fixed value)
47
- ├── data (Reward data definition)
48
- │ ├── object (object definition, required)
49
- │ │ ├── name|id (reference existing object)
50
- │ │ └── name|tags|type_parameter|permission (create new object)
51
- │ ├── claim (Guard to claim reward, optional)
52
- │ ├── description (description, optional)
53
- │ ├── coin_add (add funds, optional)
54
- │ │ ├── Option 1: { balance: number } - specify amount
55
- │ │ └── Option 2: { coin: string } - use specified Coin object ID
56
- │ ├── receive (receive CoinWrapper, optional)
57
- │ │ ├── Option 1: "recently" (string) - receive all recently received
58
- │ │ └── Option 2: { balance, token_type, received } - specify received balance
59
- │ │ ├── balance (number or string)
60
- │ │ ├── token_type (string) - token type like "CoinWrapper<0x2::wow::WOW>"
61
- │ │ └── received (array) - received CoinWrapper object records
62
- │ │ └── [{ id: string, balance: number, payment: string }]
63
- │ ├── guard_add (add RewardGuards, optional)
64
- │ │ └── Array of RewardGuard objects
65
- │ │ ├── guard (string) - Guard object ID or name
66
- │ │ ├── recipient (object) - Recipient specification
67
- │ │ │ ├── Option 1: { GuardIdentifier: number } - From Guard table (0-255)
68
- │ │ │ ├── Option 2: { Entity: { name_or_address: string } } - Fixed entity ID
69
- │ │ │ └── Option 3: { Signer: "signer" } - Current transaction signer ID
70
- │ │ ├── amount (object) - Reward amount
71
- │ │ │ ├── Option 1: { type: "Fixed", value: number } - Fixed amount
72
- │ │ │ └── Option 2: { type: "GuardU64Identifier", value: number } - Amount from Guard table (0-255)
73
- │ │ ├── expiration_time (number, optional) - Expiration timestamp in milliseconds
74
- │ │ └── store_from_id (number or null, optional) - Guard table index for record storage
75
- │ ├── guard_remove_expired (remove expired, optional)
76
- │ ├── guard_expiration_time (expiration time, optional)
77
- │ ├── owner_receive (transfer received coins or NFT objects to owner, optional)
78
- │ │ ├── Option 1: "recently" (string) - receive all recent objects
79
- │ │ ├── Option 2: Array of received objects
80
- │ │ │ └── [{ id: "object_id", type: "object_type" }]
81
- │ │ └── Option 3: Received balance object
82
- │ │ ├── balance (number or string)
83
- │ │ ├── token_type (string)
84
- │ │ └── received (array of received items)
85
- │ └── um (Contact object, optional)
86
- │ ├── Option 1: Contact object name or ID (string)
87
- │ └── Option 2: null (to unbind contact)
88
- ├── env (optional, execution environment)
89
- │ ├── account (string, optional) - account name or address, empty string for default
90
- │ ├── network (string, optional) - "testnet" or "localnet"
91
- │ ├── permission_guard (array, optional) - list of permission guard IDs
92
- │ ├── no_cache (boolean, optional) - disable caching
93
- │ └── referrer (string, optional) - referrer ID
94
- └── submission (optional, submission data)
95
- ├── type (string) - fixed value "submission"
96
- ├── guard (array) - list of guards to verify
97
- │ └── [{ object: "guard_id", impack: boolean }]
98
- └── submission (array) - submission data for guards
99
- └── [{ guard: "guard_id", submission: [guard_submission_items] }]
100
- └── guard_submission_items
101
- ├── identifier (number, 0-255) - Guard table item identifier
102
- ├── b_submission (boolean) - whether this item requires submission
103
- ├── value_type (number | string) - value type (e.g., 6 or "U64" for U64 type)
104
- ├── **value (any) - submitted value**
105
- └── name (string, optional) - item name
106
- ```
107
-
108
- ---
109
-
110
- ### ⚠️ Important Note About Submission
111
-
112
- If the execution returns a `submission` field in the response, it indicates that additional Guard verification data is required. You must:
113
-
114
- 1. Complete all required submission data within the `submission` structure
115
- 2. Resubmit the operation with the completed submission data
116
- 3. **Do not modify any other parts of the structure** - only fill in the required submission values
117
-
118
- The submission structure will specify which Guard objects need verification and what data needs to be provided for each Guard table item.
119
-
120
- **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.
121
-
122
- ---
123
-
124
- ## Sub-feature 1: Create New Reward
125
-
126
- ### Feature Description
127
-
128
- Create a new Reward object for managing rewards.
129
-
130
- ### Parameter Description
131
-
132
- | Parameter Path | Type | Required | Description | Constraints |
133
- |----------|------|------|------|------|
134
- | `operation_type` | string | Yes | Operation type | Fixed value "reward" |
135
- | `data.object` | object or string | Yes | Object definition | TypedPermissionObject |
136
- | `data.description` | string | No | Reward description | Max 65535 bcs characters |
137
- | `env.account` | string | No | Use specified account | Empty string '' uses default account |
138
- | `env.network` | enum | No | Network selection | "localnet" or "testnet" |
139
-
140
- ### Important Notes
141
-
142
- ⚠️ **Reward Guards**: Define reward rules using RewardGuard objects, which include recipient, amount, and expiration.
143
-
144
- ⚠️ **Guard Verification**: Rewards are only distributed when the specified Guard verification passes.
145
-
146
- ---
147
-
148
- ### Examples
149
-
150
- #### Example 1.1: Create Minimal Reward
151
-
152
- **Prompt**: Create a Reward named "reward_test_1", use default account and testnet network.
153
-
154
- ```json
155
- {
156
- "operation_type": "reward",
157
- "data": {
158
- "object": {
159
- "name": "reward_test_1"
160
- }
161
- },
162
- "env": {
163
- "network": "testnet"
164
- }
165
- }
166
- ```
167
-
168
- **Execution Result**:
169
- ```json
170
- {
171
- "status": "success",
172
- "objects": [
173
- {
174
- "type": "Reward",
175
- "object": "0x11a5...b44e",
176
- "version": "214214",
177
- "change": "created"
178
- },
179
- {
180
- "type": "Permission",
181
- "object": "0xb991...16cd",
182
- "version": "214214",
183
- "change": "created"
184
- }
185
- ]
186
- }
187
- ```
188
-
189
- ---
190
-
191
- #### Example 1.2: Create Reward with Tags
192
-
193
- **Prompt**: Create a Reward named "reward_test_2", add tags "referral", "incentive", description "Referral reward program".
194
-
195
- ```json
196
- {
197
- "operation_type": "reward",
198
- "data": {
199
- "object": {
200
- "name": "reward_test_2",
201
- "tags": ["referral", "incentive"]
202
- },
203
- "description": "Referral reward program"
204
- },
205
- "env": {
206
- "network": "testnet"
207
- }
208
- }
209
- ```
210
-
211
- **Execution Result**:
212
- ```json
213
- {
214
- "status": "success",
215
- "objects": [
216
- {
217
- "type": "Reward",
218
- "object": "0x85cb...ab07",
219
- "version": "214844",
220
- "change": "created"
221
- },
222
- {
223
- "type": "Permission",
224
- "object": "0xe6cc...1508",
225
- "version": "214844",
226
- "change": "created"
227
- }
228
- ]
229
- }
230
- ```
231
-
232
- ---
233
-
234
- #### Example 1.3: Create Reward with Funds
235
-
236
- **Prompt**: Create a Reward named "reward_test_3": 1) Add tags "incentive", "promotion", 2) Add description "Complete reward pool example", 3) Add 100 WOW initial funds.
237
-
238
- > **Prerequisite**: Need to create Guard object first for subsequent reward rules
239
- > ```json
240
- > {
241
- > "operation_type": "guard",
242
- > "data": {
243
- > "namedNew": {"name": "new_user_guard"},
244
- > "description": "New user reward guard",
245
- > "table": [{"identifier": 0, "value_type": "bool", "b_submission": false, "value": true}],
246
- > "root": {
247
- > "type": "node",
248
- > "node": {
249
- > "type": "logic_equal",
250
- > "nodes": [{"type": "identifier", "identifier": 0}, {"type": "identifier", "identifier": 0}]
251
- > }
252
- > }
253
- > },
254
- > "env": {"network": "testnet"}
255
- > }
256
- > ```
257
-
258
- ```json
259
- {
260
- "operation_type": "reward",
261
- "data": {
262
- "object": {
263
- "name": "reward_test_3",
264
- "tags": ["incentive", "promotion"]
265
- },
266
- "description": "Complete reward pool example",
267
- "coin_add": {
268
- "balance": 100000000000
269
- }
270
- },
271
- "env": {
272
- "network": "testnet"
273
- }
274
- }
275
- ```
276
-
277
- **Execution Result**:
278
- ```json
279
- {
280
- "status": "success",
281
- "objects": []
282
- }
283
- ```
284
-
285
- > **Note**: When creating object and adding funds simultaneously, the returned object list may be empty. You can confirm successful creation through query.
286
-
287
- ---
288
-
289
- ## Sub-feature 2: Add Funds to Reward Pool
290
-
291
- ### Feature Description
292
-
293
- Add assets to the Reward object's balance.
294
-
295
- ### Parameter Description
296
-
297
- | Parameter Path | Type | Required | Description | Constraints |
298
- |----------|------|------|------|------|
299
- | `operation_type` | string | Yes | Operation type | Fixed value "reward" |
300
- | `data.object` | string | Yes | Reward name or ID | |
301
- | `data.coin_add` | object | Yes | Amount to add | { balance: number } or { coin: string } |
302
-
303
- ---
304
-
305
- ### Examples
306
-
307
- #### Example 2.1: Add Fixed Amount
308
-
309
- **Prompt**: Add 500 WOW to "reward_test_1" pool.
310
-
311
- ```json
312
- {
313
- "operation_type": "reward",
314
- "data": {
315
- "object": "reward_test_1",
316
- "coin_add": {
317
- "balance": 500000000000
318
- }
319
- },
320
- "env": {
321
- "network": "testnet"
322
- }
323
- }
324
- ```
325
-
326
- **Execution Result**:
327
- ```json
328
- {
329
- "status": "success",
330
- "objects": [
331
- {
332
- "type": "Reward",
333
- "object": "0x11a5...b44e",
334
- "version": "216638",
335
- "change": "modified"
336
- }
337
- ]
338
- }
339
- ```
340
-
341
- ---
342
-
343
- #### Example 2.2: Add Funds with Multiple Operations
344
-
345
- **Prompt**: For "reward_test_2": Add 200 WOW funds.
346
-
347
- ```json
348
- {
349
- "operation_type": "reward",
350
- "data": {
351
- "object": "reward_test_2",
352
- "coin_add": {
353
- "balance": 200000000000
354
- }
355
- },
356
- "env": {
357
- "network": "testnet"
358
- }
359
- }
360
- ```
361
-
362
- **Execution Result**:
363
- ```json
364
- {
365
- "status": "success",
366
- "objects": [
367
- {
368
- "type": "Reward",
369
- "object": "0x85cb...ab07",
370
- "version": "217xxx",
371
- "change": "modified"
372
- }
373
- ]
374
- }
375
- ```
376
-
377
- ---
378
-
379
- ## Sub-feature 3: Claim Reward
380
-
381
- ### Feature Description
382
-
383
- Verify the specified Guard and execute the corresponding reward distribution.
384
-
385
- ### Parameter Description
386
-
387
- | Parameter Path | Type | Required | Description | Constraints |
388
- |----------|------|------|------|------|
389
- | `operation_type` | string | Yes | Operation type | Fixed value "reward" |
390
- | `data.object` | string | Yes | Reward name or ID | |
391
- | `data.claim` | string | Yes | Guard object to verify | Guard name or ID |
392
-
393
- ### Important Notes
394
-
395
- ⚠️ **Guard Must Be Configured**: The specified Guard must be in the reward's guard list.
396
-
397
- ⚠️ **Sufficient Pool Balance**: Ensure the reward pool has enough balance to cover the reward.
398
-
399
- ---
400
-
401
- ### Example
402
-
403
- #### Example 3.1: Claim Reward by Guard
404
-
405
- **Prompt**: Claim reward from "new_user_reward" by verifying "new_user_guard".
406
-
407
- ```json
408
- {
409
- "operation_type": "reward",
410
- "data": {
411
- "object": "new_user_reward",
412
- "claim": "new_user_guard"
413
- }
414
- }
415
- ```
416
-
417
- ---
418
-
419
- ## Sub-feature 4: Manage Reward Guards
420
-
421
- ### Feature Description
422
-
423
- Add RewardGuard objects to the reward pool, remove expired guards, and set guard expiration time.
424
-
425
- ### Parameter Description
426
-
427
- | Parameter Path | Type | Required | Description | Constraints |
428
- |----------|------|------|------|------|
429
- | `operation_type` | string | Yes | Operation type | Fixed value "reward" |
430
- | `data.object` | string | Yes | Reward name or ID | |
431
- | `data.guard_add` | array | No | Add RewardGuards | Array of RewardGuard objects |
432
- | `data.guard_remove_expired` | boolean | No | Remove expired guards | |
433
- | `data.guard_expiration_time` | number or null | No | Set guard expiration lock | Milliseconds, null to unlock |
434
-
435
- ### RewardGuard Structure
436
-
437
- | Field | Type | Required | Description |
438
- |-------|------|------|------|
439
- | `guard` | string | Yes | Guard object ID or name |
440
- | `recipient` | object | Yes | Recipient specification |
441
- | `amount` | object | Yes | Reward amount |
442
- | `expiration_time` | number | No | Expiration time in milliseconds (Unix timestamp) |
443
- | `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 |
444
-
445
- #### ⚠️ Important Notes About `expiration_time`
446
-
447
- **Timestamp Format**: `expiration_time` is a Unix timestamp in milliseconds, representing the expiration deadline for the reward rule.
448
-
449
- **Key Constraints**:
450
- 1. **Must be future time**: `expiration_time` must be greater than the current blockchain time, otherwise the transaction will fail (error code: E_GUARD_EXPIRED)
451
- 2. **Unit is milliseconds**: Not seconds! For example, `1876000000000` represents around year 2029
452
- 3. **Permanent if not set**: If `expiration_time` is not set, the reward rule will be valid permanently
453
-
454
- **How to Calculate**:
455
- - Current timestamp (ms): `Date.now()`
456
- - Future time: `Date.now() + 30 * 24 * 60 * 60 * 1000` (30 days later)
457
- - Online tool: https://www.unixtimestamp.com/ (remember to multiply by 1000 to convert to milliseconds)
458
-
459
- **Common Error**:
460
- ```
461
- Error: E_GUARD_EXPIRED (error code 2)
462
- ```
463
- This indicates that the set `expiration_time` is less than or equal to the current blockchain time.
464
-
465
- ### Recipient Types
466
-
467
- - **Signer**: `{ "Signer": "signer" }` - Current transaction signer
468
- - **Entity**: `{ "Entity": "name_or_address" }` - Fixed entity ID
469
- - **GuardIdentifier**: `{ "GuardIdentifier": number }` - From Guard table
470
-
471
- ### Amount Types
472
-
473
- - **Fixed**: `{ "type": "Fixed", "value": number }` - Fixed amount
474
-
475
- ---
476
-
477
- ### Examples
478
-
479
- #### Example 4.1: Add Single RewardGuard
480
-
481
- **Prompt**: Add a RewardGuard to "reward_test_1": 1) Guard "new_user_guard", 2) Recipient is signer, 3) Fixed amount 10 WOW, 4) Expires in 30 days (from current time).
482
-
483
- > **Note**: `expiration_time` must be a future timestamp (milliseconds) and must be greater than the current blockchain time.
484
-
485
- ```json
486
- {
487
- "operation_type": "reward",
488
- "data": {
489
- "object": "reward_test_1",
490
- "guard_add": [
491
- {
492
- "guard": "new_user_guard",
493
- "recipient": {
494
- "Signer": "signer"
495
- },
496
- "amount": {
497
- "type": "Fixed",
498
- "value": 1000000000
499
- },
500
- "expiration_time": 1876000000000
501
- }
502
- ]
503
- },
504
- "env": {
505
- "network": "testnet"
506
- }
507
- }
508
- ```
509
-
510
- **Execution Result**:
511
- ```json
512
- {
513
- "status": "success",
514
- "objects": [
515
- {
516
- "type": "Reward",
517
- "object": "0x11a5...b44e",
518
- "version": "218xxx",
519
- "change": "modified"
520
- }
521
- ]
522
- }
523
- ```
524
-
525
- ---
526
-
527
- #### Example 4.2: Add Multiple RewardGuards
528
-
529
- **Prompt**: Add two RewardGuards to "referral_reward": 1) First guard for referrer (entity "referrer"), 2) Second guard for referee (entity "referee").
530
-
531
- ```json
532
- {
533
- "operation_type": "reward",
534
- "data": {
535
- "object": "referral_reward",
536
- "guard_add": [
537
- {
538
- "guard": "referrer_guard",
539
- "recipient": {
540
- "Entity": "referrer"
541
- },
542
- "amount": {
543
- "type": "Fixed",
544
- "value": 500000000
545
- }
546
- },
547
- {
548
- "guard": "referee_guard",
549
- "recipient": {
550
- "Entity": "referee"
551
- },
552
- "amount": {
553
- "type": "Fixed",
554
- "value": 300000000
555
- }
556
- }
557
- ]
558
- }
559
- }
560
- ```
561
-
562
- ---
563
-
564
- #### Example 4.3: Remove Expired Guards
565
-
566
- **Prompt**: Remove all expired RewardGuards from "new_user_reward".
567
-
568
- ```json
569
- {
570
- "operation_type": "reward",
571
- "data": {
572
- "object": "new_user_reward",
573
- "guard_remove_expired": true
574
- }
575
- }
576
- ```
577
-
578
- ---
579
-
580
- #### Example 4.4: Set Guard Expiration Lock
581
-
582
- **Prompt**: Set guard expiration lock on "reward_test_2" for 7 days, preventing new guards from being added during that time.
583
-
584
- ```json
585
- {
586
- "operation_type": "reward",
587
- "data": {
588
- "object": "reward_test_2",
589
- "guard_expiration_time": 1876000000000
590
- },
591
- "env": {
592
- "network": "testnet"
593
- }
594
- }
595
- ```
596
-
597
- **Execution Result**:
598
- ```json
599
- {
600
- "status": "success",
601
- "objects": [
602
- {
603
- "type": "Reward",
604
- "object": "0x85cb...ab07",
605
- "version": "228609",
606
- "change": "mutated"
607
- }
608
- ]
609
- }
610
- ```
611
-
612
- ---
613
-
614
- #### Example 4.5: Unlock Guard Expiration
615
-
616
- **Prompt**: Unlock guard expiration on "campaign_reward", allowing new guards to be added again.
617
-
618
- ```json
619
- {
620
- "operation_type": "reward",
621
- "data": {
622
- "object": "campaign_reward",
623
- "guard_expiration_time": null
624
- }
625
- }
626
- ```
627
-
628
- ---
629
-
630
- ## Sub-feature 5: Receive and Manage Assets
631
-
632
- ### Feature Description
633
-
634
- Process CoinWrapper objects received by Reward, can deposit to pending balance or unwrap and send to permission owner.
635
-
636
- ### Parameter Description
637
-
638
- | Parameter Path | Type | Required | Description | Constraints |
639
- |----------|------|------|------|------|
640
- | `operation_type` | string | Yes | Operation type | Fixed value "reward" |
641
- | `data.object` | string | Yes | Reward name or ID | |
642
- | `data.receive` | string or object | No | Receive CoinWrapper | "recently" or ReceivedBalance object |
643
- | `data.owner_receive` | string or object | No | Unwrap and send to owner | "recently" or ReceivedObjects object |
644
-
645
- ### Important Notes
646
-
647
- ⚠️ **receive**: Unwrap received CoinWrapper and store in reward's pending balance.
648
-
649
- ⚠️ **owner_receive**: Unwrap CoinWrapper and send to permission owner.
650
-
651
- ---
652
-
653
- ### Examples
654
-
655
- #### Example 5.1: Receive Recently Received CoinWrapper
656
-
657
- **Prompt**: Deposit recently received CoinWrapper of "new_user_reward" into pending balance.
658
-
659
- ```json
660
- {
661
- "operation_type": "reward",
662
- "data": {
663
- "object": "new_user_reward",
664
- "receive": "recently"
665
- }
666
- }
667
- ```
668
-
669
- ---
670
-
671
- #### Example 5.2: Unwrap and Send to Owner
672
-
673
- **Prompt**: First send Coin to "reward_test_1" via Payment, then unwrap and send to permission owner.
674
-
675
- **Step 1: Send Coin to Reward via Payment**
676
-
677
- ```json
678
- {
679
- "operation_type": "payment",
680
- "data": {
681
- "object": {
682
- "type_parameter": "0x2::wow::WOW"
683
- },
684
- "revenue": [
685
- {
686
- "recipient": {"name_or_address": "reward_test_1"},
687
- "amount": {"balance": "5000000000"}
688
- }
689
- ],
690
- "info": {
691
- "remark": "Send coin to reward object",
692
- "index": 1
693
- }
694
- },
695
- "env": {
696
- "network": "testnet"
697
- }
698
- }
699
- ```
700
-
701
- **Step 1 Execution Result**:
702
- ```json
703
- {
704
- "status": "success",
705
- "objects": [
706
- {
707
- "type": "WReceivedObject",
708
- "object": "0x3b5e...af84",
709
- "change": "created"
710
- },
711
- {
712
- "type": "Payment",
713
- "object": "0x4fa5...b21e",
714
- "change": "created"
715
- }
716
- ]
717
- }
718
- ```
719
-
720
- **Step 2: Unwrap and Send to Owner**
721
-
722
- ```json
723
- {
724
- "operation_type": "reward",
725
- "data": {
726
- "object": "reward_test_1",
727
- "owner_receive": "recently"
728
- },
729
- "env": {
730
- "network": "testnet"
731
- }
732
- }
733
- ```
734
-
735
- **Step 2 Execution Result**:
736
- ```json
737
- {
738
- "status": "success",
739
- "objects": [
740
- {
741
- "type": "Reward",
742
- "object": "0x11a5...b44e",
743
- "version": "233053",
744
- "change": "mutated"
745
- },
746
- {
747
- "type": "WReceivedObject",
748
- "object": "0x3b5e...af84",
749
- "version": "233053",
750
- "change": "mutated"
751
- }
752
- ]
753
- }
754
- ```
755
-
756
- ---
757
-
758
- ## Sub-feature 6: Combined Operations
759
-
760
- ### Feature Description
761
-
762
- Perform multiple operations on existing Reward in a single transaction, such as adding funds and adding guards simultaneously.
763
-
764
- ### Important Notes
765
-
766
- ⚠️ **Combined Operations**: Can combine multiple operations in the same transaction to improve efficiency.
767
-
768
- ---
769
-
770
- ### Example
771
-
772
- #### Example 6.1: Complete Reward Setup
773
-
774
- **Prompt**: For "complete_reward": 1) Add 500 WOW funds, 2) Add two RewardGuards, 3) Process received balance, 4) Set description.
775
-
776
- ```json
777
- {
778
- "operation_type": "reward",
779
- "data": {
780
- "object": "complete_reward",
781
- "description": "Complete reward setup example",
782
- "coin_add": {
783
- "balance": 500000000000
784
- },
785
- "receive": "recently",
786
- "guard_add": [
787
- {
788
- "guard": "bonus_guard_1",
789
- "recipient": {
790
- "Signer": "signer"
791
- },
792
- "amount": {
793
- "type": "Fixed",
794
- "value": 2000000000
795
- }
796
- },
797
- {
798
- "guard": "bonus_guard_2",
799
- "recipient": {
800
- "Entity": "team_member"
801
- },
802
- "amount": {
803
- "type": "Fixed",
804
- "value": 1000000000
805
- }
806
- }
807
- ]
808
- }
809
- }
810
- ```
811
-
812
- ---
813
-
814
- ## Important Notes
815
-
816
- ⚠️ **Reward distribution requires Guard verification**, only users who pass Guard verification can receive rewards.
817
-
818
- ⚠️ **Reward pool funds must be sufficient**, otherwise rewards cannot be distributed.
819
-
820
- ⚠️ **Guard expiration time locks modifications**, new guards cannot be added before expiration.
821
-
822
- ---
823
-
824
- ## Related Components
825
-
826
- | Component | Description |
827
- |-----------|-------------|
828
- | **[Service](service.md)** | WYSIWYG product trading - can bind Reward to Service |
829
- | **[Guard](guard.md)** | Trust verification engine - required for reward claiming |
830
- | **[Permission](permission.md)** | Permission management |
831
- | **[Treasury](treasury.md)** | Team fund management - can fund reward pools from treasury |
832
- | **[Allocation](allocation.md)** | Automatic fund distribution - similar distribution mechanism |
833
-