@wowok/agent-mcp 2.2.13 → 2.2.14

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/dist/index.js +42 -98
  2. package/dist/schema-query/index.d.ts +29 -0
  3. package/dist/schema-query/index.js +149 -0
  4. package/dist/schemas/account_operation.schema.json +255 -0
  5. package/dist/schemas/guard2file.schema.json +71 -0
  6. package/dist/schemas/index.json +139 -0
  7. package/dist/schemas/local_info_operation.schema.json +142 -0
  8. package/dist/schemas/local_mark_operation.schema.json +119 -0
  9. package/dist/schemas/machineNode2file.schema.json +71 -0
  10. package/dist/schemas/messenger_operation.schema.json +1393 -0
  11. package/dist/schemas/onchain_events.schema.json +113 -0
  12. package/dist/schemas/onchain_operations.schema.json +376 -0
  13. package/dist/schemas/onchain_operations_allocation.schema.json +914 -0
  14. package/dist/schemas/onchain_operations_arbitration.schema.json +1166 -0
  15. package/dist/schemas/onchain_operations_contact.schema.json +853 -0
  16. package/dist/schemas/onchain_operations_demand.schema.json +984 -0
  17. package/dist/schemas/onchain_operations_gen_passport.schema.json +1141 -0
  18. package/dist/schemas/onchain_operations_guard.schema.json +713 -0
  19. package/dist/schemas/onchain_operations_machine.schema.json +1347 -0
  20. package/dist/schemas/onchain_operations_order.schema.json +830 -0
  21. package/dist/schemas/onchain_operations_payment.schema.json +717 -0
  22. package/dist/schemas/onchain_operations_permission.schema.json +1088 -0
  23. package/dist/schemas/onchain_operations_personal.schema.json +1282 -0
  24. package/dist/schemas/onchain_operations_progress.schema.json +751 -0
  25. package/dist/schemas/onchain_operations_repository.schema.json +1572 -0
  26. package/dist/schemas/onchain_operations_reward.schema.json +955 -0
  27. package/dist/schemas/onchain_operations_service.schema.json +1411 -0
  28. package/dist/schemas/onchain_operations_treasury.schema.json +1155 -0
  29. package/dist/schemas/onchain_table_data.schema.json +35 -0
  30. package/dist/schemas/operations/guard.json +163 -0
  31. package/dist/schemas/operations/permission.json +22 -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,1353 +0,0 @@
