viz-js-lib 0.11.0 → 0.12.4
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/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
- package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
- package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
- package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
- package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
- package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
- package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
- package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
- package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
- package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
- package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
- package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
- package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
- package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
- package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
- package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
- package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
- package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
- package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
- package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
- package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
- package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
- package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
- package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
- package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
- package/.qoder/repowiki/en/content/Getting Started.md +345 -0
- package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
- package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
- package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
- package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
- package/config.json +3 -1
- package/dist/statistics.html +1 -1
- package/dist/viz-tests.min.js +32 -42
- package/dist/viz-tests.min.js.gz +0 -0
- package/dist/viz.min.js +8 -18
- package/dist/viz.min.js.gz +0 -0
- package/lib/api/methods.js +24 -0
- package/lib/auth/serializer/src/ChainTypes.js +2 -1
- package/lib/auth/serializer/src/operations.js +35 -2
- package/lib/broadcast/index.js +29 -15
- package/lib/broadcast/operations.js +4 -0
- package/lib/dns.js +658 -0
- package/lib/index.js +3 -1
- package/package.json +3 -2
- package/test/dns.test.js +395 -0
- package/webpack/makeConfig.js +3 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# VIZ Blockchain — Committee Operations
|
|
2
|
+
|
|
3
|
+
Spec for implementing committee (worker proposal) operations in PHP/Node.js libraries.
|
|
4
|
+
|
|
5
|
+
The committee mechanism allows community governance: anyone can create worker requests for funding, and VIZ SHARES holders vote to approve or reject them.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## `committee_worker_create_request_operation`
|
|
10
|
+
|
|
11
|
+
**Type ID:** `35`
|
|
12
|
+
**Required authority:** `regular` of `creator`
|
|
13
|
+
|
|
14
|
+
Creates a new committee worker request (funding proposal).
|
|
15
|
+
|
|
16
|
+
### Fields
|
|
17
|
+
|
|
18
|
+
| Field | Type | Required | Description |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| `creator` | `account_name_type` | yes | Account creating the request |
|
|
21
|
+
| `url` | `string` | yes | URL describing the work/proposal |
|
|
22
|
+
| `worker` | `account_name_type` | yes | Account that will receive the payout |
|
|
23
|
+
| `required_amount_min` | `asset` (VIZ) | yes | Minimum acceptable payout |
|
|
24
|
+
| `required_amount_max` | `asset` (VIZ) | yes | Maximum acceptable payout |
|
|
25
|
+
| `duration` | `uint32_t` | yes | Request duration in seconds |
|
|
26
|
+
|
|
27
|
+
### Constraints
|
|
28
|
+
|
|
29
|
+
| Parameter | Value | Description |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `COMMITTEE_MIN_DURATION` | 5 days | Minimum duration |
|
|
32
|
+
| `COMMITTEE_MAX_DURATION` | 30 days | Maximum duration |
|
|
33
|
+
| `COMMITTEE_MAX_REQUIRED_AMOUNT` | chain configured | Max tokens per request |
|
|
34
|
+
|
|
35
|
+
### JSON Example
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
[35, {
|
|
39
|
+
"creator": "alice",
|
|
40
|
+
"url": "https://alice.example.com/proposal",
|
|
41
|
+
"worker": "alice",
|
|
42
|
+
"required_amount_min": "100.000 VIZ",
|
|
43
|
+
"required_amount_max": "500.000 VIZ",
|
|
44
|
+
"duration": 604800
|
|
45
|
+
}]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### PHP Example
|
|
49
|
+
|
|
50
|
+
```php
|
|
51
|
+
$op = [
|
|
52
|
+
'type' => 'committee_worker_create_request_operation',
|
|
53
|
+
'value' => [
|
|
54
|
+
'creator' => 'alice',
|
|
55
|
+
'url' => 'https://alice.example.com/proposal',
|
|
56
|
+
'worker' => 'alice',
|
|
57
|
+
'required_amount_min' => '100.000 VIZ',
|
|
58
|
+
'required_amount_max' => '500.000 VIZ',
|
|
59
|
+
'duration' => 604800,
|
|
60
|
+
],
|
|
61
|
+
];
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Node.js Example
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
const op = ['committee_worker_create_request', {
|
|
68
|
+
creator: 'alice',
|
|
69
|
+
url: 'https://alice.example.com/proposal',
|
|
70
|
+
worker: 'alice',
|
|
71
|
+
required_amount_min: '100.000 VIZ',
|
|
72
|
+
required_amount_max: '500.000 VIZ',
|
|
73
|
+
duration: 604800,
|
|
74
|
+
}];
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Checklist
|
|
78
|
+
- [ ] `url.size()` must be > 0 and < 256 characters
|
|
79
|
+
- [ ] `required_amount_min.symbol` must be `VIZ`
|
|
80
|
+
- [ ] `required_amount_max.symbol` must be `VIZ`
|
|
81
|
+
- [ ] `required_amount_min.amount` >= 0
|
|
82
|
+
- [ ] `required_amount_max.amount` > `required_amount_min.amount`
|
|
83
|
+
- [ ] `duration` in range `[COMMITTEE_MIN_DURATION, COMMITTEE_MAX_DURATION]`
|
|
84
|
+
- [ ] Fee (`committee_create_request_fee`) is charged to creator
|
|
85
|
+
- [ ] Sign with `creator`'s regular key
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## `committee_worker_cancel_request_operation`
|
|
90
|
+
|
|
91
|
+
**Type ID:** `36`
|
|
92
|
+
**Required authority:** `regular` of `creator`
|
|
93
|
+
|
|
94
|
+
Cancels an existing committee worker request before it expires.
|
|
95
|
+
|
|
96
|
+
### Fields
|
|
97
|
+
|
|
98
|
+
| Field | Type | Required | Description |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| `creator` | `account_name_type` | yes | Creator of the request |
|
|
101
|
+
| `request_id` | `uint32_t` | yes | ID of the request to cancel |
|
|
102
|
+
|
|
103
|
+
### JSON Example
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
[36, {
|
|
107
|
+
"creator": "alice",
|
|
108
|
+
"request_id": 42
|
|
109
|
+
}]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### PHP Example
|
|
113
|
+
|
|
114
|
+
```php
|
|
115
|
+
$op = [
|
|
116
|
+
'type' => 'committee_worker_cancel_request_operation',
|
|
117
|
+
'value' => [
|
|
118
|
+
'creator' => 'alice',
|
|
119
|
+
'request_id' => 42,
|
|
120
|
+
],
|
|
121
|
+
];
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Node.js Example
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
const op = ['committee_worker_cancel_request', {
|
|
128
|
+
creator: 'alice',
|
|
129
|
+
request_id: 42,
|
|
130
|
+
}];
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Checklist
|
|
134
|
+
- [ ] Only the `creator` of the request can cancel it
|
|
135
|
+
- [ ] `request_id` must refer to an existing active request
|
|
136
|
+
- [ ] Sign with `creator`'s regular key
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## `committee_vote_request_operation`
|
|
141
|
+
|
|
142
|
+
**Type ID:** `37`
|
|
143
|
+
**Required authority:** `regular` of `voter`
|
|
144
|
+
|
|
145
|
+
Votes on a committee worker request. Positive = support, negative = oppose.
|
|
146
|
+
|
|
147
|
+
### Fields
|
|
148
|
+
|
|
149
|
+
| Field | Type | Required | Description |
|
|
150
|
+
|---|---|---|---|
|
|
151
|
+
| `voter` | `account_name_type` | yes | Account casting the vote |
|
|
152
|
+
| `request_id` | `uint32_t` | yes | ID of the request to vote on |
|
|
153
|
+
| `vote_percent` | `int16_t` | yes | Vote weight (-10000 to 10000) |
|
|
154
|
+
|
|
155
|
+
### JSON Example
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
[37, {
|
|
159
|
+
"voter": "bob",
|
|
160
|
+
"request_id": 42,
|
|
161
|
+
"vote_percent": 10000
|
|
162
|
+
}]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### PHP Example
|
|
166
|
+
|
|
167
|
+
```php
|
|
168
|
+
$op = [
|
|
169
|
+
'type' => 'committee_vote_request_operation',
|
|
170
|
+
'value' => [
|
|
171
|
+
'voter' => 'bob',
|
|
172
|
+
'request_id' => 42,
|
|
173
|
+
'vote_percent' => 10000,
|
|
174
|
+
],
|
|
175
|
+
];
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Node.js Example
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
const op = ['committee_vote_request', {
|
|
182
|
+
voter: 'bob',
|
|
183
|
+
request_id: 42,
|
|
184
|
+
vote_percent: 10000,
|
|
185
|
+
}];
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Checklist
|
|
189
|
+
- [ ] `vote_percent` range: -10000 (strong oppose) to 10000 (strong support)
|
|
190
|
+
- [ ] `vote_percent == 0` removes vote
|
|
191
|
+
- [ ] Voting power weighted by voter's SHARES
|
|
192
|
+
- [ ] Request is approved when net vote percent >= `committee_request_approve_min_percent`
|
|
193
|
+
- [ ] Sign with `voter`'s regular key
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# VIZ Blockchain — Content & Custom Operations
|
|
2
|
+
|
|
3
|
+
Spec for implementing content and custom operations in PHP/Node.js libraries.
|
|
4
|
+
|
|
5
|
+
> **Note:** `vote_operation` (ID 0), `content_operation` (ID 1), and `delete_content_operation` (ID 9) are **deprecated**. They remain in the operation variant for historical compatibility but should not be used in new code. Shown here for completeness.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## `content_operation` *(deprecated)*
|
|
10
|
+
|
|
11
|
+
**Type ID:** `1`
|
|
12
|
+
**Required authority:** `regular` of `author`
|
|
13
|
+
|
|
14
|
+
Creates or updates content (post or comment).
|
|
15
|
+
|
|
16
|
+
### Fields
|
|
17
|
+
|
|
18
|
+
| Field | Type | Required | Description |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| `parent_author` | `account_name_type` | yes | Author of parent content (empty `""` for root post) |
|
|
21
|
+
| `parent_permlink` | `string` | yes | Permlink of parent (category/tag for root posts) |
|
|
22
|
+
| `author` | `account_name_type` | yes | Content author |
|
|
23
|
+
| `permlink` | `string` | yes | Unique identifier per author |
|
|
24
|
+
| `title` | `string` | yes | Post title |
|
|
25
|
+
| `body` | `string` | yes | Post body (Markdown) |
|
|
26
|
+
| `curation_percent` | `int16_t` | yes | Curation reward share in basis points (0–10000) |
|
|
27
|
+
| `json_metadata` | `string` | yes | JSON metadata |
|
|
28
|
+
| `extensions` | `content_extensions_type` | yes | Optional beneficiaries |
|
|
29
|
+
|
|
30
|
+
### Beneficiaries Extension
|
|
31
|
+
|
|
32
|
+
To add beneficiaries, add to `extensions`:
|
|
33
|
+
```json
|
|
34
|
+
[
|
|
35
|
+
[0, {
|
|
36
|
+
"beneficiaries": [
|
|
37
|
+
{"account": "bob", "weight": 2500}
|
|
38
|
+
]
|
|
39
|
+
}]
|
|
40
|
+
]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Checklist
|
|
44
|
+
- [ ] `permlink` must be unique per author
|
|
45
|
+
- [ ] `parent_author == ""` → root post; otherwise comment
|
|
46
|
+
- [ ] `curation_percent` range 0–10000 (must be within chain min/max)
|
|
47
|
+
- [ ] Beneficiary weights sum must be <= 10000 (100%)
|
|
48
|
+
- [ ] Beneficiaries list must be sorted by account name ascending
|
|
49
|
+
- [ ] **Deprecated** — avoid creating new content with this operation
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## `vote_operation` *(deprecated)*
|
|
54
|
+
|
|
55
|
+
**Type ID:** `0`
|
|
56
|
+
**Required authority:** `regular` of `voter`
|
|
57
|
+
|
|
58
|
+
Casts a vote on content.
|
|
59
|
+
|
|
60
|
+
### Fields
|
|
61
|
+
|
|
62
|
+
| Field | Type | Required | Description |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `voter` | `account_name_type` | yes | Voting account |
|
|
65
|
+
| `author` | `account_name_type` | yes | Content author |
|
|
66
|
+
| `permlink` | `string` | yes | Content permlink |
|
|
67
|
+
| `weight` | `int16_t` | yes | Vote weight (-10000 to 10000) |
|
|
68
|
+
|
|
69
|
+
### Checklist
|
|
70
|
+
- [ ] `weight` > 0 → upvote; `weight` < 0 → flag/downvote
|
|
71
|
+
- [ ] `weight == 0` → remove vote
|
|
72
|
+
- [ ] Flag votes may cost extra energy (see `flag_energy_additional_cost` chain property)
|
|
73
|
+
- [ ] **Deprecated** — avoid in new code
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## `delete_content_operation` *(deprecated)*
|
|
78
|
+
|
|
79
|
+
**Type ID:** `9`
|
|
80
|
+
**Required authority:** `regular` of `author`
|
|
81
|
+
|
|
82
|
+
Deletes a piece of content.
|
|
83
|
+
|
|
84
|
+
### Fields
|
|
85
|
+
|
|
86
|
+
| Field | Type | Required | Description |
|
|
87
|
+
|---|---|---|---|
|
|
88
|
+
| `author` | `account_name_type` | yes | Content author |
|
|
89
|
+
| `permlink` | `string` | yes | Content permlink to delete |
|
|
90
|
+
|
|
91
|
+
### Checklist
|
|
92
|
+
- [ ] Content must have no pending payout to be deletable
|
|
93
|
+
- [ ] **Deprecated** — avoid in new code
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## `custom_operation`
|
|
98
|
+
|
|
99
|
+
**Type ID:** `10`
|
|
100
|
+
**Required authority:** `active` or `regular` of signers
|
|
101
|
+
|
|
102
|
+
Posts arbitrary JSON data to the blockchain. Used by applications for custom logic/protocols.
|
|
103
|
+
|
|
104
|
+
### Fields
|
|
105
|
+
|
|
106
|
+
| Field | Type | Required | Description |
|
|
107
|
+
|---|---|---|---|
|
|
108
|
+
| `required_active_auths` | `flat_set<account_name_type>` | yes | Accounts requiring active auth |
|
|
109
|
+
| `required_regular_auths` | `flat_set<account_name_type>` | yes | Accounts requiring regular auth |
|
|
110
|
+
| `id` | `string` | yes | Application-defined ID (max 32 characters) |
|
|
111
|
+
| `json` | `string` | yes | Valid UTF-8 JSON string |
|
|
112
|
+
|
|
113
|
+
### JSON Example
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
[10, {
|
|
117
|
+
"required_active_auths": [],
|
|
118
|
+
"required_regular_auths": ["alice"],
|
|
119
|
+
"id": "my_app",
|
|
120
|
+
"json": "{\"action\":\"follow\",\"target\":\"bob\"}"
|
|
121
|
+
}]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### PHP Example
|
|
125
|
+
|
|
126
|
+
```php
|
|
127
|
+
$op = [
|
|
128
|
+
'type' => 'custom_operation',
|
|
129
|
+
'value' => [
|
|
130
|
+
'required_active_auths' => [],
|
|
131
|
+
'required_regular_auths' => ['alice'],
|
|
132
|
+
'id' => 'my_app',
|
|
133
|
+
'json' => json_encode(['action' => 'follow', 'target' => 'bob']),
|
|
134
|
+
],
|
|
135
|
+
];
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Node.js Example
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
const op = ['custom', {
|
|
142
|
+
required_active_auths: [],
|
|
143
|
+
required_regular_auths: ['alice'],
|
|
144
|
+
id: 'my_app',
|
|
145
|
+
json: JSON.stringify({ action: 'follow', target: 'bob' }),
|
|
146
|
+
}];
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Checklist
|
|
150
|
+
- [ ] `id` must be <= 32 characters
|
|
151
|
+
- [ ] `json` must be valid UTF-8 JSON
|
|
152
|
+
- [ ] At least one of `required_active_auths` or `required_regular_auths` must be non-empty
|
|
153
|
+
- [ ] `required_active_auths` entries → sign with those accounts' active keys
|
|
154
|
+
- [ ] `required_regular_auths` entries → sign with those accounts' regular keys
|
|
155
|
+
- [ ] Both `required_active_auths` and `required_regular_auths` may be populated simultaneously
|
|
156
|
+
- [ ] Data operations may cost additional bandwidth (see `data_operations_cost_additional_bandwidth`)
|
|
157
|
+
- [ ] `json` field is considered a "data operation" for bandwidth purposes
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# VIZ Blockchain — Escrow Operations
|
|
2
|
+
|
|
3
|
+
Spec for implementing escrow-related operations in PHP/Node.js libraries.
|
|
4
|
+
|
|
5
|
+
Escrow allows conditional transfers: funds are held in escrow until approved by both parties, or resolved by an agent in case of dispute.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Escrow Flow
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
escrow_transfer → escrow_approve (by agent & to)
|
|
13
|
+
→ [escrow_dispute] → escrow_release (by agent)
|
|
14
|
+
→ escrow_release (by from or to)
|
|
15
|
+
(expire) → expire_escrow_ratification_operation [virtual]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## `escrow_transfer_operation`
|
|
21
|
+
|
|
22
|
+
**Type ID:** `15`
|
|
23
|
+
**Required authority:** `active` of `from`
|
|
24
|
+
|
|
25
|
+
Creates an escrow transfer proposal. Funds leave `from` into escrow balance. Both `agent` and `to` must approve before funds can be released.
|
|
26
|
+
|
|
27
|
+
### Fields
|
|
28
|
+
|
|
29
|
+
| Field | Type | Required | Description |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| `from` | `account_name_type` | yes | Sender |
|
|
32
|
+
| `to` | `account_name_type` | yes | Intended recipient |
|
|
33
|
+
| `agent` | `account_name_type` | yes | Escrow agent (arbitrator) |
|
|
34
|
+
| `escrow_id` | `uint32_t` | yes | Unique ID (chosen by sender), default 30 |
|
|
35
|
+
| `token_amount` | `asset` (VIZ) | yes | Amount held in escrow |
|
|
36
|
+
| `fee` | `asset` (VIZ) | yes | Agent fee (paid on approval) |
|
|
37
|
+
| `ratification_deadline` | `time_point_sec` | yes | Deadline for agent & to to approve |
|
|
38
|
+
| `escrow_expiration` | `time_point_sec` | yes | When escrow expires if not released |
|
|
39
|
+
| `json_metadata` | `string` | yes | Optional metadata / terms |
|
|
40
|
+
|
|
41
|
+
### JSON Example
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
[15, {
|
|
45
|
+
"from": "alice",
|
|
46
|
+
"to": "bob",
|
|
47
|
+
"agent": "charlie",
|
|
48
|
+
"escrow_id": 1001,
|
|
49
|
+
"token_amount": "100.000 VIZ",
|
|
50
|
+
"fee": "1.000 VIZ",
|
|
51
|
+
"ratification_deadline": "2024-06-01T00:00:00",
|
|
52
|
+
"escrow_expiration": "2024-07-01T00:00:00",
|
|
53
|
+
"json_metadata": "{\"description\":\"payment for work\"}"
|
|
54
|
+
}]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### PHP Example
|
|
58
|
+
|
|
59
|
+
```php
|
|
60
|
+
$op = [
|
|
61
|
+
'type' => 'escrow_transfer_operation',
|
|
62
|
+
'value' => [
|
|
63
|
+
'from' => 'alice',
|
|
64
|
+
'to' => 'bob',
|
|
65
|
+
'agent' => 'charlie',
|
|
66
|
+
'escrow_id' => 1001,
|
|
67
|
+
'token_amount' => '100.000 VIZ',
|
|
68
|
+
'fee' => '1.000 VIZ',
|
|
69
|
+
'ratification_deadline' => '2024-06-01T00:00:00',
|
|
70
|
+
'escrow_expiration' => '2024-07-01T00:00:00',
|
|
71
|
+
'json_metadata' => json_encode(['description' => 'payment for work']),
|
|
72
|
+
],
|
|
73
|
+
];
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Node.js Example
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
const op = ['escrow_transfer', {
|
|
80
|
+
from: 'alice',
|
|
81
|
+
to: 'bob',
|
|
82
|
+
agent: 'charlie',
|
|
83
|
+
escrow_id: 1001,
|
|
84
|
+
token_amount: '100.000 VIZ',
|
|
85
|
+
fee: '1.000 VIZ',
|
|
86
|
+
ratification_deadline: '2024-06-01T00:00:00',
|
|
87
|
+
escrow_expiration: '2024-07-01T00:00:00',
|
|
88
|
+
json_metadata: JSON.stringify({ description: 'payment for work' }),
|
|
89
|
+
}];
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Checklist
|
|
93
|
+
- [ ] `token_amount.symbol` must be `VIZ`
|
|
94
|
+
- [ ] `fee.symbol` must be `VIZ`
|
|
95
|
+
- [ ] `token_amount.amount` must be > 0
|
|
96
|
+
- [ ] `ratification_deadline` must be before `escrow_expiration`
|
|
97
|
+
- [ ] Both deadlines must be in the future at time of broadcast
|
|
98
|
+
- [ ] `escrow_id` must be unique for the `from` account
|
|
99
|
+
- [ ] If not approved before `ratification_deadline`, virtual `expire_escrow_ratification_operation` fires and funds return
|
|
100
|
+
- [ ] Sign with `from`'s active key
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## `escrow_approve_operation`
|
|
105
|
+
|
|
106
|
+
**Type ID:** `18`
|
|
107
|
+
**Required authority:** `active` of `who`
|
|
108
|
+
|
|
109
|
+
Approves (or rejects) an escrow transfer. Both `to` and `agent` must approve. Once approved, approval cannot be revoked.
|
|
110
|
+
|
|
111
|
+
### Fields
|
|
112
|
+
|
|
113
|
+
| Field | Type | Required | Description |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| `from` | `account_name_type` | yes | Original escrow sender |
|
|
116
|
+
| `to` | `account_name_type` | yes | Original escrow recipient |
|
|
117
|
+
| `agent` | `account_name_type` | yes | Escrow agent |
|
|
118
|
+
| `who` | `account_name_type` | yes | Who is approving (`to` or `agent`) |
|
|
119
|
+
| `escrow_id` | `uint32_t` | yes | Escrow ID |
|
|
120
|
+
| `approve` | `bool` | yes | `true` to approve, `false` to reject |
|
|
121
|
+
|
|
122
|
+
### JSON Example
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
[18, {
|
|
126
|
+
"from": "alice",
|
|
127
|
+
"to": "bob",
|
|
128
|
+
"agent": "charlie",
|
|
129
|
+
"who": "bob",
|
|
130
|
+
"escrow_id": 1001,
|
|
131
|
+
"approve": true
|
|
132
|
+
}]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Checklist
|
|
136
|
+
- [ ] `who` must be either `to` or `agent`
|
|
137
|
+
- [ ] Once approved, cannot be undone
|
|
138
|
+
- [ ] If `approve: false` → escrow is cancelled, funds returned to `from`
|
|
139
|
+
- [ ] Escrow is only active once both `to` and `agent` have approved
|
|
140
|
+
- [ ] Must be done before `ratification_deadline`
|
|
141
|
+
- [ ] Sign with `who`'s active key
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## `escrow_dispute_operation`
|
|
146
|
+
|
|
147
|
+
**Type ID:** `16`
|
|
148
|
+
**Required authority:** `active` of `who`
|
|
149
|
+
|
|
150
|
+
Raises a dispute on an approved escrow. Once disputed, only the `agent` can release funds.
|
|
151
|
+
|
|
152
|
+
### Fields
|
|
153
|
+
|
|
154
|
+
| Field | Type | Required | Description |
|
|
155
|
+
|---|---|---|---|
|
|
156
|
+
| `from` | `account_name_type` | yes | Original escrow sender |
|
|
157
|
+
| `to` | `account_name_type` | yes | Original escrow recipient |
|
|
158
|
+
| `agent` | `account_name_type` | yes | Escrow agent |
|
|
159
|
+
| `who` | `account_name_type` | yes | Who is raising the dispute (`from` or `to`) |
|
|
160
|
+
| `escrow_id` | `uint32_t` | yes | Escrow ID |
|
|
161
|
+
|
|
162
|
+
### JSON Example
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
[16, {
|
|
166
|
+
"from": "alice",
|
|
167
|
+
"to": "bob",
|
|
168
|
+
"agent": "charlie",
|
|
169
|
+
"who": "alice",
|
|
170
|
+
"escrow_id": 1001
|
|
171
|
+
}]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Checklist
|
|
175
|
+
- [ ] Dispute can only be raised on an **approved** escrow (both parties approved)
|
|
176
|
+
- [ ] Dispute can be raised before or on the `escrow_expiration` deadline
|
|
177
|
+
- [ ] `who` must be `from` or `to`
|
|
178
|
+
- [ ] Once disputed, only `agent` can release via `escrow_release_operation`
|
|
179
|
+
- [ ] Sign with `who`'s active key
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## `escrow_release_operation`
|
|
184
|
+
|
|
185
|
+
**Type ID:** `17`
|
|
186
|
+
**Required authority:** `active` of `who`
|
|
187
|
+
|
|
188
|
+
Releases escrow funds to `receiver`.
|
|
189
|
+
|
|
190
|
+
### Fields
|
|
191
|
+
|
|
192
|
+
| Field | Type | Required | Description |
|
|
193
|
+
|---|---|---|---|
|
|
194
|
+
| `from` | `account_name_type` | yes | Original escrow sender |
|
|
195
|
+
| `to` | `account_name_type` | yes | Original escrow recipient |
|
|
196
|
+
| `agent` | `account_name_type` | yes | Escrow agent |
|
|
197
|
+
| `who` | `account_name_type` | yes | Account releasing funds |
|
|
198
|
+
| `receiver` | `account_name_type` | yes | Account that receives the funds |
|
|
199
|
+
| `escrow_id` | `uint32_t` | yes | Escrow ID |
|
|
200
|
+
| `token_amount` | `asset` (VIZ) | yes | Amount to release |
|
|
201
|
+
|
|
202
|
+
### JSON Example
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
[17, {
|
|
206
|
+
"from": "alice",
|
|
207
|
+
"to": "bob",
|
|
208
|
+
"agent": "charlie",
|
|
209
|
+
"who": "alice",
|
|
210
|
+
"receiver": "bob",
|
|
211
|
+
"escrow_id": 1001,
|
|
212
|
+
"token_amount": "100.000 VIZ"
|
|
213
|
+
}]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Checklist
|
|
217
|
+
- [ ] `token_amount.symbol` must be `VIZ`
|
|
218
|
+
- [ ] Release permission rules:
|
|
219
|
+
- No dispute, before expiration: `from` can release to `to`; `to` can release to `from`
|
|
220
|
+
- No dispute, after expiration: either party can release to either party
|
|
221
|
+
- Disputed: only `agent` can release to either party
|
|
222
|
+
- [ ] `receiver` must be `from` or `to`
|
|
223
|
+
- [ ] `token_amount` can be partial — remaining stays in escrow
|
|
224
|
+
- [ ] Sign with `who`'s active key
|