@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.
- package/dist/docs/index.d.ts +3 -0
- package/dist/docs/index.js +2 -0
- package/dist/docs/loader.d.ts +12 -0
- package/dist/docs/loader.js +177 -0
- package/dist/docs/search.d.ts +17 -0
- package/dist/docs/search.js +325 -0
- package/dist/docs/types.d.ts +55 -0
- package/dist/docs/types.js +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +146 -39
- package/docs/README.md +249 -0
- package/docs/WIP.md +388 -0
- package/docs/WTS.md +536 -0
- package/docs/docs/account.md +914 -0
- package/docs/docs/allocation.md +635 -0
- package/docs/docs/arbitration.md +1804 -0
- package/docs/docs/arbitration_state_machine.md +270 -0
- package/docs/docs/contact.md +709 -0
- package/docs/docs/demand.md +948 -0
- package/docs/docs/guard.md +1465 -0
- package/docs/docs/localinfo.md +432 -0
- package/docs/docs/localmark.md +583 -0
- package/docs/docs/machine.md +2490 -0
- package/docs/docs/messenger.md +2098 -0
- package/docs/docs/onchain_events.md +267 -0
- package/docs/docs/order.md +1001 -0
- package/docs/docs/payment.md +512 -0
- package/docs/docs/permission.md +1438 -0
- package/docs/docs/personal.md +742 -0
- package/docs/docs/progress.md +1748 -0
- package/docs/docs/query.md +467 -0
- package/docs/docs/repository.md +1043 -0
- package/docs/docs/reward.md +833 -0
- package/docs/docs/service.md +2130 -0
- package/docs/docs/stage-01-introduction.md +243 -0
- package/docs/docs/stage-02-trust.md +302 -0
- package/docs/docs/stage-03-collaboration.md +337 -0
- package/docs/docs/stage-04-transaction.md +277 -0
- package/docs/docs/stage-05-business.md +151 -0
- package/docs/docs/stage-06-personal.md +203 -0
- package/docs/docs/stage-07-query.md +572 -0
- package/docs/docs/stage-08-examples.md +184 -0
- package/docs/docs/treasury.md +1149 -0
- package/docs/docs/wowok_buildin_info.md +740 -0
- package/docs/examples/Insurance/Insurance.md +594 -0
- package/docs/examples/Insurance/Insurance_TestResults.md +481 -0
- package/docs/examples/Insurance/insurance_complete_guard_v1.json +50 -0
- package/docs/examples/MyShop/MyShop.md +1353 -0
- package/docs/examples/MyShop/MyShop_TestResults.md +1003 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced.md +1898 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +1297 -0
- package/docs/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +743 -0
- package/docs/examples/MyShop_Advanced/machine_nodes.json +222 -0
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature.md +776 -0
- package/docs/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +599 -0
- package/docs/examples/Travel/Travel.md +1157 -0
- package/docs/examples/Travel/Travel_TestResults.md +743 -0
- package/docs/examples/Travel/calc-weather-timestamps.js +8 -0
- package/docs/examples/Travel/travel_machine_v2_export.json +104 -0
- package/docs/examples/Travel/weather_check_guard_v1.json +51 -0
- package/docs/skills/WOWOK.md +650 -0
- package/docs/skills/onchain_operations/_common.md +406 -0
- package/docs/skills/onchain_operations/_index.md +196 -0
- package/docs/skills/onchain_operations/allocation.md +28 -0
- package/docs/skills/onchain_operations/arbitration.md +106 -0
- package/docs/skills/onchain_operations/contact.md +40 -0
- package/docs/skills/onchain_operations/demand.md +53 -0
- package/docs/skills/onchain_operations/gen_passport.md +23 -0
- package/docs/skills/onchain_operations/guard.md +56 -0
- package/docs/skills/onchain_operations/machine.md +89 -0
- package/docs/skills/onchain_operations/order.md +56 -0
- package/docs/skills/onchain_operations/payment.md +24 -0
- package/docs/skills/onchain_operations/permission.md +68 -0
- package/docs/skills/onchain_operations/personal.md +58 -0
- package/docs/skills/onchain_operations/progress.md +38 -0
- package/docs/skills/onchain_operations/repository.md +70 -0
- package/docs/skills/onchain_operations/reward.md +38 -0
- package/docs/skills/onchain_operations/service.md +78 -0
- package/docs/skills/onchain_operations/treasury.md +68 -0
- package/docs/skills/schema-account_operation.md +402 -0
- package/docs/skills/schema-guard2file.md +153 -0
- package/docs/skills/schema-local_info_operation.md +160 -0
- package/docs/skills/schema-local_mark_operation.md +148 -0
- package/docs/skills/schema-machineNode2file.md +155 -0
- package/docs/skills/schema-messenger_operation.md +547 -0
- package/docs/skills/schema-onchain_events.md +201 -0
- package/docs/skills/schema-onchain_table_data.md +334 -0
- package/docs/skills/schema-query_toolkit.md +395 -0
- package/docs/skills/schema-wip_file.md +240 -0
- package/docs/skills/schema-wowok_buildin_info.md +296 -0
- package/docs/wip-examples/three_body.html +57 -0
- package/docs/wip-examples/three_body.wip +30 -0
- package/package.json +3 -2
|
@@ -0,0 +1,2130 @@
|
|
|
1
|
+
|
|
2
|
+
# Service Component (🏪 Service Marketplace)
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Component Overview
|
|
7
|
+
|
|
8
|
+
The Service component is WoWok protocol's service/product publishing and sales management module, used to create and manage service or product listings in the marketplace. Service publishers can bind Machine (workflow templates), Repository (data warehouses), Arbitration (dispute resolution), and other components, configure Order Allocators, set up Discounts, manage Compensation Funds, and handle order creation and payment workflows.
|
|
9
|
+
|
|
10
|
+
**Critical Integration with WIP**: Service sales items can optionally include a WIP (Witness Information Promise) file that provides immutable, verifiable product/service descriptions.
|
|
11
|
+
|
|
12
|
+
- **With WIP**: Set `wip` to a local file path or HTTPS URL. The hash is automatically extracted, and customers must provide matching `wip_hash` when purchasing.
|
|
13
|
+
- **Without WIP**: Set `wip` to empty string `""` for simple products where WIP verification is not needed.
|
|
14
|
+
|
|
15
|
+
See the [WIP section in Step-by-Step Guide](#step-4-configure-wip-files-for-products-optional-but-recommended) and [Messenger](messenger.md) for details on generating, verifying, and signing WIP files.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Function List
|
|
20
|
+
|
|
21
|
+
| Function Name | Purpose | Usage Scenario | Significance |
|
|
22
|
+
|---------------|---------|----------------|-------------|
|
|
23
|
+
| **Object Management** | Create or reference Service objects | Initialize new services or modify existing ones | Foundation for all service operations |
|
|
24
|
+
| **Configure Machine** | Bind workflow templates | Define automated service execution logic | Enables workflow-driven service delivery |
|
|
25
|
+
| **Order Allocators** | Set fund distribution rules | Configure revenue sharing, platform fees | Automates financial settlements |
|
|
26
|
+
| **Publish Service** | Make service available to customers | Launch service after configuration | Transitions service from draft to active state |
|
|
27
|
+
| **Pause/Resume Orders** | Temporarily stop accepting orders | Maintenance, inventory issues | Provides operational flexibility without unpublishing |
|
|
28
|
+
| **Manage Repositories** | Attach data warehouses | Store service-related data | Enables data-driven operations |
|
|
29
|
+
| **Manage Rewards** | Attach incentive pools | Set up loyalty programs | Encourages customer engagement |
|
|
30
|
+
| **Manage Arbitrations** | Attach dispute resolution | Handle order conflicts | Ensures fair dispute handling |
|
|
31
|
+
| **Configure Contact** | Bind instant messaging | Enable customer support | Facilitates direct communication |
|
|
32
|
+
| **Manage Sales** | Add products/services | List items for sale | Core e-commerce functionality |
|
|
33
|
+
| **Issue Discounts** | Create coupon codes | Promotions, new user offers | Drives customer acquisition |
|
|
34
|
+
| **Destroy Discounts** | Remove expired coupons | Clean up outdated discounts | Maintains promotion integrity |
|
|
35
|
+
| **Compensation Fund** | Manage dispute funds | Add/withdraw arbitration funds | Ensures dispute resolution capacity |
|
|
36
|
+
| **Configure Buy Guard** | Set purchase restrictions | Restrict who can buy the service | Controls service access |
|
|
37
|
+
| **Customer Required Info** | Set mandatory fields | Collect delivery/contact info | Ensures order completeness |
|
|
38
|
+
| **Create Order** | Customer purchase flow | Place orders and make payment | Core transaction functionality |
|
|
39
|
+
| **Receive Compensation** | Withdraw dispute funds | Collect available compensation | Enables fund recovery |
|
|
40
|
+
| **Owner Receive Objects** | Unwrap and collect payments | Receive service revenue | Completes value transfer cycle |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Complete Tool Call Structure
|
|
45
|
+
|
|
46
|
+
Service operations use the following top-level structure:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"operation_type": "service",
|
|
51
|
+
"data": { ... }, // Service data definition
|
|
52
|
+
"env": { ... }, // Execution environment (optional)
|
|
53
|
+
"submission": { ... } // Guard verification submission (optional)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Sub-feature 1: Create Service
|
|
60
|
+
|
|
61
|
+
### Feature Description
|
|
62
|
+
|
|
63
|
+
Create a new Service object. Newly created services are in unpublished state by default. After publishing, customers can place orders, but certain fields become immutable.
|
|
64
|
+
|
|
65
|
+
### Parameter Description
|
|
66
|
+
|
|
67
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
68
|
+
|----------|------|------|------|------|
|
|
69
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
70
|
+
| `data.object.name` | string | No | Service name (local) | Max 64 characters |
|
|
71
|
+
| `data.object.tags` | string[] | No | Tags array | Max 50 tags |
|
|
72
|
+
| `data.object.onChain` | boolean | No | Sync name to chain | Default false |
|
|
73
|
+
| `data.object.replaceExistName` | boolean | No | Overwrite existing name | Default false |
|
|
74
|
+
| `data.object.type_parameter` | string | No | Payment token type | Default "0x2::wow::WOW" |
|
|
75
|
+
| `data.object.permission` | object/string | No | Permission object | Reference or create new |
|
|
76
|
+
| `data.description` | string | No | Service description | |
|
|
77
|
+
| `data.location` | string | No | Service location | |
|
|
78
|
+
| `env.account` | string | No | Use specified account | Empty string '' uses default |
|
|
79
|
+
| `env.network` | enum | No | Network selection | "localnet" or "testnet" |
|
|
80
|
+
|
|
81
|
+
### Important Notes
|
|
82
|
+
|
|
83
|
+
⚠️ **After publishing, these fields become immutable:** `machine`, `order_allocators`, `arbitrations`.
|
|
84
|
+
|
|
85
|
+
⚠️ **`type_parameter` defines the payment token type** accepted by this service.
|
|
86
|
+
|
|
87
|
+
### Return Result
|
|
88
|
+
|
|
89
|
+
Returns transaction block information (WowTransactionBlockSchema).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Schema Tree
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
service (Service Object)
|
|
97
|
+
├── operation_type: "service" (fixed value)
|
|
98
|
+
├── data (Service data definition)
|
|
99
|
+
│ ├── object (object definition, required)
|
|
100
|
+
│ │ ├── Option 1: NameOrAddress (string) - reference existing object
|
|
101
|
+
│ │ │ └── "object_name" or "0x..." (64 hex chars)
|
|
102
|
+
│ │ └── Option 2: TypeNamedObjectWithPermission (object) - create new
|
|
103
|
+
│ │ ├── name (string, optional) - object name, max 64 chars
|
|
104
|
+
│ │ ├── tags (string[], optional) - object tags
|
|
105
|
+
│ │ ├── onChain (boolean, optional) - sync name to chain
|
|
106
|
+
│ │ ├── replaceExistName (boolean, optional) - overwrite existing
|
|
107
|
+
│ │ ├── type_parameter (string, optional) - token type, default "0x2::wow::WOW"
|
|
108
|
+
│ │ └── permission (PermissionObject, optional)
|
|
109
|
+
│ │ ├── Option 1: NameOrAddress (string) - reference existing
|
|
110
|
+
│ │ └── Option 2: NamedObjectWithDescription (object) - create new
|
|
111
|
+
│ │ ├── name (string, optional)
|
|
112
|
+
│ │ ├── tags (string[], optional)
|
|
113
|
+
│ │ ├── onChain (boolean, optional)
|
|
114
|
+
│ │ ├── replaceExistName (boolean, optional)
|
|
115
|
+
│ │ └── description (string, optional)
|
|
116
|
+
│ ├── order_new (OrderNew, optional) - create new order
|
|
117
|
+
│ │ ├── buy (Buy, required)
|
|
118
|
+
│ │ │ ├── items (ServiceBuyItem[], required) - purchase items
|
|
119
|
+
│ │ │ │ ├── name (string, required) - product name
|
|
120
|
+
│ │ │ │ ├── stock (number/string, required) - quantity
|
|
121
|
+
│ │ │ │ └── wip_hash (string, required) - WIP hash
|
|
122
|
+
│ │ │ ├── total_pay (CoinParam, required) - payment
|
|
123
|
+
│ │ │ │ ├── Option 1: { balance: number|string }
|
|
124
|
+
│ │ │ │ └── Option 2: { coin: string } - coin object ID
|
|
125
|
+
│ │ │ ├── discount (string, optional) - discount object ID/name
|
|
126
|
+
│ │ │ ├── payment_remark (string, optional)
|
|
127
|
+
│ │ │ └── payment_index (number, optional)
|
|
128
|
+
│ │ ├── agents (ManyAccountOrMark_Address, optional) - order agents
|
|
129
|
+
│ │ ├── order_required_info (string, optional) - contact ID or WTS proof
|
|
130
|
+
│ │ ├── transfer (AccountOrMark_Address, optional) - new owner
|
|
131
|
+
│ │ ├── namedNewOrder (NamedObject, optional) - order name
|
|
132
|
+
│ │ ├── namedNewAllocation (NamedObject, optional) - allocation name
|
|
133
|
+
│ │ └── namedNewProgress (NamedObject, optional) - progress name
|
|
134
|
+
│ ├── description (string, optional) - service description
|
|
135
|
+
│ ├── location (string, optional) - service location
|
|
136
|
+
│ ├── sales (Sales, optional) - manage products
|
|
137
|
+
│ │ ├── op (enum, required) - "add"|"set"|"remove"|"clear"
|
|
138
|
+
│ │ ├── sales (ServiceSale[], optional for add/set)
|
|
139
|
+
│ │ │ ├── name (string, required) - product name
|
|
140
|
+
│ │ │ ├── price (number/string, required) - price
|
|
141
|
+
│ │ │ ├── stock (number/string, required) - inventory
|
|
142
|
+
│ │ │ ├── suspension (boolean, required) - paused status
|
|
143
|
+
│ │ │ ├── wip (string, required) - WIP URL/path
|
|
144
|
+
│ │ │ └── wip_hash (string, required) - WIP hash, empty string "" means auto-use hash from WIP file
|
|
145
|
+
│ │ └── sales_name (string[], optional for remove) - names to remove
|
|
146
|
+
│ ├── repositories (ObjectsOp, optional) - manage repositories
|
|
147
|
+
│ ├── rewards (ObjectsOp, optional) - manage rewards
|
|
148
|
+
│ ├── arbitrations (ObjectsOp, optional) - manage arbitrations
|
|
149
|
+
│ ├── machine (NameOrAddress|null, optional) - bind machine
|
|
150
|
+
│ ├── discount (Discount, optional) - issue discount
|
|
151
|
+
│ │ ├── name (string, required)
|
|
152
|
+
│ │ ├── discount_type (number, required) - 0=RATES, 1=FIXED
|
|
153
|
+
│ │ ├── discount_value (number/string, required)
|
|
154
|
+
│ │ ├── benchmark (number/string, optional)
|
|
155
|
+
│ │ ├── time_ms_start (number, optional)
|
|
156
|
+
│ │ ├── time_ms_end (number, optional)
|
|
157
|
+
│ │ ├── count (number, optional)
|
|
158
|
+
│ │ ├── recipient (ManyAccountOrMark_Address, required)
|
|
159
|
+
│ │ └── transferable (boolean, optional)
|
|
160
|
+
│ ├── discount_destroy (NameOrAddress[], optional) - destroy discounts
|
|
161
|
+
│ ├── customer_required (string[], optional) - required customer info
|
|
162
|
+
│ ├── buy_guard (NameOrAddress|null, optional) - buy guard object ID or name
|
|
163
|
+
│ ├── order_allocators (Allocators|null, optional) - fund allocation
|
|
164
|
+
│ │ ├── description (string, required)
|
|
165
|
+
│ │ ├── threshold (number/string, required)
|
|
166
|
+
│ │ └── allocators (Allocator[], required)
|
|
167
|
+
│ │ ├── guard (NameOrAddress, required)
|
|
168
|
+
│ │ ├── sharing (SharingItem[], required)
|
|
169
|
+
│ │ │ ├── who (Recipient, required)
|
|
170
|
+
│ │ │ │ ├── Option 1: { GuardIdentifier: number }
|
|
171
|
+
│ │ │ │ ├── Option 2: { Entity: AccountOrMark_Address }
|
|
172
|
+
│ │ │ │ └── Option 3: { Signer: "signer" }
|
|
173
|
+
│ │ │ ├── sharing (number/string, required)
|
|
174
|
+
│ │ │ └── mode (enum, required) - "Amount"|"Rate"|"Surplus"
|
|
175
|
+
│ │ └── max (number/string, optional)
|
|
176
|
+
│ ├── compensation_fund_add (CoinParam, optional) - add compensation
|
|
177
|
+
│ ├── setting_locked_time_add (number, optional) - additional lock duration (ms) to extend 'setting_lock_duration'. Initial value is 30 days, can only be increased. Affects: rewards, arbitrations, and compensation_fund_receive
|
|
178
|
+
│ ├── compensation_fund_receive (ReceivedBalanceOrRecently, optional)
|
|
179
|
+
│ ├── owner_receive (ReceivedObjectsOrRecently, optional)
|
|
180
|
+
│ ├── um (NameOrAddress|null, optional) - contact object
|
|
181
|
+
│ ├── pause (boolean, optional) - pause orders
|
|
182
|
+
│ └── publish (boolean, optional) - publish service
|
|
183
|
+
├── env (optional, execution environment)
|
|
184
|
+
│ ├── account (string, optional) - account name/address, "" for default
|
|
185
|
+
│ ├── network (string, optional) - "localnet" or "testnet"
|
|
186
|
+
│ ├── permission_guard (string[], optional) - guard IDs
|
|
187
|
+
│ ├── no_cache (boolean, optional) - disable caching
|
|
188
|
+
│ └── referrer (string, optional) - referrer ID
|
|
189
|
+
└── submission (optional, submission data)
|
|
190
|
+
├── type: "submission" (fixed)
|
|
191
|
+
├── guard (array) - guards to verify
|
|
192
|
+
│ └── [{ object: "guard_id", impack: boolean }]
|
|
193
|
+
└── submission (array) - guard submissions
|
|
194
|
+
└── [{ guard: "guard_id", submission: [items] }]
|
|
195
|
+
└── guard_submission_items
|
|
196
|
+
├── identifier (number, 0-255)
|
|
197
|
+
├── b_submission (boolean)
|
|
198
|
+
├── value_type (number|string)
|
|
199
|
+
├── value (any)
|
|
200
|
+
└── name (string, optional)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Creating a Sellable Service: Step-by-Step Guide
|
|
206
|
+
|
|
207
|
+
Building a fully functional, sellable Service requires several components working together. Follow these steps to create a complete service marketplace listing:
|
|
208
|
+
|
|
209
|
+
### Step 0: Prerequisites (Optional but Recommended)
|
|
210
|
+
|
|
211
|
+
Before creating your Service, you may need to set up these foundational components:
|
|
212
|
+
|
|
213
|
+
1. **Permission Object** - Controls who can manage the Service
|
|
214
|
+
- See [Permission](permission.md) for creating permission objects
|
|
215
|
+
- If not specified, a new Permission will be created automatically
|
|
216
|
+
|
|
217
|
+
2. **Guard Objects** - Used in Order Allocators for conditional fund distribution
|
|
218
|
+
- See [Guard](guard.md) for creating Guard objects
|
|
219
|
+
- Example: Create an "always_true_guard" that always passes verification
|
|
220
|
+
|
|
221
|
+
### Step 1: Create the Service Object
|
|
222
|
+
|
|
223
|
+
Create a basic Service object with name, description, and optional configuration.
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"operation_type": "service",
|
|
228
|
+
"data": {
|
|
229
|
+
"object": {
|
|
230
|
+
"name": "my_service",
|
|
231
|
+
"description": "My service description"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Step 2: Configure Machine (Order Processing Workflow)
|
|
238
|
+
|
|
239
|
+
Bind a published Machine to define how orders are processed. The Machine represents your service delivery workflow.
|
|
240
|
+
|
|
241
|
+
**Prerequisites:**
|
|
242
|
+
- Create a Machine using [Machine](machine.md) operations
|
|
243
|
+
- Publish the Machine before binding
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"operation_type": "service",
|
|
248
|
+
"data": {
|
|
249
|
+
"object": "my_service",
|
|
250
|
+
"machine": "my_published_machine"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Step 3: Configure Order Allocators (Fund Distribution)
|
|
256
|
+
|
|
257
|
+
Set up how order payments are distributed among recipients. This is a **critical step** before publishing your Service.
|
|
258
|
+
|
|
259
|
+
#### Understanding Order Allocators
|
|
260
|
+
|
|
261
|
+
Order Allocators define how funds from customer orders are distributed. Each allocator consists of:
|
|
262
|
+
|
|
263
|
+
| Component | Description | Required |
|
|
264
|
+
|-----------|-------------|----------|
|
|
265
|
+
| **Guard** | Validates allocation conditions | Yes |
|
|
266
|
+
| **Sharing** | Defines who receives funds and how much | Yes |
|
|
267
|
+
| **Mode** | "Rate" (percentage), "Amount" (fixed), or "Surplus" (remaining) | Yes |
|
|
268
|
+
| **Threshold** | Minimum amount to trigger allocation | Yes |
|
|
269
|
+
|
|
270
|
+
#### Step 3.1: Create Required Guards
|
|
271
|
+
|
|
272
|
+
Before configuring allocators, you need to create Guards that will validate allocation conditions.
|
|
273
|
+
|
|
274
|
+
**Option A: Simple Always-True Guard**
|
|
275
|
+
|
|
276
|
+
For testing or simple services where funds should always be allocated:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"operation_type": "guard",
|
|
281
|
+
"data": {
|
|
282
|
+
"namedNew": {
|
|
283
|
+
"name": "always_true_guard",
|
|
284
|
+
"tags": ["allocation", "simple"]
|
|
285
|
+
},
|
|
286
|
+
"description": "Always returns true for unconditional fund allocation",
|
|
287
|
+
"table": [
|
|
288
|
+
{
|
|
289
|
+
"identifier": 0,
|
|
290
|
+
"b_submission": false,
|
|
291
|
+
"value_type": "Bool",
|
|
292
|
+
"value": true
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"root": {
|
|
296
|
+
"type": "node",
|
|
297
|
+
"node": {
|
|
298
|
+
"type": "identifier",
|
|
299
|
+
"identifier": 0
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"env": {
|
|
304
|
+
"account": "",
|
|
305
|
+
"network": "testnet"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Option B: Order Completion Guard**
|
|
311
|
+
|
|
312
|
+
For production services, create Guards that verify order status before allowing fund withdrawal:
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"operation_type": "guard",
|
|
317
|
+
"data": {
|
|
318
|
+
"namedNew": {
|
|
319
|
+
"name": "order_completed_guard",
|
|
320
|
+
"tags": ["allocation", "withdraw"]
|
|
321
|
+
},
|
|
322
|
+
"description": "Verify order is in Completed status before allowing fund withdrawal. Submit order object ID.",
|
|
323
|
+
"table": [
|
|
324
|
+
{
|
|
325
|
+
"identifier": 0,
|
|
326
|
+
"b_submission": true,
|
|
327
|
+
"value_type": "Address",
|
|
328
|
+
"name": "order_id"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"identifier": 1,
|
|
332
|
+
"b_submission": false,
|
|
333
|
+
"value_type": "String",
|
|
334
|
+
"value": "Completed",
|
|
335
|
+
"name": "completed_node"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"root": {
|
|
339
|
+
"type": "node",
|
|
340
|
+
"node": {
|
|
341
|
+
"type": "logic_equal",
|
|
342
|
+
"nodes": [
|
|
343
|
+
{
|
|
344
|
+
"type": "query",
|
|
345
|
+
"query": 1253,
|
|
346
|
+
"object": {
|
|
347
|
+
"identifier": 0,
|
|
348
|
+
"convert_witness": 100
|
|
349
|
+
},
|
|
350
|
+
"parameters": []
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"type": "identifier",
|
|
354
|
+
"identifier": 1
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"env": {
|
|
361
|
+
"account": "",
|
|
362
|
+
"network": "testnet"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Key Points for Order Completion Guard:**
|
|
368
|
+
- Uses `convert_witness: 100` (TypeOrderProgress) to query the order's Progress object
|
|
369
|
+
- Query ID `1253` retrieves the current node name from Progress
|
|
370
|
+
- Validates that order has reached "Completed" status
|
|
371
|
+
|
|
372
|
+
See [Guard Query Instructions](guard.md#query-instructions-and-on-chain-object-access) for more details on cross-object queries.
|
|
373
|
+
|
|
374
|
+
#### Step 3.2: Configure Allocators in Service
|
|
375
|
+
|
|
376
|
+
Now configure the order_allocators with your Guards:
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"operation_type": "service",
|
|
381
|
+
"data": {
|
|
382
|
+
"object": "my_service",
|
|
383
|
+
"order_allocators": {
|
|
384
|
+
"description": "Order fund allocation - 100% to merchant after completion",
|
|
385
|
+
"threshold": 0,
|
|
386
|
+
"allocators": [
|
|
387
|
+
{
|
|
388
|
+
"guard": "order_completed_guard",
|
|
389
|
+
"sharing": [
|
|
390
|
+
{
|
|
391
|
+
"who": { "Signer": "signer" },
|
|
392
|
+
"sharing": 10000,
|
|
393
|
+
"mode": "Rate"
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### Advanced: Multiple Allocators for Complex Scenarios
|
|
404
|
+
|
|
405
|
+
For e-commerce with both merchant withdrawal and customer refund scenarios:
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"operation_type": "service",
|
|
410
|
+
"data": {
|
|
411
|
+
"object": "my_service",
|
|
412
|
+
"order_allocators": {
|
|
413
|
+
"description": "E-commerce fund allocation with withdraw and refund",
|
|
414
|
+
"threshold": 0,
|
|
415
|
+
"allocators": [
|
|
416
|
+
{
|
|
417
|
+
"guard": "merchant_withdraw_guard",
|
|
418
|
+
"sharing": [
|
|
419
|
+
{
|
|
420
|
+
"who": { "Signer": "signer" },
|
|
421
|
+
"sharing": 10000,
|
|
422
|
+
"mode": "Rate"
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"guard": "customer_refund_guard",
|
|
428
|
+
"sharing": [
|
|
429
|
+
{
|
|
430
|
+
"who": { "Entity": { "address": "" } },
|
|
431
|
+
"sharing": 10000,
|
|
432
|
+
"mode": "Rate"
|
|
433
|
+
}
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**Sharing Modes Explained:**
|
|
443
|
+
|
|
444
|
+
| Mode | Description | Example |
|
|
445
|
+
|------|-------------|---------|
|
|
446
|
+
| **Rate** | Percentage of total (0-10000 = 0%-100%) | `10000` = 100% |
|
|
447
|
+
| **Amount** | Fixed amount in token units | `50000000000` = 50 WOW |
|
|
448
|
+
| **Surplus** | Remaining funds after other allocations | Use for final recipient |
|
|
449
|
+
|
|
450
|
+
**Recipient Types:**
|
|
451
|
+
|
|
452
|
+
| Type | Format | Description |
|
|
453
|
+
|------|--------|-------------|
|
|
454
|
+
| **Signer** | `{ "Signer": "signer" }` | Transaction sender (merchant) |
|
|
455
|
+
| **Entity** | `{ "Entity": { "address": "..." } }` | Specific address |
|
|
456
|
+
| **GuardIdentifier** | `{ "GuardIdentifier": 0 }` | Address from Guard table |
|
|
457
|
+
|
|
458
|
+
⚠️ **Important:** After publishing the Service, `order_allocators` becomes **immutable**! Ensure your allocation logic is correct before publishing.
|
|
459
|
+
|
|
460
|
+
### Step 4: Configure WIP Files for Products (Optional but Recommended)
|
|
461
|
+
|
|
462
|
+
WIP (Witness Information Promise) files provide immutable, verifiable product/service descriptions. While optional, using WIP is strongly recommended for building trust.
|
|
463
|
+
|
|
464
|
+
**Two approaches:**
|
|
465
|
+
|
|
466
|
+
#### Approach A: No WIP (Simple Products)
|
|
467
|
+
- Set `wip` to empty string `""`
|
|
468
|
+
- Customers don't need to provide `wip_hash` when purchasing
|
|
469
|
+
|
|
470
|
+
#### Approach B: With WIP (Recommended)
|
|
471
|
+
1. **Generate WIP File** using the `wip_file` tool:
|
|
472
|
+
```json
|
|
473
|
+
{
|
|
474
|
+
"operation_type": "wip_file",
|
|
475
|
+
"data": {
|
|
476
|
+
"operation": "generate",
|
|
477
|
+
"markdown_text": "# Product Name\n\n## Description\nDetailed product description here...",
|
|
478
|
+
"images": ["https://example.com/product-image.jpg"],
|
|
479
|
+
"account": "",
|
|
480
|
+
"output_path": "./product.wip"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
2. **Upload WIP File** to your website or a publicly accessible HTTPS location
|
|
486
|
+
- The WIP file must be accessible via an HTTPS URL
|
|
487
|
+
- Example: `https://your-domain.com/product.wip`
|
|
488
|
+
- **Note**: When adding products to Service, you must provide a network-accessible HTTPS URL (local file paths are for testing only)
|
|
489
|
+
|
|
490
|
+
3. **Extract Hash** from the generated WIP file (automatically handled when using local file path)
|
|
491
|
+
|
|
492
|
+
4. **Add Product to Service**:
|
|
493
|
+
```json
|
|
494
|
+
{
|
|
495
|
+
"operation_type": "service",
|
|
496
|
+
"data": {
|
|
497
|
+
"object": "my_service",
|
|
498
|
+
"sales": {
|
|
499
|
+
"op": "add",
|
|
500
|
+
"sales": [
|
|
501
|
+
{
|
|
502
|
+
"name": "Product Name",
|
|
503
|
+
"price": 50000000,
|
|
504
|
+
"stock": 50,
|
|
505
|
+
"suspension": false,
|
|
506
|
+
"wip": "https://your-domain.com/product.wip",
|
|
507
|
+
"wip_hash": "46e1445b7f57210dd757bd40358f6a78308ef7494115eaad27510fb29de799e0"
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Important:** The `wip_hash` must match the hash extracted from your WIP file. Customers must provide the same hash when purchasing:
|
|
516
|
+
```json
|
|
517
|
+
{
|
|
518
|
+
"wip_hash": "46e1445b7f57210dd757bd40358f6a78308ef7494115eaad27510fb29de799e0"
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
See [Messenger](messenger.md) for more details on WIP file operations.
|
|
523
|
+
|
|
524
|
+
### Step 5: Configure Arbitration (Required if using Compensation Fund)
|
|
525
|
+
|
|
526
|
+
If you plan to use compensation funds for dispute resolution, you must configure at least one Arbitration object.
|
|
527
|
+
|
|
528
|
+
```json
|
|
529
|
+
{
|
|
530
|
+
"operation_type": "service",
|
|
531
|
+
"data": {
|
|
532
|
+
"object": "my_service",
|
|
533
|
+
"arbitrations": {
|
|
534
|
+
"op": "add",
|
|
535
|
+
"objects": ["arbitration_object_id"]
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
See [Arbitration](arbitration.md) for creating arbitration objects.
|
|
542
|
+
|
|
543
|
+
### Step 6: Add More Products/Services (Optional)
|
|
544
|
+
|
|
545
|
+
If you need to add more products after initial setup, use the same sales operation. See [Sub-feature 8: Manage Sales List](#sub-feature-8-manage-sales-list) for detailed examples including:
|
|
546
|
+
- Adding products without WIP (simple products)
|
|
547
|
+
- Adding products with WIP (verified products)
|
|
548
|
+
- Removing or clearing products
|
|
549
|
+
|
|
550
|
+
### Step 7: Configure Contact & Required User Information (Optional)
|
|
551
|
+
|
|
552
|
+
If your service requires customers to provide personal information (shipping address, phone number, email, etc.), you need to:
|
|
553
|
+
|
|
554
|
+
1. **Create a Contact Object** - Enables secure messaging between you and customers
|
|
555
|
+
- See [Contact](contact.md) for creating contact objects
|
|
556
|
+
- Contact allows encrypted communication for handling sensitive information
|
|
557
|
+
|
|
558
|
+
2. **Bind Contact to Service**:
|
|
559
|
+
```json
|
|
560
|
+
{
|
|
561
|
+
"operation_type": "service",
|
|
562
|
+
"data": {
|
|
563
|
+
"object": "my_service",
|
|
564
|
+
"contact": "my_contact_object"
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
3. **Set Required Information Fields** - Define what customer information is required when placing orders:
|
|
570
|
+
```json
|
|
571
|
+
{
|
|
572
|
+
"operation_type": "service",
|
|
573
|
+
"data": {
|
|
574
|
+
"object": "my_service",
|
|
575
|
+
"order_required_info": "shipping_address,phone_number,email"
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
**Common Required Information Fields:**
|
|
581
|
+
- `shipping_address` - Physical delivery address
|
|
582
|
+
- `phone_number` - Contact phone
|
|
583
|
+
- `email` - Email address
|
|
584
|
+
- `real_name` - Customer's real name
|
|
585
|
+
- `postal_code` - Postal/ZIP code
|
|
586
|
+
|
|
587
|
+
**Privacy & Security:**
|
|
588
|
+
- All sensitive information is transmitted through encrypted Messenger channels
|
|
589
|
+
- See [Messenger](messenger.md) for secure communication features
|
|
590
|
+
- Consider using WIP files to document your privacy policy
|
|
591
|
+
|
|
592
|
+
### Step 8: Publish the Service
|
|
593
|
+
|
|
594
|
+
Once all configurations are complete, publish the Service to make it available for customers.
|
|
595
|
+
|
|
596
|
+
⚠️ **Warning:** After publishing, `machine`, `order_allocators`, and `arbitrations` become immutable!
|
|
597
|
+
|
|
598
|
+
```json
|
|
599
|
+
{
|
|
600
|
+
"operation_type": "service",
|
|
601
|
+
"data": {
|
|
602
|
+
"object": "my_service",
|
|
603
|
+
"publish": true
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Complete Example: One-Step Service Creation
|
|
609
|
+
|
|
610
|
+
You can also create a complete service in a single call:
|
|
611
|
+
|
|
612
|
+
```json
|
|
613
|
+
{
|
|
614
|
+
"operation_type": "service",
|
|
615
|
+
"data": {
|
|
616
|
+
"object": {
|
|
617
|
+
"name": "complete_service"
|
|
618
|
+
},
|
|
619
|
+
"description": "A complete sellable service",
|
|
620
|
+
"machine": "my_published_machine",
|
|
621
|
+
"order_allocators": {
|
|
622
|
+
"description": "Default allocation",
|
|
623
|
+
"threshold": 0,
|
|
624
|
+
"allocators": [
|
|
625
|
+
{
|
|
626
|
+
"guard": "always_true_guard",
|
|
627
|
+
"sharing": [
|
|
628
|
+
{
|
|
629
|
+
"who": { "Signer": "signer" },
|
|
630
|
+
"sharing": 10000,
|
|
631
|
+
"mode": "Rate"
|
|
632
|
+
}
|
|
633
|
+
]
|
|
634
|
+
}
|
|
635
|
+
]
|
|
636
|
+
},
|
|
637
|
+
"arbitrations": {
|
|
638
|
+
"op": "add",
|
|
639
|
+
"objects": ["arbitration_id"]
|
|
640
|
+
},
|
|
641
|
+
"sales": {
|
|
642
|
+
"op": "add",
|
|
643
|
+
"sales": [
|
|
644
|
+
{
|
|
645
|
+
"name": "Product with WIP",
|
|
646
|
+
"price": 50000000,
|
|
647
|
+
"stock": 50,
|
|
648
|
+
"suspension": false,
|
|
649
|
+
"wip": "https://your-domain.com/product.wip",
|
|
650
|
+
"wip_hash": "46e1445b7f57210dd757bd40358f6a78308ef7494115eaad27510fb29de799e0"
|
|
651
|
+
}
|
|
652
|
+
]
|
|
653
|
+
},
|
|
654
|
+
"publish": true
|
|
655
|
+
},
|
|
656
|
+
"env": {
|
|
657
|
+
"network": "testnet"
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Related Documentation
|
|
663
|
+
|
|
664
|
+
- [Machine](machine.md) - Creating workflow templates
|
|
665
|
+
- [Guard](guard.md) - Creating validation guards
|
|
666
|
+
- [Arbitration](arbitration.md) - Dispute resolution
|
|
667
|
+
- [Messenger](messenger.md) - WIP file operations
|
|
668
|
+
- [Order](order.md) - Customer purchase flow
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
### Examples
|
|
673
|
+
|
|
674
|
+
#### Example 1.1: Basic Service Creation
|
|
675
|
+
|
|
676
|
+
**Prompt**: Create a new Service object with a local name "web3_consulting_service", set description to "Professional Web3 consulting services", and use default WOW token type.
|
|
677
|
+
|
|
678
|
+
```json
|
|
679
|
+
{
|
|
680
|
+
"operation_type": "service",
|
|
681
|
+
"data": {
|
|
682
|
+
"object": {
|
|
683
|
+
"name": "web3_consulting_service",
|
|
684
|
+
"tags": ["web3", "consulting", "blockchain"],
|
|
685
|
+
"type_parameter": "0x2::wow::WOW",
|
|
686
|
+
"permission": {
|
|
687
|
+
"name": "service_permission",
|
|
688
|
+
"description": "Permission for managing this service"
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
"description": "Professional Web3 consulting services",
|
|
692
|
+
"location": "Online"
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
#### Example 1.2: Minimal Service Creation
|
|
700
|
+
|
|
701
|
+
**Prompt**: Create a minimal Service object without a name, using all default settings.
|
|
702
|
+
|
|
703
|
+
```json
|
|
704
|
+
{
|
|
705
|
+
"operation_type": "service",
|
|
706
|
+
"data": {
|
|
707
|
+
"object": {}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
## Sub-feature 2: Configure Machine
|
|
715
|
+
|
|
716
|
+
### Feature Description
|
|
717
|
+
|
|
718
|
+
Bind a Machine (workflow template) to the Service. The Machine must be in published state.
|
|
719
|
+
|
|
720
|
+
### Parameter Description
|
|
721
|
+
|
|
722
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
723
|
+
|----------|------|------|------|------|
|
|
724
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
725
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
726
|
+
| `data.machine` | object/string/null | No | Machine configuration | Reference, create, or null to remove |
|
|
727
|
+
|
|
728
|
+
### Important Notes
|
|
729
|
+
|
|
730
|
+
⚠️ **Machine must be published** before binding to a Service.
|
|
731
|
+
|
|
732
|
+
⚠️ **After Service publication, `machine` field becomes immutable.**
|
|
733
|
+
|
|
734
|
+
⚠️ **Machine must be created separately** before binding. See [Machine](machine.md) for how to create and publish a Machine.
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
### Examples
|
|
739
|
+
|
|
740
|
+
#### Example 2.1: Reference Existing Machine
|
|
741
|
+
|
|
742
|
+
**Prompt**: Bind an existing Machine named "consulting_workflow" to the Service "web3_consulting_service".
|
|
743
|
+
|
|
744
|
+
```json
|
|
745
|
+
{
|
|
746
|
+
"operation_type": "service",
|
|
747
|
+
"data": {
|
|
748
|
+
"object": "web3_consulting_service",
|
|
749
|
+
"machine": "consulting_workflow"
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
---
|
|
755
|
+
|
|
756
|
+
#### Example 2.2: Remove Machine
|
|
757
|
+
|
|
758
|
+
**Prompt**: Remove the currently bound Machine from the Service. Note: Only works if Service is not yet published.
|
|
759
|
+
|
|
760
|
+
```json
|
|
761
|
+
{
|
|
762
|
+
"operation_type": "service",
|
|
763
|
+
"data": {
|
|
764
|
+
"object": "web3_consulting_service",
|
|
765
|
+
"machine": null
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
---
|
|
771
|
+
|
|
772
|
+
## Sub-feature 3: Configure Order Allocators
|
|
773
|
+
|
|
774
|
+
### Feature Description
|
|
775
|
+
|
|
776
|
+
Configure automatic fund allocation rules for orders. The allocators define how order funds are distributed.
|
|
777
|
+
|
|
778
|
+
### Parameter Description
|
|
779
|
+
|
|
780
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
781
|
+
|----------|------|------|------|------|
|
|
782
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
783
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
784
|
+
| `data.order_allocators.description` | string | Yes | Allocators description | Max 4000 BCS characters |
|
|
785
|
+
| `data.order_allocators.threshold` | number | Yes | Threshold amount in smallest token units | No decimals or negatives |
|
|
786
|
+
| `data.order_allocators.allocators` | array | Yes | Allocator list | 1-100 allocators |
|
|
787
|
+
| `data.order_allocators.allocators[].guard` | string | Yes | Guard object for this allocator | Guard name or ID |
|
|
788
|
+
| `data.order_allocators.allocators[].sharing` | array | Yes | Sharing items for this allocator | 1-100 sharing items |
|
|
789
|
+
| `data.order_allocators.allocators[].sharing[].who` | object | Yes | Recipient type | `{ GuardIdentifier: number }`, `{ Entity: { name_or_address: string } }`, or `{ Signer: "signer" }` |
|
|
790
|
+
| `data.order_allocators.allocators[].sharing[].sharing` | number | Yes | Sharing amount or rate in smallest units | No decimals or negatives |
|
|
791
|
+
| `data.order_allocators.allocators[].sharing[].mode` | string | Yes | Allocation mode | "Amount", "Rate", or "Surplus" |
|
|
792
|
+
| `data.order_allocators.allocators[].max` | number or null | No | Maximum allocation amount | No decimals or negatives |
|
|
793
|
+
|
|
794
|
+
### Important Notes
|
|
795
|
+
|
|
796
|
+
⚠️ **Sum of all sharing rates should be ≤ 10000 (100%).**
|
|
797
|
+
|
|
798
|
+
⚠️ **After Service publication, `order_allocators` becomes immutable.**
|
|
799
|
+
|
|
800
|
+
---
|
|
801
|
+
|
|
802
|
+
### Examples
|
|
803
|
+
|
|
804
|
+
#### Example 3.1: Configure Sharing Allocators
|
|
805
|
+
|
|
806
|
+
**Prompt**: Configure order allocators for web3_consulting_service with: 1) Description "Order fund allocation", 2) Threshold at 1000000000 (1 WOW), 3) One allocator with "order_guard" guard, 4) Sharing items: 70% to developer (Entity), 20% to platform (Entity), and 10% to signer.
|
|
807
|
+
|
|
808
|
+
```json
|
|
809
|
+
{
|
|
810
|
+
"operation_type": "service",
|
|
811
|
+
"data": {
|
|
812
|
+
"object": "web3_consulting_service",
|
|
813
|
+
"order_allocators": {
|
|
814
|
+
"description": "Order fund allocation",
|
|
815
|
+
"threshold": 1000000000,
|
|
816
|
+
"allocators": [
|
|
817
|
+
{
|
|
818
|
+
"guard": "order_guard",
|
|
819
|
+
"sharing": [
|
|
820
|
+
{
|
|
821
|
+
"who": {
|
|
822
|
+
"Entity": {
|
|
823
|
+
"name_or_address": "developer"
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
"sharing": 7000,
|
|
827
|
+
"mode": "Rate"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"who": {
|
|
831
|
+
"Entity": {
|
|
832
|
+
"name_or_address": "platform"
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
"sharing": 2000,
|
|
836
|
+
"mode": "Rate"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"who": {
|
|
840
|
+
"Signer": "signer"
|
|
841
|
+
},
|
|
842
|
+
"sharing": 1000,
|
|
843
|
+
"mode": "Rate"
|
|
844
|
+
}
|
|
845
|
+
],
|
|
846
|
+
"max": null
|
|
847
|
+
}
|
|
848
|
+
]
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
---
|
|
855
|
+
|
|
856
|
+
## Sub-feature 4: Manage Repository List
|
|
857
|
+
|
|
858
|
+
### Feature Description
|
|
859
|
+
|
|
860
|
+
Add, set, remove, or clear Repository objects from the Service.
|
|
861
|
+
|
|
862
|
+
### Parameter Description
|
|
863
|
+
|
|
864
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
865
|
+
|----------|------|------|------|------|
|
|
866
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
867
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
868
|
+
| `data.repositories.op` | string | Yes | Operation type | "add", "set", "remove", "clear" |
|
|
869
|
+
| `data.repositories.objects` | string[] | No | Object list | Required for add/set/remove |
|
|
870
|
+
|
|
871
|
+
---
|
|
872
|
+
|
|
873
|
+
### Examples
|
|
874
|
+
|
|
875
|
+
#### Example 4.1: Add Repository
|
|
876
|
+
|
|
877
|
+
**Prompt**: Add a Repository named "service_data_repo" to the Service.
|
|
878
|
+
|
|
879
|
+
```json
|
|
880
|
+
{
|
|
881
|
+
"operation_type": "service",
|
|
882
|
+
"data": {
|
|
883
|
+
"object": "web3_consulting_service",
|
|
884
|
+
"repositories": {
|
|
885
|
+
"op": "add",
|
|
886
|
+
"objects": ["service_data_repo"]
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
---
|
|
893
|
+
|
|
894
|
+
#### Example 4.2: Set Repositories (Overwrite)
|
|
895
|
+
|
|
896
|
+
**Prompt**: Set Repository list to ["repo_a", "repo_b"], replacing any existing repositories.
|
|
897
|
+
|
|
898
|
+
```json
|
|
899
|
+
{
|
|
900
|
+
"operation_type": "service",
|
|
901
|
+
"data": {
|
|
902
|
+
"object": "web3_consulting_service",
|
|
903
|
+
"repositories": {
|
|
904
|
+
"op": "set",
|
|
905
|
+
"objects": ["repo_a", "repo_b"]
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
---
|
|
912
|
+
|
|
913
|
+
#### Example 4.3: Remove Repository
|
|
914
|
+
|
|
915
|
+
**Prompt**: Remove "old_repo" from the Repository list.
|
|
916
|
+
|
|
917
|
+
```json
|
|
918
|
+
{
|
|
919
|
+
"operation_type": "service",
|
|
920
|
+
"data": {
|
|
921
|
+
"object": "web3_consulting_service",
|
|
922
|
+
"repositories": {
|
|
923
|
+
"op": "remove",
|
|
924
|
+
"objects": ["old_repo"]
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
---
|
|
931
|
+
|
|
932
|
+
#### Example 4.4: Clear All Repositories
|
|
933
|
+
|
|
934
|
+
**Prompt**: Clear all Repository objects from the Service.
|
|
935
|
+
|
|
936
|
+
```json
|
|
937
|
+
{
|
|
938
|
+
"operation_type": "service",
|
|
939
|
+
"data": {
|
|
940
|
+
"object": "web3_consulting_service",
|
|
941
|
+
"repositories": {
|
|
942
|
+
"op": "clear"
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## Sub-feature 5: Manage Reward List
|
|
951
|
+
|
|
952
|
+
### Feature Description
|
|
953
|
+
|
|
954
|
+
Add, set, remove, or clear Reward objects from the Service. Uses the same operation structure as repositories.
|
|
955
|
+
|
|
956
|
+
### Parameter Description
|
|
957
|
+
|
|
958
|
+
Same structure as Sub-feature 4 (Manage Repository List), but with `data.rewards` instead of `data.repositories`.
|
|
959
|
+
|
|
960
|
+
---
|
|
961
|
+
|
|
962
|
+
### Examples
|
|
963
|
+
|
|
964
|
+
#### Example 5.1: Add Reward
|
|
965
|
+
|
|
966
|
+
**Prompt**: Add a Reward object named "loyalty_reward" to the Service.
|
|
967
|
+
|
|
968
|
+
```json
|
|
969
|
+
{
|
|
970
|
+
"operation_type": "service",
|
|
971
|
+
"data": {
|
|
972
|
+
"object": "web3_consulting_service",
|
|
973
|
+
"rewards": {
|
|
974
|
+
"op": "add",
|
|
975
|
+
"objects": ["loyalty_reward"]
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
---
|
|
982
|
+
|
|
983
|
+
## Sub-feature 6: Manage Arbitration List
|
|
984
|
+
|
|
985
|
+
### Feature Description
|
|
986
|
+
|
|
987
|
+
Add, set, remove, or clear Arbitration objects from the Service. Uses the same operation structure as repositories.
|
|
988
|
+
|
|
989
|
+
### Parameter Description
|
|
990
|
+
|
|
991
|
+
Same structure as Sub-feature 4 (Manage Repository List), but with `data.arbitrations` instead of `data.repositories`.
|
|
992
|
+
|
|
993
|
+
---
|
|
994
|
+
|
|
995
|
+
### Examples
|
|
996
|
+
|
|
997
|
+
#### Example 6.1: Add Arbitration
|
|
998
|
+
|
|
999
|
+
**Prompt**: Add an Arbitration object named "dispute_resolution" to the Service.
|
|
1000
|
+
|
|
1001
|
+
```json
|
|
1002
|
+
{
|
|
1003
|
+
"operation_type": "service",
|
|
1004
|
+
"data": {
|
|
1005
|
+
"object": "web3_consulting_service",
|
|
1006
|
+
"arbitrations": {
|
|
1007
|
+
"op": "add",
|
|
1008
|
+
"objects": ["dispute_resolution"]
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
---
|
|
1015
|
+
|
|
1016
|
+
## Sub-feature 7: Configure Contact (um)
|
|
1017
|
+
|
|
1018
|
+
### Feature Description
|
|
1019
|
+
|
|
1020
|
+
Bind a Contact (instant messaging) object to the Service.
|
|
1021
|
+
|
|
1022
|
+
### Parameter Description
|
|
1023
|
+
|
|
1024
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1025
|
+
|----------|------|------|------|------|
|
|
1026
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1027
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1028
|
+
| `data.um` | object/string/null | No | Contact configuration | Reference, create, or null to remove |
|
|
1029
|
+
|
|
1030
|
+
---
|
|
1031
|
+
|
|
1032
|
+
### Examples
|
|
1033
|
+
|
|
1034
|
+
#### Example 7.1: Reference Existing Contact
|
|
1035
|
+
|
|
1036
|
+
**Prompt**: Bind an existing Contact named "service_support" to the Service.
|
|
1037
|
+
|
|
1038
|
+
```json
|
|
1039
|
+
{
|
|
1040
|
+
"operation_type": "service",
|
|
1041
|
+
"data": {
|
|
1042
|
+
"object": "web3_consulting_service",
|
|
1043
|
+
"um": "service_support"
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
---
|
|
1049
|
+
|
|
1050
|
+
#### Example 7.2: Remove Contact
|
|
1051
|
+
|
|
1052
|
+
**Prompt**: Remove the currently bound Contact from the Service.
|
|
1053
|
+
|
|
1054
|
+
```json
|
|
1055
|
+
{
|
|
1056
|
+
"operation_type": "service",
|
|
1057
|
+
"data": {
|
|
1058
|
+
"object": "web3_consulting_service",
|
|
1059
|
+
"um": null
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
---
|
|
1065
|
+
|
|
1066
|
+
## Sub-feature 8: Manage Sales List
|
|
1067
|
+
|
|
1068
|
+
### Feature Description
|
|
1069
|
+
|
|
1070
|
+
Add, set, remove, or clear sales products/services from the Service. Each sales item can optionally include a WIP (Witness Information Promise) file that provides immutable, verifiable product/service descriptions.
|
|
1071
|
+
|
|
1072
|
+
### Parameter Description
|
|
1073
|
+
|
|
1074
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1075
|
+
|----------|------|------|------|------|
|
|
1076
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1077
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1078
|
+
| `data.sales.op` | string | Yes | Operation type | "add", "set", "remove", "clear" |
|
|
1079
|
+
| `data.sales.sales` | array | No | Sales items list | Required for add/set |
|
|
1080
|
+
| `data.sales.sales[].name` | string | Yes | Product/service name | Max 64 characters |
|
|
1081
|
+
| `data.sales.sales[].price` | number/string | Yes | Price in smallest token units | No decimals |
|
|
1082
|
+
| `data.sales.sales[].stock` | number/string | Yes | Inventory quantity | No decimals |
|
|
1083
|
+
| `data.sales.sales[].wip` | string | Yes | WIP file URL or local path | Empty string "" for no WIP |
|
|
1084
|
+
| `data.sales.sales[].wip_hash` | string | No | WIP file hash | Auto-extracted from local WIP files |
|
|
1085
|
+
| `data.sales.sales[].suspension` | boolean | Yes | Whether sale is suspended | |
|
|
1086
|
+
| `data.sales.sales_name` | string[] | No | Names to remove | Required for remove |
|
|
1087
|
+
|
|
1088
|
+
### Important Notes About WIP
|
|
1089
|
+
|
|
1090
|
+
**What is WIP?**
|
|
1091
|
+
WIP (Witness Information Promise) is a cryptographically signed JSON file that contains product/service descriptions, images, and metadata. It ensures:
|
|
1092
|
+
- **Immutability**: Once created, the content cannot be altered
|
|
1093
|
+
- **Verifiability**: Customers can verify the product description matches what was promised
|
|
1094
|
+
- **Trust**: Builds confidence between buyers and sellers
|
|
1095
|
+
|
|
1096
|
+
**WIP Usage Modes:**
|
|
1097
|
+
|
|
1098
|
+
1. **Without WIP** (Simple products):
|
|
1099
|
+
- Set `wip` to empty string `""`
|
|
1100
|
+
- No `wip_hash` required
|
|
1101
|
+
- Customers purchase without WIP verification
|
|
1102
|
+
|
|
1103
|
+
2. **With WIP** (Recommended for valuable products):
|
|
1104
|
+
- Set `wip` to a local `.wip` file path or HTTPS URL
|
|
1105
|
+
- Hash is automatically extracted from local WIP files
|
|
1106
|
+
- Customers must provide matching `wip_hash` when purchasing
|
|
1107
|
+
|
|
1108
|
+
---
|
|
1109
|
+
|
|
1110
|
+
### Examples
|
|
1111
|
+
|
|
1112
|
+
#### Example 8.1: Add Sales Item Without WIP (Simple Product)
|
|
1113
|
+
|
|
1114
|
+
**Prompt**: Add a simple product without WIP verification. Customers can purchase without providing WIP hash.
|
|
1115
|
+
|
|
1116
|
+
```json
|
|
1117
|
+
{
|
|
1118
|
+
"operation_type": "service",
|
|
1119
|
+
"data": {
|
|
1120
|
+
"object": "web3_consulting_service",
|
|
1121
|
+
"sales": {
|
|
1122
|
+
"op": "add",
|
|
1123
|
+
"sales": [
|
|
1124
|
+
{
|
|
1125
|
+
"name": "simple_product",
|
|
1126
|
+
"price": 30000000,
|
|
1127
|
+
"stock": 100,
|
|
1128
|
+
"suspension": false,
|
|
1129
|
+
"wip": "",
|
|
1130
|
+
"wip_hash": ""
|
|
1131
|
+
}
|
|
1132
|
+
]
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
---
|
|
1139
|
+
|
|
1140
|
+
#### Example 8.2: Add Sales Item With WIP (Recommended)
|
|
1141
|
+
|
|
1142
|
+
**Prompt**: Add a product with WIP file. First generate the WIP file, then reference it when adding the product.
|
|
1143
|
+
|
|
1144
|
+
**Step 1: Generate WIP File**
|
|
1145
|
+
```json
|
|
1146
|
+
{
|
|
1147
|
+
"operation_type": "wip_file",
|
|
1148
|
+
"data": {
|
|
1149
|
+
"operation": "generate",
|
|
1150
|
+
"markdown_text": "# Three-Body Problem (三体)\n\n## Book Information\n- **Author**: Liu Cixin\n- **Genre**: Science Fiction\n- **Pages**: 302\n\n## Description\nThe Three-Body Problem is a science fiction novel that explores humanity's first contact with an alien civilization...",
|
|
1151
|
+
"images": ["https://example.com/three-body-cover.jpg"],
|
|
1152
|
+
"account": "",
|
|
1153
|
+
"output_path": "./three_body.wip"
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
**Step 2: Add Product with WIP**
|
|
1159
|
+
```json
|
|
1160
|
+
{
|
|
1161
|
+
"operation_type": "service",
|
|
1162
|
+
"data": {
|
|
1163
|
+
"object": "book_store_service",
|
|
1164
|
+
"sales": {
|
|
1165
|
+
"op": "add",
|
|
1166
|
+
"sales": [
|
|
1167
|
+
{
|
|
1168
|
+
"name": "三体(带WIP)",
|
|
1169
|
+
"price": 50000000,
|
|
1170
|
+
"stock": 50,
|
|
1171
|
+
"suspension": false,
|
|
1172
|
+
"wip": "https://your-domain.com/three_body.wip",
|
|
1173
|
+
"wip_hash": "46e1445b7f57210dd757bd40358f6a78308ef7494115eaad27510fb29de799e0"
|
|
1174
|
+
}
|
|
1175
|
+
]
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
```
|
|
1180
|
+
|
|
1181
|
+
**Step 3: Customer Purchase (Must Provide WIP Hash)**
|
|
1182
|
+
```json
|
|
1183
|
+
{
|
|
1184
|
+
"operation_type": "service",
|
|
1185
|
+
"data": {
|
|
1186
|
+
"object": "book_store_service",
|
|
1187
|
+
"order_new": {
|
|
1188
|
+
"buy": {
|
|
1189
|
+
"items": [
|
|
1190
|
+
{
|
|
1191
|
+
"name": "三体(带WIP)",
|
|
1192
|
+
"stock": 1,
|
|
1193
|
+
"wip_hash": "46e1445b7f57210dd757bd40358f6a78308ef7494115eaad27510fb29de799e0"
|
|
1194
|
+
}
|
|
1195
|
+
],
|
|
1196
|
+
"total_pay": {
|
|
1197
|
+
"balance": 50000000
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
"order_required_info": ""
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
---
|
|
1207
|
+
|
|
1208
|
+
#### Example 8.3: Add Multiple Sales Items (Mixed WIP and Non-WIP)
|
|
1209
|
+
|
|
1210
|
+
**Prompt**: Add multiple products, some with WIP and some without.
|
|
1211
|
+
|
|
1212
|
+
```json
|
|
1213
|
+
{
|
|
1214
|
+
"operation_type": "service",
|
|
1215
|
+
"data": {
|
|
1216
|
+
"object": "web3_consulting_service",
|
|
1217
|
+
"sales": {
|
|
1218
|
+
"op": "add",
|
|
1219
|
+
"sales": [
|
|
1220
|
+
{
|
|
1221
|
+
"name": "basic_consulting",
|
|
1222
|
+
"price": 100000000,
|
|
1223
|
+
"stock": 100,
|
|
1224
|
+
"suspension": false,
|
|
1225
|
+
"wip": "",
|
|
1226
|
+
"wip_hash": ""
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"name": "premium_consulting",
|
|
1230
|
+
"price": 500000000,
|
|
1231
|
+
"stock": 20,
|
|
1232
|
+
"suspension": false,
|
|
1233
|
+
"wip": "https://your-domain.com/premium_service.wip",
|
|
1234
|
+
"wip_hash": "abc123def456..."
|
|
1235
|
+
}
|
|
1236
|
+
]
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
---
|
|
1243
|
+
|
|
1244
|
+
#### Example 8.4: Remove Sales Item
|
|
1245
|
+
|
|
1246
|
+
**Prompt**: Remove the "old_product" sales item from the Service.
|
|
1247
|
+
|
|
1248
|
+
```json
|
|
1249
|
+
{
|
|
1250
|
+
"operation_type": "service",
|
|
1251
|
+
"data": {
|
|
1252
|
+
"object": "web3_consulting_service",
|
|
1253
|
+
"sales": {
|
|
1254
|
+
"op": "remove",
|
|
1255
|
+
"sales_name": ["old_product"]
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
---
|
|
1262
|
+
|
|
1263
|
+
#### Example 8.5: Clear All Sales
|
|
1264
|
+
|
|
1265
|
+
**Prompt**: Clear all sales items from the Service.
|
|
1266
|
+
|
|
1267
|
+
```json
|
|
1268
|
+
{
|
|
1269
|
+
"operation_type": "service",
|
|
1270
|
+
"data": {
|
|
1271
|
+
"object": "web3_consulting_service",
|
|
1272
|
+
"sales": {
|
|
1273
|
+
"op": "clear"
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
---
|
|
1280
|
+
|
|
1281
|
+
## Sub-feature 9: Issue Discount
|
|
1282
|
+
|
|
1283
|
+
### Feature Description
|
|
1284
|
+
|
|
1285
|
+
Create and issue a new discount coupon for the Service.
|
|
1286
|
+
|
|
1287
|
+
### Parameter Description
|
|
1288
|
+
|
|
1289
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1290
|
+
|----------|------|------|------|------|
|
|
1291
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1292
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1293
|
+
| `data.discount.name` | string | Yes | Discount name | |
|
|
1294
|
+
| `data.discount.discount_type` | number | Yes | Discount type | 0 (RATES) or 1 (FIXED) |
|
|
1295
|
+
| `data.discount.discount_value` | number/string | Yes | Discount value | Rate: 0-10000 (e.g., 1000 means 10% discount); Fixed: amount in smallest token unit |
|
|
1296
|
+
| `data.discount.benchmark` | number/string | No | Minimum amount threshold | In smallest token unit | |
|
|
1297
|
+
| `data.discount.time_ms_start` | number | No | Start time (ms timestamp) | |
|
|
1298
|
+
| `data.discount.time_ms_end` | number | No | End time (ms timestamp) | |
|
|
1299
|
+
| `data.discount.count` | number | No | Usage count limit | |
|
|
1300
|
+
| `data.discount.recipient.entities` | string[] | Yes | Eligible recipients | Account names or addresses |
|
|
1301
|
+
| `data.discount.transferable` | boolean | No | Whether transferable | |
|
|
1302
|
+
|
|
1303
|
+
---
|
|
1304
|
+
|
|
1305
|
+
### Examples
|
|
1306
|
+
|
|
1307
|
+
#### Example 9.1: Rate Discount (Percentage)
|
|
1308
|
+
|
|
1309
|
+
**Prompt**: Issue a rate discount named "new_user_20off" with 20% off (discount_value=2000), minimum purchase of 100 WOW (benchmark=100000000000), valid for 30 days, limited to 1000 uses, eligible for alice and bob. Note: 20% discount uses 2000 (not 0.2) since rate discounts use 0-10000 scale where 10000 means 100%. Use discount_type=0 for rate discounts.
|
|
1310
|
+
|
|
1311
|
+
```json
|
|
1312
|
+
{
|
|
1313
|
+
"operation_type": "service",
|
|
1314
|
+
"data": {
|
|
1315
|
+
"object": "web3_consulting_service",
|
|
1316
|
+
"discount": {
|
|
1317
|
+
"name": "new_user_20off",
|
|
1318
|
+
"discount_type": 0,
|
|
1319
|
+
"discount_value": 2000,
|
|
1320
|
+
"benchmark": 100000000000,
|
|
1321
|
+
"time_ms_start": 1735689600000,
|
|
1322
|
+
"time_ms_end": 1738368000000,
|
|
1323
|
+
"count": 1000,
|
|
1324
|
+
"recipient": {
|
|
1325
|
+
"entities": ["alice", "bob"]
|
|
1326
|
+
},
|
|
1327
|
+
"transferable": false
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
---
|
|
1334
|
+
|
|
1335
|
+
#### Example 9.2: Fixed Amount Discount
|
|
1336
|
+
|
|
1337
|
+
**Prompt**: Issue a fixed discount named "holiday_50off" with 50 WOW off (discount_value=50000000000), transferable, and eligible for everyone. Note: Fixed discount uses smallest token unit (not 50, but 50000000000 for 50 WOW with 9 decimals). Use discount_type=1 for fixed discounts.
|
|
1338
|
+
|
|
1339
|
+
```json
|
|
1340
|
+
{
|
|
1341
|
+
"operation_type": "service",
|
|
1342
|
+
"data": {
|
|
1343
|
+
"object": "web3_consulting_service",
|
|
1344
|
+
"discount": {
|
|
1345
|
+
"name": "holiday_50off",
|
|
1346
|
+
"discount_type": 1,
|
|
1347
|
+
"discount_value": 50000000000,
|
|
1348
|
+
"recipient": {
|
|
1349
|
+
"entities": []
|
|
1350
|
+
},
|
|
1351
|
+
"transferable": true
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
```
|
|
1356
|
+
|
|
1357
|
+
---
|
|
1358
|
+
|
|
1359
|
+
## Sub-feature 10: Destroy Discount
|
|
1360
|
+
|
|
1361
|
+
### Feature Description
|
|
1362
|
+
|
|
1363
|
+
Destroy existing discount objects.
|
|
1364
|
+
|
|
1365
|
+
### Parameter Description
|
|
1366
|
+
|
|
1367
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1368
|
+
|----------|------|------|------|------|
|
|
1369
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1370
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1371
|
+
| `data.discount_destroy` | string[] | Yes | Discount object names or IDs to destroy | Array of object names or addresses |
|
|
1372
|
+
|
|
1373
|
+
---
|
|
1374
|
+
|
|
1375
|
+
### Examples
|
|
1376
|
+
|
|
1377
|
+
#### Example 10.1: Destroy Discount
|
|
1378
|
+
|
|
1379
|
+
**Prompt**: Destroy the discount object named "expired_coupon".
|
|
1380
|
+
|
|
1381
|
+
```json
|
|
1382
|
+
{
|
|
1383
|
+
"operation_type": "service",
|
|
1384
|
+
"data": {
|
|
1385
|
+
"object": "web3_consulting_service",
|
|
1386
|
+
"discount_destroy": ["expired_coupon"]
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
```
|
|
1390
|
+
|
|
1391
|
+
---
|
|
1392
|
+
|
|
1393
|
+
## Sub-feature 11: Add Compensation Fund
|
|
1394
|
+
|
|
1395
|
+
### Feature Description
|
|
1396
|
+
|
|
1397
|
+
Add funds to the compensation fund pool. These funds are used for arbitration compensation when resolving order disputes.
|
|
1398
|
+
|
|
1399
|
+
👉 **For complete arbitration workflow, see [Arbitration - Complete Workflow](arbitration.md#complete-arbitration-workflow-example)**
|
|
1400
|
+
|
|
1401
|
+
**Quick Overview:**
|
|
1402
|
+
1. Service provider adds compensation funds (this operation)
|
|
1403
|
+
2. Buyer creates dispute via Arbitration
|
|
1404
|
+
3. Arbitration process completes with ruling
|
|
1405
|
+
4. Buyer claims compensation via Order
|
|
1406
|
+
|
|
1407
|
+
### Parameter Description
|
|
1408
|
+
|
|
1409
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1410
|
+
|----------|------|------|------|------|
|
|
1411
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1412
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1413
|
+
| `data.compensation_fund_add.balance` | number/string | No | Amount value | Pay from transaction account |
|
|
1414
|
+
| `data.compensation_fund_add.coin` | string | No | Coin object ID | Use specified Coin |
|
|
1415
|
+
| `data.setting_locked_time_add` | number | No | Additional lock duration (ms) to extend 'setting_lock_duration'. Initial value is 30 days, can only be increased. Affects: rewards, arbitrations, and compensation_fund_receive |
|
|
1416
|
+
|
|
1417
|
+
---
|
|
1418
|
+
|
|
1419
|
+
### Examples
|
|
1420
|
+
|
|
1421
|
+
#### Example 11.1: Add Compensation Fund with Balance
|
|
1422
|
+
|
|
1423
|
+
**Prompt**: Add 1000 WOW tokens (balance=1000000000000) to the compensation fund with a lock time of 24 hours (86400000 ms). Note: Amount is in smallest token unit (9 decimals for WOW).
|
|
1424
|
+
|
|
1425
|
+
```json
|
|
1426
|
+
{
|
|
1427
|
+
"operation_type": "service",
|
|
1428
|
+
"data": {
|
|
1429
|
+
"object": "web3_consulting_service",
|
|
1430
|
+
"compensation_fund_add": {
|
|
1431
|
+
"balance": 1000000000000
|
|
1432
|
+
},
|
|
1433
|
+
"setting_locked_time_add": 86400000
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
---
|
|
1439
|
+
|
|
1440
|
+
#### Example 11.2: Add Compensation Fund with Coin Object
|
|
1441
|
+
|
|
1442
|
+
**Prompt**: Add a specific Coin object to the compensation fund.
|
|
1443
|
+
|
|
1444
|
+
```json
|
|
1445
|
+
{
|
|
1446
|
+
"operation_type": "service",
|
|
1447
|
+
"data": {
|
|
1448
|
+
"object": "web3_consulting_service",
|
|
1449
|
+
"compensation_fund_add": {
|
|
1450
|
+
"coin": "0x7890...coin_object"
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
```
|
|
1455
|
+
|
|
1456
|
+
---
|
|
1457
|
+
|
|
1458
|
+
## Sub-feature 12: Configure Customer Required Info
|
|
1459
|
+
|
|
1460
|
+
### Feature Description
|
|
1461
|
+
|
|
1462
|
+
Set the information customers must provide when placing orders.
|
|
1463
|
+
|
|
1464
|
+
### Parameter Description
|
|
1465
|
+
|
|
1466
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1467
|
+
|----------|------|------|------|------|
|
|
1468
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1469
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1470
|
+
| `data.customer_required` | string[] | No | Required fields | e.g., ["phone", "email"] |
|
|
1471
|
+
|
|
1472
|
+
---
|
|
1473
|
+
|
|
1474
|
+
### Examples
|
|
1475
|
+
|
|
1476
|
+
#### Example 12.1: Set Required Info
|
|
1477
|
+
|
|
1478
|
+
**Prompt**: Configure customer to provide phone, email, and delivery address when placing orders.
|
|
1479
|
+
|
|
1480
|
+
```json
|
|
1481
|
+
{
|
|
1482
|
+
"operation_type": "service",
|
|
1483
|
+
"data": {
|
|
1484
|
+
"object": "web3_consulting_service",
|
|
1485
|
+
"customer_required": ["phone", "email", "delivery_address"]
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
```
|
|
1489
|
+
|
|
1490
|
+
---
|
|
1491
|
+
|
|
1492
|
+
## Sub-feature 13: Pause/Resume Accepting Orders
|
|
1493
|
+
|
|
1494
|
+
### Feature Description
|
|
1495
|
+
|
|
1496
|
+
Pause or resume the Service from accepting new orders without unpublishing.
|
|
1497
|
+
|
|
1498
|
+
### Parameter Description
|
|
1499
|
+
|
|
1500
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1501
|
+
|----------|------|------|------|------|
|
|
1502
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1503
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1504
|
+
| `data.pause` | boolean | No | Pause flag | true=pause, false=resume |
|
|
1505
|
+
|
|
1506
|
+
---
|
|
1507
|
+
|
|
1508
|
+
### Examples
|
|
1509
|
+
|
|
1510
|
+
#### Example 13.1: Pause Accepting Orders
|
|
1511
|
+
|
|
1512
|
+
**Prompt**: Pause the Service from accepting new orders.
|
|
1513
|
+
|
|
1514
|
+
```json
|
|
1515
|
+
{
|
|
1516
|
+
"operation_type": "service",
|
|
1517
|
+
"data": {
|
|
1518
|
+
"object": "web3_consulting_service",
|
|
1519
|
+
"pause": true
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
---
|
|
1525
|
+
|
|
1526
|
+
#### Example 13.2: Resume Accepting Orders
|
|
1527
|
+
|
|
1528
|
+
**Prompt**: Resume the Service to accept new orders.
|
|
1529
|
+
|
|
1530
|
+
```json
|
|
1531
|
+
{
|
|
1532
|
+
"operation_type": "service",
|
|
1533
|
+
"data": {
|
|
1534
|
+
"object": "web3_consulting_service",
|
|
1535
|
+
"pause": false
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
---
|
|
1541
|
+
|
|
1542
|
+
## Sub-feature 14: Publish Service
|
|
1543
|
+
|
|
1544
|
+
### Feature Description
|
|
1545
|
+
|
|
1546
|
+
Publish the Service. After publishing, customers can place orders, but certain fields become immutable.
|
|
1547
|
+
|
|
1548
|
+
### Parameter Description
|
|
1549
|
+
|
|
1550
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1551
|
+
|----------|------|------|------|------|
|
|
1552
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1553
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1554
|
+
| `data.publish` | boolean | No | Publish flag | Set to true to publish |
|
|
1555
|
+
|
|
1556
|
+
### Important Notes
|
|
1557
|
+
|
|
1558
|
+
⚠️ **After publishing, these fields become immutable:** `machine`, `order_allocators`, `arbitrations`.
|
|
1559
|
+
|
|
1560
|
+
⚠️ **Ensure all configurations are correct before publishing.**
|
|
1561
|
+
|
|
1562
|
+
---
|
|
1563
|
+
|
|
1564
|
+
### Examples
|
|
1565
|
+
|
|
1566
|
+
#### Example 14.1: Publish Service
|
|
1567
|
+
|
|
1568
|
+
**Prompt**: Publish the Service so customers can start placing orders.
|
|
1569
|
+
|
|
1570
|
+
```json
|
|
1571
|
+
{
|
|
1572
|
+
"operation_type": "service",
|
|
1573
|
+
"data": {
|
|
1574
|
+
"object": "web3_consulting_service",
|
|
1575
|
+
"publish": true
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
---
|
|
1581
|
+
|
|
1582
|
+
## Sub-feature 15: Create Order
|
|
1583
|
+
|
|
1584
|
+
### Feature Description
|
|
1585
|
+
|
|
1586
|
+
Create a new order as a customer and make payment.
|
|
1587
|
+
|
|
1588
|
+
### Parameter Description
|
|
1589
|
+
|
|
1590
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1591
|
+
|----------|------|------|------|------|
|
|
1592
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1593
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1594
|
+
| `data.order_new.buy.items` | array | Yes | Items to purchase | At least one item |
|
|
1595
|
+
| `data.order_new.buy.items[].name` | string | Yes | Product/service name | |
|
|
1596
|
+
| `data.order_new.buy.items[].stock` | number/string | Yes | Quantity | |
|
|
1597
|
+
| `data.order_new.buy.items[].wip_hash` | string | Yes | WIP file hash | |
|
|
1598
|
+
| `data.order_new.buy.total_pay` | object | Yes | Payment amount | CoinParam |
|
|
1599
|
+
| `data.order_new.buy.discount` | string | No | Discount object | Name or ID |
|
|
1600
|
+
| `data.order_new.buy.payment_remark` | string | No | Payment remark | |
|
|
1601
|
+
| `data.order_new.buy.payment_index` | number | No | Payment index | |
|
|
1602
|
+
| `data.order_new.agents.entities` | string[] | No | Order agents | |
|
|
1603
|
+
| `data.order_new.order_required_info` | string | Yes | Contact or WTS Proof | |
|
|
1604
|
+
| `data.order_new.transfer` | string | No | New order owner | |
|
|
1605
|
+
| `data.order_new.namedNewOrder` | object | No | Order name | NamedObject |
|
|
1606
|
+
| `data.order_new.namedNewAllocation` | object | No | Allocation name | NamedObject |
|
|
1607
|
+
| `data.order_new.namedNewProgress` | object | No | Progress name | NamedObject |
|
|
1608
|
+
|
|
1609
|
+
---
|
|
1610
|
+
|
|
1611
|
+
### Examples
|
|
1612
|
+
|
|
1613
|
+
#### Example 15.1: Create Order
|
|
1614
|
+
|
|
1615
|
+
**Prompt**: Create an order for "basic_consulting" with quantity 1, pay 100 WOW (total_pay.balance=100000000000), use discount "new_user_20off", add payment remark, include the WIP hash from "service_desc.wip", and name the order "my_first_order". Note: Amount is in smallest token unit (9 decimals for WOW). The wip_hash must match the hash of the sales item's WIP file. See WIP section for how to generate and verify WIP files.
|
|
1616
|
+
|
|
1617
|
+
```json
|
|
1618
|
+
{
|
|
1619
|
+
"operation_type": "service",
|
|
1620
|
+
"data": {
|
|
1621
|
+
"object": "web3_consulting_service",
|
|
1622
|
+
"order_new": {
|
|
1623
|
+
"buy": {
|
|
1624
|
+
"items": [
|
|
1625
|
+
{
|
|
1626
|
+
"name": "basic_consulting",
|
|
1627
|
+
"stock": 1,
|
|
1628
|
+
"wip_hash": "sha256:abc123def456..."
|
|
1629
|
+
}
|
|
1630
|
+
],
|
|
1631
|
+
"total_pay": {
|
|
1632
|
+
"balance": 100000000000
|
|
1633
|
+
},
|
|
1634
|
+
"discount": "new_user_20off",
|
|
1635
|
+
"payment_remark": "First purchase"
|
|
1636
|
+
},
|
|
1637
|
+
"agents": {
|
|
1638
|
+
"entities": ["agent_account"]
|
|
1639
|
+
},
|
|
1640
|
+
"order_required_info": "customer_contact",
|
|
1641
|
+
"namedNewOrder": {
|
|
1642
|
+
"name": "my_first_order"
|
|
1643
|
+
},
|
|
1644
|
+
"namedNewAllocation": {
|
|
1645
|
+
"name": "order_allocation"
|
|
1646
|
+
},
|
|
1647
|
+
"namedNewProgress": {
|
|
1648
|
+
"name": "order_progress"
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
---
|
|
1656
|
+
|
|
1657
|
+
## Sub-feature 16: Receive Compensation Fund
|
|
1658
|
+
|
|
1659
|
+
### Feature Description
|
|
1660
|
+
|
|
1661
|
+
Receive compensation funds from orders.
|
|
1662
|
+
|
|
1663
|
+
### Parameter Description
|
|
1664
|
+
|
|
1665
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1666
|
+
|----------|------|------|------|------|
|
|
1667
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1668
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1669
|
+
| `data.compensation_fund_receive` | string/object | Yes | Receive configuration | "recently" or ReceivedBalance object |
|
|
1670
|
+
|
|
1671
|
+
---
|
|
1672
|
+
|
|
1673
|
+
### Examples
|
|
1674
|
+
|
|
1675
|
+
#### Example 16.1: Receive Recently Available Compensation
|
|
1676
|
+
|
|
1677
|
+
**Prompt**: Receive all compensation funds that became available recently.
|
|
1678
|
+
|
|
1679
|
+
```json
|
|
1680
|
+
{
|
|
1681
|
+
"operation_type": "service",
|
|
1682
|
+
"data": {
|
|
1683
|
+
"object": "web3_consulting_service",
|
|
1684
|
+
"compensation_fund_receive": "recently"
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
---
|
|
1690
|
+
|
|
1691
|
+
#### Example 16.2: Receive Specific Amount
|
|
1692
|
+
|
|
1693
|
+
**Prompt**: Receive specific amount from compensation funds using ReceivedBalance object. Note: Requires querying received balance records first.
|
|
1694
|
+
|
|
1695
|
+
```json
|
|
1696
|
+
{
|
|
1697
|
+
"operation_type": "service",
|
|
1698
|
+
"data": {
|
|
1699
|
+
"object": "web3_consulting_service",
|
|
1700
|
+
"compensation_fund_receive": {
|
|
1701
|
+
"balance": 100000000000,
|
|
1702
|
+
"token_type": "0x2::wow::WOW",
|
|
1703
|
+
"received": [
|
|
1704
|
+
{
|
|
1705
|
+
"id": "0x...",
|
|
1706
|
+
"balance": 100000000000,
|
|
1707
|
+
"payment": "0x..."
|
|
1708
|
+
}
|
|
1709
|
+
]
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
```
|
|
1714
|
+
|
|
1715
|
+
---
|
|
1716
|
+
|
|
1717
|
+
## Sub-feature 17: Owner Receive Objects
|
|
1718
|
+
|
|
1719
|
+
### Feature Description
|
|
1720
|
+
|
|
1721
|
+
Unwrap CoinWrapper and other objects received by the Service and send them to the owner of its Permission object.
|
|
1722
|
+
|
|
1723
|
+
### Parameter Description
|
|
1724
|
+
|
|
1725
|
+
| Parameter Path | Type | Required | Description | Constraints |
|
|
1726
|
+
|----------|------|------|------|------|
|
|
1727
|
+
| `operation_type` | string | Yes | Operation type | Fixed value "service" |
|
|
1728
|
+
| `data.object` | string | Yes | Reference existing Service | Service name or ID |
|
|
1729
|
+
| `data.owner_receive.type` | string | Yes | Receive type | "recently" or "objects" |
|
|
1730
|
+
| `data.owner_receive.objects` | string[] | No | Object list | Required for type "objects" |
|
|
1731
|
+
| `data.owner_receive.time_ms_ago` | number | No | Time range (ms) | |
|
|
1732
|
+
|
|
1733
|
+
---
|
|
1734
|
+
|
|
1735
|
+
### Examples
|
|
1736
|
+
|
|
1737
|
+
#### Example 17.1: Receive Recently Available Objects
|
|
1738
|
+
|
|
1739
|
+
**Prompt**: Unwrap and receive objects that became available in the last 24 hours.
|
|
1740
|
+
|
|
1741
|
+
```json
|
|
1742
|
+
{
|
|
1743
|
+
"operation_type": "service",
|
|
1744
|
+
"data": {
|
|
1745
|
+
"object": "web3_consulting_service",
|
|
1746
|
+
"owner_receive": {
|
|
1747
|
+
"type": "recently",
|
|
1748
|
+
"time_ms_ago": 86400000
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
```
|
|
1753
|
+
|
|
1754
|
+
---
|
|
1755
|
+
|
|
1756
|
+
#### Example 17.2: Receive Specific Objects
|
|
1757
|
+
|
|
1758
|
+
**Prompt**: Unwrap and receive specific CoinWrapper objects.
|
|
1759
|
+
|
|
1760
|
+
```json
|
|
1761
|
+
{
|
|
1762
|
+
"operation_type": "service",
|
|
1763
|
+
"data": {
|
|
1764
|
+
"object": "web3_consulting_service",
|
|
1765
|
+
"owner_receive": {
|
|
1766
|
+
"type": "objects",
|
|
1767
|
+
"objects": ["coin_wrapper_1", "coin_wrapper_2"]
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
```
|
|
1772
|
+
|
|
1773
|
+
---
|
|
1774
|
+
|
|
1775
|
+
## Important Notes
|
|
1776
|
+
|
|
1777
|
+
⚠️ **CRITICAL: Every Service sales item requires a `wip_hash`** - this ensures product/service descriptions are immutable and verifiable. See the WIP section below for how to generate WIP files.
|
|
1778
|
+
|
|
1779
|
+
⚠️ **After publishing, these fields become immutable:** `machine`, `order_allocators`, `arbitrations`.
|
|
1780
|
+
|
|
1781
|
+
⚠️ **`type_parameter` defines the payment token type** accepted by this service, default is "0x2::wow::WOW".
|
|
1782
|
+
|
|
1783
|
+
⚠️ **All objects support local naming** with `name`, `tags`, `onChain`, and `replaceExistName`.
|
|
1784
|
+
|
|
1785
|
+
⚠️ **Use `pause` to temporarily stop accepting orders** .
|
|
1786
|
+
|
|
1787
|
+
⚠️ **`compensation_fund_add` adds funds for arbitration compensation** in order disputes.
|
|
1788
|
+
|
|
1789
|
+
⚠️ **`discount_type` must be 0 (RATES) or 1 (FIXED).**
|
|
1790
|
+
|
|
1791
|
+
---
|
|
1792
|
+
|
|
1793
|
+
## Related Components
|
|
1794
|
+
|
|
1795
|
+
| Component | Description |
|
|
1796
|
+
|-----------|-------------|
|
|
1797
|
+
| **[Machine](machine.md)** | Workflow template |
|
|
1798
|
+
| **[Repository](repository.md)** | Data ownership and usage rights |
|
|
1799
|
+
| **[Arbitration](arbitration.md)** | Dispute resolution |
|
|
1800
|
+
| **[Contact](contact.md)** | Public contact information |
|
|
1801
|
+
| **[Treasury](treasury.md)** | Team fund management |
|
|
1802
|
+
| **[Reward](reward.md)** | Marketing incentives |
|
|
1803
|
+
| **[Allocation](allocation.md)** | Automatic fund distribution |
|
|
1804
|
+
| **[Order](order.md)** | Order management |
|
|
1805
|
+
| **[Payment](payment.md)** | Direct coin transfers |
|
|
1806
|
+
|
|
1807
|
+
---
|
|
1808
|
+
|
|
1809
|
+
## ⚖️ Service Fairness and Arbitration Integration
|
|
1810
|
+
|
|
1811
|
+
The Service component integrates with the Arbitration system to ensure fair dispute resolution. For detailed arbitration state machine and process, see [Arbitration - State Machine](arbitration.md#complete-arbitration-state-machine).
|
|
1812
|
+
|
|
1813
|
+
### Service Fairness Principles
|
|
1814
|
+
|
|
1815
|
+
| Principle | Implementation | User Benefit |
|
|
1816
|
+
|-----------|----------------|--------------|
|
|
1817
|
+
| **Transparent Terms** | WIP files hash product descriptions immutably | Buyers know exactly what they're purchasing |
|
|
1818
|
+
| **Escrow Protection** | Order payments held securely until fulfillment | Both parties protected from fraud |
|
|
1819
|
+
| **Dispute Resolution** | Arbitration objects bound to services | Fair third-party resolution available |
|
|
1820
|
+
| **Compensation Guarantee** | Compensation funds locked in service | Buyers assured of refund capability |
|
|
1821
|
+
| **Immutable Records** | All actions recorded on-chain | Complete audit trail of transactions |
|
|
1822
|
+
|
|
1823
|
+
### Quick Setup Guide
|
|
1824
|
+
|
|
1825
|
+
To enable arbitration for your service:
|
|
1826
|
+
|
|
1827
|
+
1. **Create Arbitration Object**: Set up dispute resolution rules
|
|
1828
|
+
```json
|
|
1829
|
+
{
|
|
1830
|
+
"operation_type": "arbitration",
|
|
1831
|
+
"data": {
|
|
1832
|
+
"object": {"name": "my_arbitration"},
|
|
1833
|
+
"description": "Dispute resolution for my service"
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
```
|
|
1837
|
+
|
|
1838
|
+
2. **Bind to Service**: Link arbitration to service
|
|
1839
|
+
```json
|
|
1840
|
+
{
|
|
1841
|
+
"operation_type": "service",
|
|
1842
|
+
"data": {
|
|
1843
|
+
"object": "my_service",
|
|
1844
|
+
"arbitrations": {"objects": ["my_arbitration"]}
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
```
|
|
1848
|
+
|
|
1849
|
+
3. **Add Compensation Fund**: Ensure funds available for disputes
|
|
1850
|
+
```json
|
|
1851
|
+
{
|
|
1852
|
+
"operation_type": "service",
|
|
1853
|
+
"data": {
|
|
1854
|
+
"object": "my_service",
|
|
1855
|
+
"compensation_fund_add": {"balance": 100000000000}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
👉 **See [Arbitration - State Machine](arbitration.md#complete-arbitration-state-machine) for complete dispute resolution flow and state transitions**
|
|
1861
|
+
|
|
1862
|
+
### Key Arbitration Links
|
|
1863
|
+
|
|
1864
|
+
| Resource | Link | Description |
|
|
1865
|
+
|----------|------|-------------|
|
|
1866
|
+
| **State Machine** | [Arbitration - State Machine](arbitration.md#complete-arbitration-state-machine) | Complete state transitions and flow |
|
|
1867
|
+
| **Create Arbitration** | [Arbitration - Create](arbitration.md#sub-feature-1-create-new-arbitration) | Set up dispute resolution system |
|
|
1868
|
+
| **File Dispute** | [Arbitration - Dispute](arbitration.md#sub-feature-2-create-dispute-dispute) | Buyer initiates dispute |
|
|
1869
|
+
| **Complete Workflow** | [Arbitration - Full Example](arbitration.md#complete-arbitration-workflow-example) | End-to-end arbitration process |
|
|
1870
|
+
| **Transparency** | [Arbitration - Transparency](arbitration.md#transparent-arbitration-process) | How transparency is ensured |
|
|
1871
|
+
|
|
1872
|
+
---
|
|
1873
|
+
|
|
1874
|
+
# Witness Information Promise (WIP) File Operations
|
|
1875
|
+
|
|
1876
|
+
---
|
|
1877
|
+
|
|
1878
|
+
## Component Overview
|
|
1879
|
+
|
|
1880
|
+
The Witness Information Promise (WIP) file format is a cryptographically verifiable JSON format for transmitting immutable promise information. WIP files can be created from markdown and images, verified for integrity, signed with accounts, and converted to HTML. WIP is closely integrated with the Service component, where every sales item must reference a WIP file hash to ensure product/service description immutability.
|
|
1881
|
+
|
|
1882
|
+
---
|
|
1883
|
+
|
|
1884
|
+
## Function List
|
|
1885
|
+
|
|
1886
|
+
| Function Name | Purpose | Usage Scenario | Significance |
|
|
1887
|
+
|---------------|---------|----------------|-------------|
|
|
1888
|
+
| **Generate WIP** | Create WIP files from markdown text and optional images | Product/service descriptions, contracts, terms of service | Foundation for immutable content creation |
|
|
1889
|
+
| **Verify WIP** | Check WIP file integrity and signatures | Validate product descriptions, verify contract authenticity | Ensures content hasn't been tampered with |
|
|
1890
|
+
| **Sign WIP** | Add digital signatures to WIP files | Sign service agreements, certify product details | Provides non-repudiation and authenticity |
|
|
1891
|
+
| **Convert to HTML** | Render WIP files to HTML format | Display product descriptions, view signed documents | Makes WIP content human-readable |
|
|
1892
|
+
|
|
1893
|
+
---
|
|
1894
|
+
|
|
1895
|
+
## Complete Tool Call Structure
|
|
1896
|
+
|
|
1897
|
+
WIP operations use the following top-level structure:
|
|
1898
|
+
|
|
1899
|
+
```json
|
|
1900
|
+
{
|
|
1901
|
+
"type": "operation_type",
|
|
1902
|
+
// operation-specific fields
|
|
1903
|
+
}
|
|
1904
|
+
```
|
|
1905
|
+
|
|
1906
|
+
---
|
|
1907
|
+
|
|
1908
|
+
## Schema Tree
|
|
1909
|
+
|
|
1910
|
+
```
|
|
1911
|
+
wip_file (WIP Operations)
|
|
1912
|
+
├── type (discriminator, required)
|
|
1913
|
+
│ ├── "generate"
|
|
1914
|
+
│ │ ├── options (required, WipGenerationOptions)
|
|
1915
|
+
│ │ │ ├── markdown_text (required, string)
|
|
1916
|
+
│ │ │ ├── images (optional, ImageSource[])
|
|
1917
|
+
│ │ │ └── account (optional, string)
|
|
1918
|
+
│ │ └── outputPath (required, string)
|
|
1919
|
+
│ ├── "verify"
|
|
1920
|
+
│ │ ├── wipFilePath (required, string)
|
|
1921
|
+
│ │ └── hash_equal (optional, string)
|
|
1922
|
+
│ ├── "sign"
|
|
1923
|
+
│ │ ├── wipFilePath (required, string)
|
|
1924
|
+
│ │ ├── account (optional, string)
|
|
1925
|
+
│ │ └── outputPath (optional, string)
|
|
1926
|
+
│ └── "wip2html"
|
|
1927
|
+
│ ├── wipPath (required, string)
|
|
1928
|
+
│ └── options (optional, WipToHtmlOptions)
|
|
1929
|
+
│ ├── title (optional, string)
|
|
1930
|
+
│ ├── theme (optional, "light"/"dark")
|
|
1931
|
+
│ └── outputPath (optional, string)
|
|
1932
|
+
└── (no other top-level fields)
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1935
|
+
---
|
|
1936
|
+
|
|
1937
|
+
## Example 1: Generate WIP File
|
|
1938
|
+
|
|
1939
|
+
### Feature Description
|
|
1940
|
+
|
|
1941
|
+
Create a new WIP file from markdown text and optional images. The generated file includes content hashing and can optionally be signed.
|
|
1942
|
+
|
|
1943
|
+
### Examples
|
|
1944
|
+
|
|
1945
|
+
#### Example 1.1: Generate Basic WIP
|
|
1946
|
+
|
|
1947
|
+
**Prompt**: Please generate a WIP file for a service description. Use markdown text: "Basic Web3 Consulting Service - 1 hour session", output to "service_desc.wip".
|
|
1948
|
+
|
|
1949
|
+
```json
|
|
1950
|
+
{
|
|
1951
|
+
"type": "generate",
|
|
1952
|
+
"options": {
|
|
1953
|
+
"markdown_text": "Basic Web3 Consulting Service - 1 hour session"
|
|
1954
|
+
},
|
|
1955
|
+
"outputPath": "service_desc.wip"
|
|
1956
|
+
}
|
|
1957
|
+
```
|
|
1958
|
+
|
|
1959
|
+
---
|
|
1960
|
+
|
|
1961
|
+
#### Example 1.2: Generate WIP with Images and Signature
|
|
1962
|
+
|
|
1963
|
+
**Prompt**: Generate a WIP file for premium consulting with markdown text, include two images from local files, and sign it with account "alice". Markdown: "Premium Consulting Package includes 4 hours of dedicated service and priority support.", images: "logo.png" and "demo.jpg", output to "premium_service.wip".
|
|
1964
|
+
|
|
1965
|
+
```json
|
|
1966
|
+
{
|
|
1967
|
+
"type": "generate",
|
|
1968
|
+
"options": {
|
|
1969
|
+
"markdown_text": "Premium Consulting Package includes 4 hours of dedicated service and priority support.",
|
|
1970
|
+
"images": [
|
|
1971
|
+
{
|
|
1972
|
+
"source": "logo.png",
|
|
1973
|
+
"id": "company_logo",
|
|
1974
|
+
"filename": "company_logo.png"
|
|
1975
|
+
},
|
|
1976
|
+
{
|
|
1977
|
+
"source": "demo.jpg",
|
|
1978
|
+
"id": "service_demo"
|
|
1979
|
+
}
|
|
1980
|
+
],
|
|
1981
|
+
"account": "alice"
|
|
1982
|
+
},
|
|
1983
|
+
"outputPath": "premium_service.wip"
|
|
1984
|
+
}
|
|
1985
|
+
```
|
|
1986
|
+
|
|
1987
|
+
---
|
|
1988
|
+
|
|
1989
|
+
## Example 2: Verify WIP File
|
|
1990
|
+
|
|
1991
|
+
### Feature Description
|
|
1992
|
+
|
|
1993
|
+
Verify a WIP file's integrity by checking its hash and signatures. Optionally verify against an expected hash value.
|
|
1994
|
+
|
|
1995
|
+
### Examples
|
|
1996
|
+
|
|
1997
|
+
#### Example 2.1: Basic Verification
|
|
1998
|
+
|
|
1999
|
+
**Prompt**: Verify the integrity of the WIP file at "service_desc.wip".
|
|
2000
|
+
|
|
2001
|
+
```json
|
|
2002
|
+
{
|
|
2003
|
+
"type": "verify",
|
|
2004
|
+
"wipFilePath": "service_desc.wip"
|
|
2005
|
+
}
|
|
2006
|
+
```
|
|
2007
|
+
|
|
2008
|
+
---
|
|
2009
|
+
|
|
2010
|
+
#### Example 2.2: Verify with Expected Hash
|
|
2011
|
+
|
|
2012
|
+
**Prompt**: Verify the WIP file at "premium_service.wip" and check that it matches the expected hash value.
|
|
2013
|
+
|
|
2014
|
+
```json
|
|
2015
|
+
{
|
|
2016
|
+
"type": "verify",
|
|
2017
|
+
"wipFilePath": "premium_service.wip",
|
|
2018
|
+
"hash_equal": "sha256:abc123def456..."
|
|
2019
|
+
}
|
|
2020
|
+
```
|
|
2021
|
+
|
|
2022
|
+
---
|
|
2023
|
+
|
|
2024
|
+
## Example 3: Sign WIP File
|
|
2025
|
+
|
|
2026
|
+
### Feature Description
|
|
2027
|
+
|
|
2028
|
+
Sign an existing WIP file with an account's private key. Adds a digital signature to prove authenticity.
|
|
2029
|
+
|
|
2030
|
+
### Examples
|
|
2031
|
+
|
|
2032
|
+
#### Example 3.1: Sign with Default Account
|
|
2033
|
+
|
|
2034
|
+
**Prompt**: Sign the WIP file at "service_desc.wip" using the default account. Save to "signed_service_desc.wip".
|
|
2035
|
+
|
|
2036
|
+
```json
|
|
2037
|
+
{
|
|
2038
|
+
"type": "sign",
|
|
2039
|
+
"wipFilePath": "service_desc.wip",
|
|
2040
|
+
"outputPath": "signed_service_desc.wip"
|
|
2041
|
+
}
|
|
2042
|
+
```
|
|
2043
|
+
|
|
2044
|
+
---
|
|
2045
|
+
|
|
2046
|
+
#### Example 3.2: Sign with Specific Account
|
|
2047
|
+
|
|
2048
|
+
**Prompt**: Sign the WIP file at "premium_service.wip" using account "bob".
|
|
2049
|
+
|
|
2050
|
+
```json
|
|
2051
|
+
{
|
|
2052
|
+
"type": "sign",
|
|
2053
|
+
"wipFilePath": "premium_service.wip",
|
|
2054
|
+
"account": "bob"
|
|
2055
|
+
}
|
|
2056
|
+
```
|
|
2057
|
+
|
|
2058
|
+
---
|
|
2059
|
+
|
|
2060
|
+
## Example 4: Convert WIP to HTML
|
|
2061
|
+
|
|
2062
|
+
### Feature Description
|
|
2063
|
+
|
|
2064
|
+
Convert one or more WIP files to HTML format for display. Supports single files, directories, and network URLs.
|
|
2065
|
+
|
|
2066
|
+
### Examples
|
|
2067
|
+
|
|
2068
|
+
#### Example 4.1: Convert Single File
|
|
2069
|
+
|
|
2070
|
+
**Prompt**: Convert the WIP file at "service_desc.wip" to HTML, set page title to "Service Description", use light theme.
|
|
2071
|
+
|
|
2072
|
+
```json
|
|
2073
|
+
{
|
|
2074
|
+
"type": "wip2html",
|
|
2075
|
+
"wipPath": "service_desc.wip",
|
|
2076
|
+
"options": {
|
|
2077
|
+
"title": "Service Description",
|
|
2078
|
+
"theme": "light"
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
```
|
|
2082
|
+
|
|
2083
|
+
---
|
|
2084
|
+
|
|
2085
|
+
#### Example 4.2: Convert Directory with Output Path
|
|
2086
|
+
|
|
2087
|
+
**Prompt**: Convert all WIP files in the "./wips" directory to HTML and save them to "./html_output".
|
|
2088
|
+
|
|
2089
|
+
```json
|
|
2090
|
+
{
|
|
2091
|
+
"type": "wip2html",
|
|
2092
|
+
"wipPath": "./wips",
|
|
2093
|
+
"options": {
|
|
2094
|
+
"outputPath": "./html_output"
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
```
|
|
2098
|
+
|
|
2099
|
+
---
|
|
2100
|
+
|
|
2101
|
+
## WIP and Service Integration
|
|
2102
|
+
|
|
2103
|
+
WIP files are deeply integrated with the Service component. Every sales item in a Service must reference a WIP file hash using the `wip_hash` field. This ensures that product/service descriptions are immutable and verifiable.
|
|
2104
|
+
|
|
2105
|
+
### Workflow Example
|
|
2106
|
+
|
|
2107
|
+
1. **Create WIP**: Generate a WIP file describing your product/service
|
|
2108
|
+
2. **Sign WIP** (optional): Sign the WIP file with your account
|
|
2109
|
+
3. **Get Hash**: Extract the WIP file's hash
|
|
2110
|
+
4. **Add to Service**: Reference the hash in your Service's sales item
|
|
2111
|
+
5. **Publish**: Customers can verify the product description by checking the WIP hash
|
|
2112
|
+
|
|
2113
|
+
---
|
|
2114
|
+
|
|
2115
|
+
## Important Notes
|
|
2116
|
+
|
|
2117
|
+
⚠️ **Every Service sales item requires a `wip_hash`** - this ensures product description immutability.
|
|
2118
|
+
|
|
2119
|
+
⚠️ **WIP files can be signed with multiple signatures** - supports multi-signature scenarios.
|
|
2120
|
+
|
|
2121
|
+
---
|
|
2122
|
+
|
|
2123
|
+
## Related Components
|
|
2124
|
+
|
|
2125
|
+
| Component | Description |
|
|
2126
|
+
|-----------|-------------|
|
|
2127
|
+
| **[Service](service.md)** | WYSIWYG product trading - uses WIP hashes for sales items |
|
|
2128
|
+
| **[Account](account.md)** | Local wallet management - signs WIP files |
|
|
2129
|
+
| **[Query](query.md)** | Data query - can retrieve and verify WIP-related data |
|
|
2130
|
+
|