1
- # MyShop E-Commerce Example
2
-
3
- A complete e-commerce example demonstrating how to build an online store using WoWok protocol. This guide covers both merchant setup and customer order workflows.
4
-
5
- > 📋 **View Actual Execution Results**: See [MyShop_TestResults.md](MyShop_TestResults.md) for real testnet execution results with actual object addresses and transaction outputs.
6
-
7
- ---
8
-
9
- ## Core Requirements & Features
10
-
11
- | Requirement | Description | Implementation |
12
- |-------------|-------------|----------------|
13
- | **Product Listing** | Create and manage product/service listings | Service object with pricing, inventory, and WIP integration |
14
- | **Order Workflow** | Automated order processing from creation to completion | Machine with nodes: Order Confirmation → Shipping → In Transit → Completed |
15
- | **Permission Control** | Role-based access for merchant and customer operations | Permission object with custom indexes for merchant operations |
16
- | **Arbitration Support** | Dispute resolution mechanism | Arbitration object for handling order conflicts |
17
- | **WIP Verification** | Product authenticity verification via WIP files | WIP hash stored in Service for customer verification |
18
- | **Discount System** | Coupon and promotional code support | Discount object with time-limited offers |
19
- | **Customer Communication** | Secure messaging between merchant and customer | Contact objects for pre-sales and after-sales support |
20
-
21
- ### Key Design Decisions
22
-
23
- 1. **Workflow-Driven Orders**: Order state transitions controlled by Machine workflow, ensuring predictable processing
24
- 2. **Permission-Based Operations**: Merchant operations require specific permission indexes (1000-1002)
25
- 3. **Customer Ownership**: Order owners can cancel orders and complete orders via `namedOperator: ""`
26
- 4. **Modular Architecture**: Separate objects for Permission, Machine, Service, Arbitration, and Contact
27
-
28
- ---
29
-
30
- ## Overview
31
-
32
- This example demonstrates a toy store e-commerce system with the following features:
33
-
34
- - **Merchant System**: Product listing, order management, workflow automation
35
- - **Customer Experience**: Browse products, place orders, track progress
36
- - **Trust & Security**: Arbitration for disputes, WIP for product verification
37
- - **Workflow Automation**: Machine-driven order processing from confirmation to delivery
38
-
39
- ---
40
-
41
- ## Architecture
42
-
43
- ### System Components
44
-
45
- ```
46
- ┌─────────────────────────────────────────────────────────────────────────────┐
47
- │ MyShop E-Commerce System │
48
- ├─────────────────────────────────────────────────────────────────────────────┤
49
- │ │
50
- │ ┌─────────────────────────┐ ┌─────────────────────────┐ │
51
- │ │ Merchant System │ │ Customer System │ │
52
- │ ├─────────────────────────┤ ├─────────────────────────┤ │
53
- │ │ • Permission (Access) │ │ • Browse Products │ │
54
- │ │ • Machine (Workflow) │ │ • Create Order │ │
55
- │ │ • Service (Products) │◄──►│ • Send Private Info(*) │ │
56
- │ │ • Allocation (Payment) │ │ • Track Progress │ │
57
- │ │ • Discount (Coupons) │ │ • Order Complete │ │
58
- │ │ • Contact (Messaging) │ │ • Receive Goods │ │
59
- │ └─────────────────────────┘ └─────────────────────────┘ │
60
- │ │
61
- │ Optional: Arbitration (Dispute Resolution) │
62
- │ │
63
- └─────────────────────────────────────────────────────────────────────────────┘
64
-
65
- > **\*** Private information (shipping address, phone number) is sent via encrypted Messenger after order creation, not stored on-chain.
66
-
67
- ### Order Workflow (Happy Path)
68
-
69
- ```
70
- ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
71
- │ Order │────►│ Shipping │────►│ In Transit │────►│ Completed │
72
- │ Confirmation │ │ │ │ │ │ │
73
- └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
74
- │ │
75
- │ ┌──────────────┐ │
76
- └───────────────────►│ Order End │◄───────────────────────┘
77
- (Cancel Order) │(Final State) │ (Complete Order)
78
- └──────────────┘
79
- ```
80
-
81
- **Normal Flow**: Order Confirmation → Shipping → In Transit → Completed → Order End
82
- **Alternative**: Order Confirmation → Cancel Order → Order End (if cancelled)
83
-
84
- ---
85
-
86
- ## Part 1: Merchant System Setup
87
-
88
- This section guides merchants through setting up their online store.
89
-
90
- ### Prerequisites
91
-
92
- Before starting, ensure you have:
93
- - A WoWok account with testnet WOW tokens
94
- - Access to the WoWok MCP server
95
-
96
- **Create merchant account:**
97
-
98
- **Prompt**: Create a new account named "myshop_merchant" for the store owner.
99
-
100
- ```json
101
- {
102
- "gen": {
103
- "name": "myshop_merchant"
104
- }
105
- }
106
- ```
107
-
108
- **Get test tokens:**
109
-
110
- **Prompt**: Request testnet WOW tokens for account "myshop_merchant".
111
-
112
- ```json
113
- {
114
- "faucet": {
115
- "network": "testnet",
116
- "name_or_address": "myshop_merchant"
117
- }
118
- }
119
- ```
120
-
121
- ---
122
-
123
- ### Step 1: Create Permission Object
124
-
125
- First, create a Permission object to manage access control for your store operations.
126
-
127
- **Prompt**: Create a Permission object named "myshop_permission_v2" with tags ["ecommerce", "toys", "shop"] and description "Permission management for MyShop toy store".
128
-
129
- ```json
130
- {
131
- "operation_type": "permission",
132
- "data": {
133
- "object": {
134
- "name": "myshop_permission_v2",
135
- "tags": ["ecommerce", "toys", "shop"],
136
- "onChain": false
137
- },
138
- "description": "Permission management for MyShop toy store"
139
- },
140
- "env": {
141
- "account": "myshop_merchant",
142
- "network": "testnet"
143
- }
144
- }
145
- ```
146
-
147
- ---
148
-
149
- ### Step 2: Create Machine (Order Workflow)
150
-
151
- Create a Machine to define the order processing workflow. This includes nodes for order confirmation, shipping, delivery, and completion.
152
-
153
- **Prompt**: Create a Machine named "myshop_machine_v2" with permission "myshop_permission_v2" for the toy store workflow.
154
-
155
- ```json
156
- {
157
- "operation_type": "machine",
158
- "data": {
159
- "object": {
160
- "name": "myshop_machine_v2",
161
- "permission": "myshop_permission_v2"
162
- },
163
- "description": "Order processing workflow for MyShop toy store"
164
- },
165
- "env": {
166
- "account": "myshop_merchant",
167
- "network": "testnet"
168
- }
169
- }
170
- ```
171
-
172
- ---
173
-
174
- ### Step 3.1: Machine Workflow Design
175
-
176
- Before adding nodes, let's understand the order processing workflow:
177
-
178
- ```
179
- ┌─────────────────────────────────────────────────────────────────────────────────────┐
180
- │ MyShop Order Processing Workflow │
181
- ├─────────────────────────────────────────────────────────────────────────────────────┤
182
- │ │
183
- │ ┌──────────────────┐ │
184
- │ │ Order Created │◄─────────────────────────────────────────────────────────┐ │
185
- │ │ (Initial State) │ │ │
186
- │ └────────┬─────────┘ │ │
187
- │ │ │ │
188
- │ ▼ │ │
189
- │ ┌──────────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
190
- │ │ Order Confirmation│────►│ Confirm Order│ │ Cancel Order │───────────────────┘ │
191
- │ │ (Node 1) │ │ (Merchant) │ │ (Customer) │ │
192
- │ │ │ │ permission │ │ (Order │ │
193
- │ └────────┬─────────┘ │ Index 1000 │ │ Owner) │ │
194
- │ │ └──────────────┘ └──────────────┘ │
195
- │ │ │ │
196
- │ │ ▼ │
197
- │ │ ┌──────────────┐ │
198
- │ │ │ Threshold │ │
199
- │ │ │ = 1 │ │
200
- │ │ └──────┬───────┘ │
201
- │ │ │ │
202
- │ ▼ ▼ │
203
- │ ┌──────────────────┐ │
204
- │ │ Shipping │◄─────────────────────────────────────────────────────────┐ │
205
- │ │ (Node 2) │ │ │
206
- │ │ │ ┌──────────────┐ │ │
207
- │ └────────┬─────────┘────►│ Ship Goods │ │ │
208
- │ │ │ (Merchant) │ │ │
209
- │ │ │ permission │ │ │
210
- │ │ │ Index 1001 │ │ │
211
- │ │ └──────────────┘ │ │
212
- │ │ │ │ │
213
- │ │ ▼ │ │
214
- │ │ ┌──────────────┐ │ │
215
- │ │ │ Threshold │ │ │
216
- │ │ │ = 1 │ │ │
217
- │ │ └──────┬───────┘ │ │
218
- │ │ │ │ │
219
- │ ▼ ▼ │ │
220
- │ ┌──────────────────┐ │
221
- │ │ In Transit │◄─────────────────────────────────────────────────────────┐ │
222
- │ │ (Node 3) │ │ │
223
- │ │ │ ┌──────────────┐ │ │
224
- │ └────────┬─────────┘────►│Confirm Delivery │ │
225
- │ │ │ (Merchant) │ │ │
226
- │ │ │ permission │ │ │
227
- │ │ │ Index 1002 │ │ │
228
- │ │ └──────────────┘ │ │
229
- │ │ │ │ │
230
- │ │ ▼ │ │
231
- │ │ ┌──────────────┐ │ │
232
- │ │ │ Threshold │ │ │
233
- │ │ │ = 1 │ │ │
234
- │ │ └──────┬───────┘ │ │
235
- │ │ │ │ │
236
- │ ▼ ▼ │ │
237
- │ ┌──────────────────┐ │
238
- │ │ Completed │◄─────────────────────────────────────────────────────────┐ │
239
- │ │ (Node 4) │ │ │
240
- │ │ │ ┌──────────────┐ │ │
241
- │ └────────┬─────────┘────►│Complete Order│ │ │
242
- │ │ │ (Customer) │ │ │
243
- │ │ │ (Order │ │ │
244
- │ │ │ Owner) │ │ │
245
- │ │ └──────────────┘ │ │
246
- │ │ │ │ │
247
- │ │ ▼ │ │
248
- │ │ ┌──────────────┐ │ │
249
- │ │ │ Order End │ │ │
250
- │ │ │ (Final State) │ │
251
- │ │ └──────────────┘ │ │
252
- │ │ │
253
- │ └───────────────────────────────────────────────────────────────────────┘
254
- │ │
255
- │ Legend: │
256
- │ ───► = Forward transition (with threshold requirement) │
257
- │ ◄─── = Alternative path (cancellation) │
258
- │ │
259
- └─────────────────────────────────────────────────────────────────────────────────────┘
260
- ```
261
-
262
- **Workflow Explanation:**
263
-
264
- | Node | Name | Description | Threshold | Forwards |
265
- |------|------|-------------|-----------|----------|
266
- | 1 | Order Confirmation | Initial state after order creation | 0 | Confirm Order (Merchant), Cancel Order (Customer) |
267
- | 2 | Shipping | Merchant prepares and ships goods | 1 | Ship Goods (Merchant) |
268
- | 3 | In Transit | Goods are being delivered | 1 | Confirm Delivery (Merchant) |
269
- | 4 | Completed | Order successfully completed | 1 | Complete Order (Customer) |
270
-
271
- **Permission Index Mapping:**
272
- - `1000` - Merchant confirms order
273
- - `1001` - Merchant ships goods
274
- - `1002` - Merchant confirms delivery
275
-
276
- **Order Permission:**
277
- - Use `namedOperator: ""` (empty string) to allow order owner and agents to operate through Order object
278
- - This is the recommended way to give order owners control over their orders
279
-
280
- ---
281
-
282
- ### Step 4: Add Workflow Nodes
283
-
284
- Add the workflow nodes to the Machine for order processing.
285
-
286
- **Prompt**: Add workflow nodes to "myshop_machine_v2" including Order Confirmation, Shipping, In Transit, and Completed nodes.
287
-
288
- ```json
289
- {
290
- "operation_type": "machine",
291
- "data": {
292
- "object": "myshop_machine_v2",
293
- "node": {
294
- "op": "add",
295
- "nodes": [
296
- {
297
- "name": "Order Confirmation",
298
- "pairs": [
299
- {
300
- "prev_node": "",
301
- "threshold": 0,
302
- "forwards": [
303
- {
304
- "name": "Confirm Order",
305
- "permissionIndex": 1000,
306
- "weight": 1
307
- },
308
- {
309
- "name": "Cancel Order",
310
- "namedOperator": "",
311
- "weight": 1
312
- }
313
- ]
314
- }
315
- ]
316
- },
317
- {
318
- "name": "Shipping",
319
- "pairs": [
320
- {
321
- "prev_node": "Order Confirmation",
322
- "threshold": 1,
323
- "forwards": [
324
- {
325
- "name": "Ship Goods",
326
- "permissionIndex": 1001,
327
- "weight": 1
328
- }
329
- ]
330
- }
331
- ]
332
- },
333
- {
334
- "name": "In Transit",
335
- "pairs": [
336
- {
337
- "prev_node": "Shipping",
338
- "threshold": 1,
339
- "forwards": [
340
- {
341
- "name": "Confirm Delivery",
342
- "permissionIndex": 1002,
343
- "weight": 1
344
- }
345
- ]
346
- }
347
- ]
348
- },
349
- {
350
- "name": "Completed",
351
- "pairs": [
352
- {
353
- "prev_node": "In Transit",
354
- "threshold": 1,
355
- "forwards": [
356
- {
357
- "name": "Complete Order",
358
- "namedOperator": "",
359
- "weight": 1
360
- }
361
- ]
362
- }
363
- ]
364
- }
365
- ]
366
- }
367
- },
368
- "env": {
369
- "account": "myshop_merchant",
370
- "network": "testnet"
371
- }
372
- }
373
- ```
374
-
375
- ---
376
-
377
- ### Step 5: Publish the Machine
378
-
379
- Publish the Machine to make it available for creating orders.
380
-
381
- **Prompt**: Publish the Machine "myshop_machine_v2" to enable order creation.
382
-
383
- ```json
384
- {
385
- "operation_type": "machine",
386
- "data": {
387
- "object": "myshop_machine_v2",
388
- "publish": true
389
- },
390
- "env": {
391
- "account": "myshop_merchant",
392
- "network": "testnet"
393
- }
394
- }
395
- ```
396
- ---
397
-
398
- ### Step 5.1: Create Contact Object for Customer Service
399
-
400
- Create a Contact object to enable encrypted communication between customers and the store for after-sales support.
401
-
402
- #### 5.1.1 Enable Merchant Messenger
403
-
404
- **Prompt**: Enable messenger for the merchant account.
405
-
406
- ```json
407
- {
408
- "messenger": {
409
- "m": "myshop_merchant_messenger",
410
- "name_or_account": "myshop_merchant"
411
- }
412
- }
413
- ```
414
-
415
- #### 5.1.2 Create After-Sales Contact Object
416
-
417
- **Prompt**: Create a Contact object named "myshop_aftersales_contact_v2" with permission "myshop_permission_v2" for after-sales support.
418
-
419
- ```json
420
- {
421
- "operation_type": "contact",
422
- "data": {
423
- "object": {
424
- "name": "myshop_aftersales_contact_v2",
425
- "permission": "myshop_permission_v2"
426
- },
427
- "description": "MyShop after-sales support contact - we're here to help with orders, shipping, and returns",
428
- "ims": {
429
- "op": "add",
430
- "im": [
431
- {
432
- "at": "myshop_merchant",
433
- "description": "Primary after-sales support representative"
434
- }
435
- ]
436
- }
437
- },
438
- "env": {
439
- "account": "myshop_merchant",
440
- "network": "testnet"
441
- }
442
- }
443
- ```
444
-
445
- ---
446
-
447
- ### Step 6: Create Allocation Guards
448
-
449
- Before creating the Service, you need Guards for order fund allocation. These Guards validate when funds can be withdrawn by the merchant or refunded to customers.
450
-
451
- #### 6.1 Create Merchant Withdraw Guard
452
-
453
- This Guard checks if the order has reached "Completed" status before allowing the merchant to withdraw funds.
454
-
455
- **Prompt**: Create a Guard named "myshop_withdraw_guard_v2" that verifies the order is in "Completed" status.
456
-
457
- ```json
458
- {
459
- "operation_type": "guard",
460
- "data": {
461
- "namedNew": {
462
- "name": "myshop_withdraw_guard_v2",
463
- "tags": ["ecommerce", "withdraw", "merchant"]
464
- },
465
- "description": "Verify order is completed before merchant can withdraw funds. Submit order object ID.",
466
- "table": [
467
- {
468
- "identifier": 0,
469
- "b_submission": true,
470
- "value_type": "Address",
471
- "name": "order_id"
472
- },
473
- {
474
- "identifier": 1,
475
- "b_submission": false,
476
- "value_type": "String",
477
- "value": "Completed",
478
- "name": "completed_node"
479
- }
480
- ],
481
- "root": {
482
- "type": "node",
483
- "node": {
484
- "type": "logic_equal",
485
- "nodes": [
486
- {
487
- "type": "query",
488
- "query": 1253,
489
- "object": {
490
- "identifier": 0,
491
- "convert_witness": 100
492
- },
493
- "parameters": []
494
- },
495
- {
496
- "type": "identifier",
497
- "identifier": 1
498
- }
499
- ]
500
- }
501
- }
502
- },
503
- "env": {
504
- "account": "myshop_merchant",
505
- "network": "testnet"
506
- }
507
- }
508
- ```
509
-
510
- **How it works:**
511
- - Uses `convert_witness: 100` (TypeOrderProgress) to access the order's Progress object
512
- - Query ID `1253` (`progress.current`) retrieves the current node name
513
- - Compares with "Completed" to verify order status
514
-
515
- #### 6.2 Create Customer Refund Guard
516
-
517
- For scenarios where customers need refunds before order completion.
518
-
519
- **Prompt**: Create a Guard named "myshop_refund_guard_v2" for customer refund scenarios.
520
-
521
- ```json
522
- {
523
- "operation_type": "guard",
524
- "data": {
525
- "namedNew": {
526
- "name": "myshop_refund_guard_v2",
527
- "tags": ["ecommerce", "refund", "customer"]
528
- },
529
- "description": "Allow refund for orders not yet shipped. Submit order object ID.",
530
- "table": [
531
- {
532
- "identifier": 0,
533
- "b_submission": true,
534
- "value_type": "Address",
535
- "name": "order_id"
536
- },
537
- {
538
- "identifier": 1,
539
- "b_submission": false,
540
- "value_type": "String",
541
- "value": "Order Confirmation",
542
- "name": "confirmation_node"
543
- }
544
- ],
545
- "root": {
546
- "type": "node",
547
- "node": {
548
- "type": "logic_equal",
549
- "nodes": [
550
- {
551
- "type": "query",
552
- "query": 1253,
553
- "object": {
554
- "identifier": 0,
555
- "convert_witness": 100
556
- },
557
- "parameters": []
558
- },
559
- {
560
- "type": "identifier",
561
- "identifier": 1
562
- }
563
- ]
564
- }
565
- }
566
- },
567
- "env": {
568
- "account": "myshop_merchant",
569
- "network": "testnet"
570
- }
571
- }
572
- ```
573
- ---
574
-
575
- ### Step 7: Create Service (Store)
576
-
577
- Create the Service object that represents your online store with products. This step binds all previously created components together.
578
-
579
- > **Important**: For Service creation, you need to provide a complete configuration including machine, order_allocators with Guards, and products. The Service will be created and published in a single transaction.
580
-
581
- #### 7.1 Understanding Order Allocators
582
-
583
- The `order_allocators` configuration defines how order payments are distributed:
584
-
585
- | Component | Description |
586
- |-----------|-------------|
587
- | **Guard** | Validates allocation conditions (e.g., order must be completed) |
588
- | **Sharing** | Defines who receives funds and how much |
589
- | **Mode** | "Rate" (percentage), "Amount" (fixed), or "Surplus" |
590
- | **Threshold** | Minimum amount to trigger allocation |
591
-
592
- **Recipient Types:**
593
- - `{ "Signer": "signer" }` - Transaction sender (merchant)
594
- - `{ "Entity": { "address": "..." } }` - Specific address
595
- - `{ "GuardIdentifier": 0 }` - Address from Guard table
596
-
597
- #### 7.2 Create and Publish Service
598
-
599
- **Prompt**: Create and publish a Service named "myshop_service_v2" with machine "myshop_machine_v2", order allocation using Guards, after-sales contact, and toy products.
600
-
601
- ```json
602
- {
603
- "operation_type": "service",
604
- "data": {
605
- "object": {
606
- "name": "myshop_service_v2",
607
- "type_parameter": "0x2::wow::WOW",
608
- "permission": "myshop_permission_v2",
609
- "tags": ["ecommerce", "toys", "store"],
610
- "onChain": false
611
- },
612
- "description": "MyShop - Top quality toys for children",
613
- "location": "Online Store",
614
- "machine": "myshop_machine_v2",
615
- "order_allocators": {
616
- "description": "Order revenue allocation - merchant withdraw after completion",
617
- "threshold": 0,
618
- "allocators": [
619
- {
620
- "guard": "myshop_withdraw_guard_v2",
621
- "sharing": [
622
- {
623
- "who": { "Signer": "signer" },
624
- "sharing": 10000,
625
- "mode": "Rate"
626
- }
627
- ]
628
- },
629
- {
630
- "guard": "myshop_refund_guard_v2",
631
- "sharing": [
632
- {
633
- "who": { "GuardIdentifier": 0 },
634
- "sharing": 10000,
635
- "mode": "Rate"
636
- }
637
- ]
638
- }
639
- ]
640
- },
641
- "sales": {
642
- "op": "add",
643
- "sales": [
644
- {
645
- "name": "Play Purse Set 35PCS",
646
- "price": 3000000000,
647
- "stock": 100,
648
- "suspension": false,
649
- "wip": "",
650
- "wip_hash": ""
651
- },
652
- {
653
- "name": "Little Girls Purse with Accessories",
654
- "price": 5000000000,
655
- "stock": 50,
656
- "suspension": false,
657
- "wip": "",
658
- "wip_hash": ""
659
- },
660
- {
661
- "name": "Tree House Building Set",
662
- "price": 2000000000,
663
- "stock": 75,
664
- "suspension": false,
665
- "wip": "",
666
- "wip_hash": ""
667
- }
668
- ]
669
- },
670
- "um": "myshop_aftersales_contact_v2",
671
- "publish": true
672
- },
673
- "env": {
674
- "account": "myshop_merchant",
675
- "network": "testnet"
676
- }
677
- }
678
- ```
679
-
680
- ⚠️ **Important Notes:**
681
- - After publishing, `machine`, `order_allocators`, and `arbitrations` become **immutable**
682
- - Ensure your Guards and allocation logic are correct before publishing
683
- - The `sharing` value of `10000` represents 100% (rate mode uses 0-10000 scale)
684
-
685
- ---
686
-
687
- ### Step 8: Create Discount Coupons (Optional)
688
-
689
- Create discount coupons for promotional campaigns.
690
-
691
- **Prompt**: Create a 20% discount coupon named "HOLIDAY20" for holiday promotions, valid for 30 days, distributed to customers "alice" and "bob".
692
-
693
- ```json
694
- {
695
- "operation_type": "service",
696
- "data": {
697
- "object": "myshop_service_v2",
698
- "discount": {
699
- "name": "HOLIDAY20",
700
- "discount_type": 0,
701
- "discount_value": 2000,
702
- "benchmark": 0,
703
- "time_ms_start": 0,
704
- "time_ms_end": 2592000000,
705
- "count": 100,
706
- "recipient": ["alice", "bob"],
707
- "transferable": true
708
- }
709
- },
710
- "env": {
711
- "account": "myshop_merchant",
712
- "network": "testnet"
713
- }
714
- }
715
- ```
716
-
717
- ---
718
-
719
- ## Part 2: Customer Order Flow
720
-
721
- This section guides customers through browsing products, placing orders, and tracking progress.
722
-
723
- ### Prerequisites
724
-
725
- Create a customer account:
726
-
727
- **Prompt**: Create a customer account named "myshop_customer".
728
-
729
- ```json
730
- {
731
- "gen": {
732
- "name": "myshop_customer"
733
- }
734
- }
735
- ```
736
-
737
- **Get test tokens:**
738
-
739
- ```json
740
- {
741
- "faucet": {
742
- "network": "testnet",
743
- "name_or_address": "myshop_customer"
744
- }
745
- }
746
- ```
747
-
748
- ---
749
-
750
- ### Step 1: Query Service Products
751
-
752
- Customers can query the Service to see available products.
753
-
754
- **Prompt**: Query the Service "myshop_service_v2" to view available products and their details.
755
-
756
- ```json
757
- {
758
- "query_type": "onchain_objects",
759
- "objects": ["myshop_service_v2"],
760
- "no_cache": true
761
- }
762
- ```
763
-
764
- ---
765
-
766
- ### Step 2: Create Order (Customer Purchase)
767
-
768
- Customer creates an order by purchasing products from the Service.
769
-
770
- **Prompt**: Create an order for customer "myshop_customer" to purchase "Play Purse Set 35PCS" from "myshop_service_v2" with payment of 3WOW.
771
-
772
- ```json
773
- {
774
- "operation_type": "service",
775
- "data": {
776
- "object": "myshop_service_v2",
777
- "order_new": {
778
- "buy": {
779
- "items": [
780
- {
781
- "name": "Play Purse Set 35PCS",
782
- "stock": 1,
783
- "wip_hash": ""
784
- }
785
- ],
786
- "total_pay": {
787
- "balance": 3000000000
788
- }
789
- }
790
- }
791
- },
792
- "env": {
793
- "account": "myshop_customer",
794
- "network": "testnet"
795
- }
796
- }
797
- ```
798
-
799
- ---
800
-
801
- ### Step 2.1: Send Shipping Address via Messenger (Privacy Protection)
802
-
803
- After creating the order, the customer needs to send their shipping address and contact information to the after-sales support team. This is done securely through the Messenger system to protect privacy - the information is never stored on-chain.
804
-
805
- ```
806
- ┌─────────────────────────────────────────────────────────────────────────────────────┐
807
- │ Private Information Exchange via Messenger │
808
- ├─────────────────────────────────────────────────────────────────────────────────────┤
809
- │ │
810
- │ ┌──────────────────┐ End-to-End Encrypted ┌──────────────────┐ │
811
- │ │ │◄──────────────────────────────────────►│ │ │
812
- │ │ myshop_customer │ Messenger Channel │ myshop_aftersales│ │
813
- │ │ (Customer) │ (Never on-chain) │ (After-Sales) │ │
814
- │ │ │ │ Support Team │ │
815
- │ └────────┬─────────┘ └────────┬─────────┘ │
816
- │ │ │ │
817
- │ │ 1. Send shipping address │ │
818
- │ │ - Full name │ │
819
- │ │ - Phone number │ │
820
- │ │ - Shipping address │ │
821
- │ │ - Order reference ID │ │
822
- │ │──────────────────────────────────────────────────────────►│ │
823
- │ │ │ │
824
- │ │ 2. Receive confirmation │ │
825
- │ │ - Address verified │ │
826
- │ │ - Delivery ETA │ │
827
- │ │ - Tracking number (when available) │ │
828
- │ │◄──────────────────────────────────────────────────────────│ │
829
- │ │ │ │
830
- │ ┌────────▼─────────┐ ┌────────▼─────────┐ │
831
- │ │ Customer Info │ │ Support System │ │
832
- │ │ (Local Storage) │ │ (Local Storage) │ │
833
- │ └──────────────────┘ └──────────────────┘ │
834
- │ │
835
- │ Privacy Guarantees: │
836
- │ ✅ End-to-end encryption - Only customer and support can read │
837
- │ ✅ No on-chain storage - Message content never touches blockchain │
838
- │ ✅ Verifiable identity - Contact object confirms who you're talking to │
839
- │ ✅ WTS support - Can generate verifiable conversation records if needed │
840
- │ │
841
- └─────────────────────────────────────────────────────────────────────────────────────┘
842
- ```
843
-
844
- #### 2.1.1 Customer Enables Messenger
845
-
846
- **Prompt**: Enable messenger for customer account "myshop_customer" to send private messages.
847
-
848
- ```json
849
- {
850
- "messenger": {
851
- "m": "customer_messenger"
852
- },
853
- "name_or_account": "myshop_customer"
854
- }
855
- ```
856
-
857
- #### 2.1.2 Customer Sends Shipping Information
858
-
859
- **Prompt**: Customer "myshop_customer" sends shipping address and contact information to after-sales support "myshop_aftersales" via encrypted messenger.
860
-
861
- ```json
862
- {
863
- "operation": "send_message",
864
- "from": "myshop_customer",
865
- "to": "myshop_aftersales",
866
- "content": "Order Shipping Information:\n\nOrder ID: 0x5678...9abc\nProduct: Play Purse Set 35PCS\n\nRecipient: Zhang San\nPhone: 138-0000-0000\nAddress: Building 123, Unit 456, Room 789\n Chaoyang District, Beijing\n China, 100000\n\nPlease confirm receipt of this information."
867
- }
868
- ```
869
-
870
- #### 2.1.3 After-Sales Support Receives and Confirms
871
-
872
- **Prompt**: After-sales support "myshop_aftersales" views the message and sends confirmation to customer.
873
-
874
- ```json
875
- {
876
- "operation": "send_message",
877
- "from": "myshop_aftersales",
878
- "to": "myshop_customer",
879
- "content": "Dear Customer,\n\nWe have received your shipping information:\n✅ Order ID: 0x5678...9abc confirmed\n✅ Shipping address verified\n✅ Contact phone: 138-0000-0000\n\nYour order will be processed within 24 hours. We'll send you the tracking number once shipped.\n\nThank you for shopping with MyShop!"
880
- }
881
- ```
882
-
883
- #### 2.1.4 View Conversation History
884
-
885
- **Prompt**: View the conversation between customer and after-sales support to confirm both messages were delivered.
886
-
887
- ```json
888
- {
889
- "operation": "watch_messages",
890
- "filter": {
891
- "peerAddress": "myshop_aftersales",
892
- "account": "myshop_customer"
893
- }
894
- }
895
- ```
896
-
897
- ---
898
-
899
- ### Step 3: Query Order Status
900
-
901
- Customer can query the order status and progress.
902
-
903
- **Prompt**: Query the order "0x5678...9abc" to check its current status and progress.
904
-
905
- ```json
906
- {
907
- "query_type": "onchain_objects",
908
- "objects": ["0x5678...9abc"]
909
- }
910
- ```
911
-
912
- ---
913
-
914
- ### Step 4: Query Progress Status
915
-
916
- Check the current workflow node of the order.
917
-
918
- **Prompt**: Query the Progress "0x1234...5678" to see the current workflow node.
919
-
920
- ```json
921
- {
922
- "query_type": "onchain_objects",
923
- "objects": ["0x1234...5678"]
924
- }
925
- ```
926
- ---
927
-
928
- ### Step 5: Merchant Confirms Order
929
-
930
- Merchant advances the order from "Order Confirmation" to "Shipping".
931
-
932
- > **Note**: The merchant (order owner) can use `operation_type: "order"` with `progress` to advance the workflow. Non-owners must use `operation_type: "progress"` with `operate`.
933
-
934
- **Prompt**: Advance the order "0x5678...9abc" progress from "Order Confirmation" to "Shipping" using the "Confirm Order" forward.
935
-
936
- ```json
937
- {
938
- "operation_type": "order",
939
- "data": {
940
- "object": "0x5678...9abc",
941
- "progress": {
942
- "operation": {
943
- "next_node_name": "Shipping",
944
- "forward": "Confirm Order"
945
- },
946
- "hold": false,
947
- "message": "Order confirmed by merchant"
948
- }
949
- },
950
- "env": {
951
- "account": "myshop_merchant",
952
- "network": "testnet"
953
- }
954
- }
955
- ```
956
- ---
957
-
958
- ### Step 6: Merchant Ships Order
959
-
960
- Merchant ships the order and advances to "In Transit".
961
-
962
- **Prompt**: Advance the order "0x5678...9abc" progress from "Shipping" to "In Transit" using the "Ship Goods" forward.
963
-
964
- ```json
965
- {
966
- "operation_type": "order",
967
- "data": {
968
- "object": "0x5678...9abc",
969
- "progress": {
970
- "operation": {
971
- "next_node_name": "In Transit",
972
- "forward": "Ship Goods"
973
- },
974
- "hold": false,
975
- "message": "Goods shipped via express delivery"
976
- }
977
- },
978
- "env": {
979
- "account": "myshop_merchant",
980
- "network": "testnet"
981
- }
982
- }
983
- ```
984
- ---
985
-
986
- ### Step 7: Confirm Delivery
987
-
988
- Merchant or delivery service confirms the order has been delivered.
989
-
990
- **Prompt**: Advance the order "0x5678...9abc" progress from "In Transit" to "Completed" using the "Confirm Delivery" forward.
991
-
992
- ```json
993
- {
994
- "operation_type": "order",
995
- "data": {
996
- "object": "0x5678...9abc",
997
- "progress": {
998
- "operation": {
999
- "next_node_name": "Completed",
1000
- "forward": "Confirm Delivery"
1001
- },
1002
- "hold": false,
1003
- "message": "Goods delivered successfully"
1004
- }
1005
- },
1006
- "env": {
1007
- "account": "myshop_merchant",
1008
- "network": "testnet"
1009
- }
1010
- }
1011
- ```
1012
- ---
1013
-
1014
- ### Step 8: Customer Completes Order
1015
-
1016
- Customer confirms receipt and completes the order.
1017
-
1018
- > **Important**: Non-order owners (like the customer in this case) must use `operation_type: "progress"` to advance the workflow. Only the order owner (merchant) can use `operation_type: "order"` with progress operations.
1019
-
1020
- **Prompt**: Customer "myshop_customer" completes the order "0x5678...9abc" by advancing from "Completed" node using "Complete Order" forward.
1021
-
1022
- ```json
1023
- {
1024
- "operation_type": "progress",
1025
- "data": {
1026
- "object": "0x1234...5678",
1027
- "operate": {
1028
- "operation": {
1029
- "next_node_name": "Completed",
1030
- "forward": "Complete Order"
1031
- },
1032
- "hold": false,
1033
- "message": "Order received and completed"
1034
- }
1035
- },
1036
- "env": {
1037
- "account": "myshop_customer",
1038
- "network": "testnet"
1039
- }
1040
- }
1041
- ```
1042
- ---
1043
-
1044
- ### Step 9: Merchant Withdraws Funds
1045
-
1046
- After order completion, the merchant needs to:
1047
- 1. Activate the Allocation by verifying the Guard (order completion status)
1048
- 2. Withdraw funds from the Service
1049
-
1050
- #### 9.1 Activate Allocation (Guard Verification)
1051
-
1052
- First, activate the Allocation by submitting the Guard verification with the Order ID.
1053
-
1054
- > **Note**: You can get the Allocation object ID from the Order object's `allocation` field, or by naming it during order creation with `namedNewAllocation`.
1055
-
1056
- **Prompt**: Activate allocation "0xdef0...1234" by verifying the withdraw guard with order "0x5678...9abc".
1057
-
1058
- ```json
1059
- {
1060
- "operation_type": "allocation",
1061
- "data": {
1062
- "object": "0x248f01d944de8f6712ec06f9b4c54f93fe4132e5323488b2d24c83d7487069de",
1063
- "alloc_by_guard": "myshop_withdraw_guard_v2"
1064
- },
1065
- "submission": {
1066
- "type": "submission",
1067
- "guard": [
1068
- {
1069
- "object": "myshop_withdraw_guard_v2",
1070
- "impack": true
1071
- }
1072
- ],
1073
- "submission": [
1074
- {
1075
- "guard": "myshop_withdraw_guard_v2",
1076
- "submission": [
1077
- {
1078
- "identifier": 0,
1079
- "b_submission": true,
1080
- "value_type": "Address",
1081
- "value": "0x497ea4f7a5bb098802c23deedd8ed7122d6b501979394ce111aa66432d2ba0ca"
1082
- }
1083
- ]
1084
- }
1085
- ]
1086
- },
1087
- "env": {
1088
- "account": "myshop_merchant",
1089
- "network": "testnet",
1090
- "no_cache": true
1091
- }
1092
- }
1093
- ```
1094
-
1095
- #### 9.2 Withdraw Funds from Service
1096
-
1097
- After the Allocation is activated, withdraw the funds from the Service.
1098
-
1099
- **Prompt**: Withdraw funds from service "myshop_service_v2" to the merchant account.
1100
-
1101
- ```json
1102
- {
1103
- "operation_type": "service",
1104
- "data": {
1105
- "object": "myshop_service_v2",
1106
- "owner_receive": "recently"
1107
- },
1108
- "env": {
1109
- "account": "myshop_merchant",
1110
- "network": "testnet"
1111
- }
1112
- }
1113
- ```
1114
- ---
1115
-
1116
- ## Alternative Flow: Order Cancellation
1117
-
1118
- ### Customer Cancels Order
1119
-
1120
- Customer can cancel the order before it's confirmed.
1121
-
1122
- > **Note**: Customer (non-order owner) uses `operation_type: "progress"` to cancel the order.
1123
-
1124
- **Prompt**: Customer "myshop_customer" cancels the order "0x5678...9abc" before merchant confirmation.
1125
-
1126
- ```json
1127
- {
1128
- "operation_type": "progress",
1129
- "data": {
1130
- "object": "0x1234...5678",
1131
- "operate": {
1132
- "operation": {
1133
- "next_node_name": "Order Confirmation",
1134
- "forward": "Cancel Order"
1135
- },
1136
- "hold": false,
1137
- "message": "Order cancelled by customer"
1138
- }
1139
- },
1140
- "env": {
1141
- "account": "myshop_customer",
1142
- "network": "testnet"
1143
- }
1144
- }
1145
- ```
1146
- ---
1147
-
1148
- ## Alternative Flow: Dispute and Arbitration
1149
-
1150
- ### Step 1: Create Arbitration Object
1151
-
1152
- First, create an Arbitration object for handling order disputes.
1153
-
1154
- **Prompt**: Create an Arbitration object named "myshop_arbitration_v2" with permission "myshop_permission_v2" for dispute resolution.
1155
-
1156
- ```json
1157
- {
1158
- "operation_type": "arbitration",
1159
- "data": {
1160
- "object": {
1161
- "name": "myshop_arbitration_v2",
1162
- "type_parameter": "0x2::wow::WOW",
1163
- "permission": "myshop_permission_v2",
1164
- "tags": ["ecommerce", "dispute", "toys"],
1165
- "onChain": false
1166
- },
1167
- "description": "Arbitration system for MyShop toy store disputes",
1168
- "location": "Online arbitration system",
1169
- "fee": 100000000
1170
- },
1171
- "env": {
1172
- "account": "myshop_merchant",
1173
- "network": "testnet"
1174
- }
1175
- }
1176
- ```
1177
-
1178
- ### Step 2: Customer Submits Arbitration
1179
-
1180
- If there's a dispute, customer can submit arbitration.
1181
-
1182
- **Prompt**: Customer "myshop_customer" submits arbitration for order "0x5678...9abc" using arbitration "myshop_arbitration".
1183
-
1184
- ```json
1185
- {
1186
- "operation_type": "order",
1187
- "data": {
1188
- "object": "0x5678...9abc",
1189
- "arb_confirm": {
1190
- "arb": "myshop_arbitration",
1191
- "confirm": true,
1192
- "description": "Product not as described - requesting refund",
1193
- "proposition": ["Full refund", "Return shipping cost coverage"]
1194
- }
1195
- },
1196
- "env": {
1197
- "account": "myshop_customer",
1198
- "network": "testnet"
1199
- }
1200
- }
1201
- ```
1202
-
1203
- ### Step 3: Query Arbitration Status
1204
-
1205
- Check the status of the arbitration.
1206
-
1207
- **Prompt**: Query the arbitration "0xbeef...cafe" to check its status.
1208
-
1209
- ```json
1210
- {
1211
- "query_type": "onchain_objects",
1212
- "objects": ["0xbeef...cafe"]
1213
- }
1214
- ```
1215
-
1216
- ---
1217
-
1218
- ## Summary
1219
-
1220
- This MyShop e-commerce example demonstrates:
1221
-
1222
- 1. **Merchant Setup**:
1223
- - Permission management for access control
1224
- - Machine workflow for order processing with visual flow diagram
1225
- - Contact objects for pre-sales and after-sales support
1226
- - Service creation with products and pricing
1227
- - Arbitration setup for dispute resolution
1228
- - Discount coupon creation for promotions
1229
-
1230
- 2. **Customer Flow**:
1231
- - Product browsing and selection
1232
- - Order creation with payment
1233
- - **Private information exchange via Messenger** (shipping address, phone number)
1234
- - Progress tracking through workflow nodes
1235
- - Order completion and payment release
1236
-
1237
- 3. **Privacy & Security Features**:
1238
- - End-to-end encrypted messaging for sensitive information
1239
- - Contact-based identity verification
1240
- - No private data stored on-chain
1241
- - WTS support for verifiable conversation records
1242
-
1243
- 4. **Alternative Flows**:
1244
- - Order cancellation before confirmation
1245
- - Dispute submission and arbitration process
1246
-
1247
- All operations use the new WoWok SDK patterns with JSON-based tool calls, making it easy for AI agents to interact with the blockchain e-commerce system.
1248
-
1249
- ---
1250
-
1251
- ## Important: Order vs Progress Operations
1252
-
1253
- When advancing order workflows, it's crucial to use the correct operation type based on who is performing the action:
1254
-
1255
- ### Order Owner (Merchant)
1256
-
1257
- The order owner can use `operation_type: "order"` with the `progress` field:
1258
-
1259
- ```json
1260
- {
1261
- "operation_type": "order",
1262
- "data": {
1263
- "object": "0x5678...9abc",
1264
- "progress": {
1265
- "operation": {
1266
- "next_node_name": "Shipping",
1267
- "forward": "Confirm Order"
1268
- },
1269
- "hold": false,
1270
- "message": "Order confirmed"
1271
- }
1272
- }
1273
- }
1274
- ```
1275
-
1276
- ### Non-Owner (Customer, Agents)
1277
-
1278
- Non-owners must use `operation_type: "progress"` with the `operate` field:
1279
-
1280
- ```json
1281
- {
1282
- "operation_type": "progress",
1283
- "data": {
1284
- "object": "0x1234...5678",
1285
- "operate": {
1286
- "operation": {
1287
- "next_node_name": "Completed",
1288
- "forward": "Complete Order"
1289
- },
1290
- "hold": false,
1291
- "message": "Order completed"
1292
- }
1293
- }
1294
- }
1295
- ```
1296
-
1297
- > **Key Difference**:
1298
- > - `order` operation: Uses `progress` field, only for order owners
1299
- > - `progress` operation: Uses `operate` field, for anyone with permission to advance the workflow
1300
-
1301
- The Progress object ID can be obtained from:
1302
- - Order object's `progress` field
1303
- - Named during order creation with `namedNewProgress`
1304
-
1305
- ---
1306
-
1307
- ## Object Reference Summary
1308
-
1309
- | Object Type | Name | Example Address | Purpose |
1310
- |-------------|------|-----------------|---------|
1311
- | Account | myshop_merchant | 0x73e1...708a | Store owner account |
1312
- | Account | myshop_customer | 0x6e95...d94d | Customer account |
1313
- | Permission | myshop_permission_v2 | 0x0e01...9862 | Access control management |
1314
- | Guard | myshop_withdraw_guard_v2 | 0x7fe6...91ea | Merchant withdrawal validation (order completed) |
1315
- | Guard | myshop_refund_guard_v2 | 0x6147...bda4 | Customer refund validation (order not shipped) |
1316
- | Machine | myshop_machine_v2 | 0x923b...6aac | Order processing workflow |
1317
- | Contact | myshop_aftersales_contact_v2 | 0x855a...f53b | After-sales support contact |
1318
- | Service | myshop_service_v2 | 0xc02e...9755 | Online store with products |
1319
- | Arbitration | myshop_arbitration_v2 | (to be created) | Dispute resolution |
1320
- | Discount | HOLIDAY20 | (to be created) | Promotional coupon |
1321
- | Order | (dynamic) | 0x497e...a0ca | Customer purchase order |
1322
- | Progress | (dynamic) | 0xf7ec...472f | Order workflow progress |
1323
- | Allocation | (dynamic) | 0x248f...69de | Order fund allocation |
1324
- | Arb | (dynamic) | (dynamic) | Arbitration case |
1325
-
1326
- ---
1327
-
1328
- ## Next Steps
1329
-
1330
- - Extend the workflow with more nodes (e.g., "Return Goods", "Refund Processing")
1331
- - Add more complex Guards for conditional transitions
1332
- - Implement WIP files for product verification
1333
- - Create multiple discount campaigns
1334
- - Set up Repository for order data storage
1335
- - Add WTS generation for messenger conversation records
1336
- - Implement file sharing via Messenger (shipping labels, invoices)
1337
- - Add blacklist/guardlist management for spam prevention
1338
- - Create automated notification system for order status updates
1339
-
1340
- ---
1341
-
1342
- ## Notes
1343
-
1344
- - All addresses shown in examples are truncated for readability (format: 0xabcd...efgh)
1345
- - Use the full 64-character address in actual operations
1346
- - Test on testnet before deploying to mainnet
1347
- - Ensure sufficient WOW tokens for transaction fees
1348
-
1349
- ---
1350
-
1351
- ## Actual Test Results
1352
-
1353
- For actual execution results with real object addresses and transaction outputs from testnet, see [MyShop_TestResults.md](MyShop_TestResults.md).