Skip to content

Commit 229c3cb

Browse files
authored
docs: more v2 (#121)
* docs: correct data contract error range * docs(api): update token event info * docs(ref): fix contract links * docs: add token fee info to explanation * docs: update token config info and action rules * docs: add token direct purchase info * docs(ref): data contract updates * docs: link updates * docs: add contract fees info Based on dashpay/platform#2584 * docs: add js-sdk connection example for local build
1 parent 98b3ae1 commit 229c3cb

6 files changed

Lines changed: 220 additions & 27 deletions

File tree

docs/explanations/tokens.md

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Dash Platform’s token functionality provides a straightforward, account-based
1616
- **Access Control [Groups](#groups)**: Multi-party groups with user-defined thresholds support complex authorization schemes for token management
1717
- **Built-in [Distribution](#distribution-rules)**: Manual minting or scheduled release over time
1818
- **Seamless Integration**: Tokens live alongside documents in a single data contract, enabling additional use cases (e.g., ticketing, digital assets, stablecoins)
19+
- **Token-Based Document [Fees](#token-based-fees)**: Charge tokens for an application's document actions (e.g., create, transfer), with options to burn tokens or reward the contract owner
1920

2021
The following sections describe the features and configuration options available for token creators
2122
using Dash Platform.
@@ -103,11 +104,12 @@ When creating a token, you define its configuration using the following paramete
103104
| Configuration Parameter | Mutable | Default |
104105
|:------------------------|:------------------|:--------|
105106
| [Conventions](#display-conventions) | Yes | N/A. Depends on implementation |
106-
| [Decimal precision](#display-conventions)| Yes | [8](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/v0/mod.rs#L38) |
107-
| [Base supply](#token-supply) | **No** | [100000](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs#L159) |
107+
| [Decimal precision](#display-conventions)| Yes | [8](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs#L376) |
108+
| [Base supply](#token-supply) | **No** | [100000](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs#L378) |
108109
| [Maximum supply](#token-supply) | Yes | None |
109110
| [Keep history](#history) | Yes | True |
110111
| [Start paused](#initial-state) | Yes | False |
112+
| [Allow transfer to frozen balance](#allow-transfer-to-frozen-balance) | Yes | True |
111113
| [Main control group](#main-control-group)| Yes | None |
112114
| Main control group can be modified | Yes | NoOne |
113115

@@ -137,6 +139,10 @@ When creating a token, you define its configuration using the following paramete
137139
- Whether the authority to change these parameters can be transferred or locked to "no one"
138140
- Example: "Only group #1 can update the max supply.” See the [Rules section](#rules) for details.
139141

142+
#### Allow Transfer to Frozen Balance
143+
144+
- Allow transferring and minting of tokens to frozen identity token balances
145+
140146
#### Main Control Group
141147

142148
- A group that can be referenced in other fields to control multiple aspects of the token with the same group.
@@ -179,19 +185,46 @@ Rules can authorize no one, specific identities, or multiparty groups. The compl
179185

180186
##### Action Rules
181187

182-
Token action rules can be configured to allow updating who has access to many [token actions](#actions). The following table summarizes the available action rules:
188+
Token action rules can be configured to control access to many [token actions](#actions). The
189+
following table summarizes the configurable rules and their default authorized parties:
190+
191+
###### General Controls
192+
193+
| Configuration Rule | Can be Changed? | Default Authorized Party |
194+
|:--------------------------------------|:----------------|:-------------------------|
195+
| Conventions change rules | Yes | NoOne |
196+
| Max supply change rules | Yes | NoOne |
197+
| Main control group can be modified | Yes | NoOne |
198+
199+
###### Minting and Burning
200+
201+
| Configuration Rule | Can be Changed? | Default Authorized Party |
202+
|:--------------------------------------|:----------------|:-------------------------|
203+
| Manual minting rules | Yes | Contract Owner |
204+
| Manual burning rules | Yes | Contract Owner |
205+
| Minting: choosing destination rules | Yes | NoOne |
206+
207+
###### Freezing Controls
208+
209+
| Configuration Rule | Can be Changed? | Default Authorized Party |
210+
|:--------------------------------------|:----------------|:-------------------------|
211+
| Freeze rules | Yes | NoOne |
212+
| Unfreeze rules | Yes | NoOne |
213+
| Destroy frozen funds rules | Yes | NoOne |
214+
215+
###### Distribution
216+
217+
| Configuration Rule | Can be Changed? | Default Authorized Party |
218+
|:--------------------------------------|:----------------|:-------------------------|
219+
| Perpetual distribution rules | Yes | NoOne |
220+
| New tokens destination identity rules | Yes | NoOne |
221+
| Direct purchase pricing change rules | Yes | NoOne |
222+
223+
###### Emergency
183224

184-
| Configuration Rule | Can be Changed? | Default Authorized Party|
185-
|:-------------------|:------------------|:--------|
186-
| Conventions change rules | Yes | NoOne |
187-
| Max supply change rules | Yes | NoOne |
188-
| Manual minting rules | Yes | Contract Owner |
189-
| Manual burning rules | Yes | Contract Owner |
190-
| Freeze rules | Yes | NoOne |
191-
| Unfreeze rules | Yes | NoOne |
192-
| Destroy frozen funds rules | Yes | NoOne |
193-
| Emergency_action rules | Yes | NoOne |
194-
| Main control group can be modified | Yes | NoOne |
225+
| Configuration Rule | Can be Changed? | Default Authorized Party |
226+
|:--------------------------------------|:----------------|:-------------------------|
227+
| Emergency action rules | Yes | NoOne |
195228

196229
##### Distribution Rules
197230

@@ -430,6 +463,21 @@ For example, a group is defined with a required threshold of 10. The group membe
430463

431464
In this group, Member A and Member C have a combined power of 11 and can perform actions without approval from Member B. If Member B proposes an action, Member A and C must both approve to authorize the action.
432465

466+
### Token-Based Fees
467+
468+
Dash Platform allows developers to charge token fees for document-related actions (e.g., creating or transferring a document). This provides a way to monetize app usage or implement economic incentives using tokens. These fees are configured in the data contract and apply to all document types in the contract.
469+
470+
Examples:
471+
472+
- Require 1000 tokens to create a document
473+
- Burn 200 tokens when a document is transferred
474+
475+
This allows for:
476+
477+
- Spam protection (pay-to-post)
478+
- Revenue generation for app creators
479+
- Deflationary models via token burning
480+
433481
## Token Creation
434482

435483
Creating a token on Dash Platform consists of creating a data contract, registering it on the network, and then creating tokens based on the schema defined in the data contract.
@@ -510,4 +558,14 @@ Once the data contract design is completed, the contract can be registered on th
510558

511559
## Token Trading
512560

561+
### Direct Purchase
562+
563+
Tokens can be configured to enable direct purchase by users. This allows the contract owner (or other authorized party) to sell the token directly to users at a fixed price or according to a tiered pricing schedule.
564+
565+
The token’s [change control rules](#change-control-rules) include a `changeDirectPurchasePricingRules` setting to determine who is authorized to set or update the price. By default this is set to no one (`NoOne`) to disable direct sales. To allow direct sales, this rule should be set to authorize someone (e.g., the contract owner) to change pricing.
566+
567+
When enabled, the authorized party can set the token price using a state transition. Users can purchase the token through Platform’s built-in mechanism (see [Token Set Purchase Price Transition](../protocol-ref/token.md#token-set-purchase-price-transition) and [Token Purchase Transition](../protocol-ref/token.md#token-purchase-transition)). The direct purchase system supports defining a minimum purchase amount and volume discounts via pricing tiers. The token’s price can also be removed to stop sales.
568+
569+
### Marketplace
570+
513571
A planned token marketplace will support the trading of tokens.

docs/protocol-ref/data-contract.md

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,34 @@
88

99
Data contracts define the schema (structure) of data an application will store on Dash Platform. Contracts are described using [JSON Schema](https://json-schema.org/understanding-json-schema/) which allows the platform to validate the contract-related data submitted to it.
1010

11-
The following sections provide details that developers need to construct valid contracts. All data contracts must define one or more [documents](#data-contract-documents) or [tokens](#data-contract-tokens), whereas definitions are optional and may not be used for simple contracts.
11+
The following sections provide details that developers need to construct valid contracts. All data contracts must define at least one [document](#data-contract-documents) or [token](#data-contract-tokens). A contract may define multiple documents and/or tokens.
12+
13+
### Fees
14+
15+
Dash Platform charges fees for registering data contracts based on complexity. These fees compensate evonodes for their role in storing and processing contract-related data.
16+
17+
The table below outlines the current fee structure for various data contract components. Fees are denominated in DASH and are charged at registration time based on the structure of the contract.
18+
19+
| Fee Component | Amount (DASH) | Description |
20+
|--------------------------------------------------------|-------------------|---------|
21+
| `base_contract_registration_fee` | 0.1 | Fixed fee for every data contract. Covers the baseline cost of anchoring a contract into platform state. |
22+
| `document_type_registration_fee` | 0.02 | Charged per [document type](./data-contract-document.md#contract-documents). Reflects indexing and storage schema overhead. |
23+
| `document_type_base_non_unique`<br>`_index_registration_fee` | 0.01 | Per non-unique [index](./data-contract-document.md#document-indices) in a document type. Supports query operations. |
24+
| `document_type_base_unique_index`<br>`_registration_fee` | 0.01 | Per unique [index](./data-contract-document.md#document-indices). Enforces uniqueness and adds validation complexity. |
25+
| `document_type_base_contested`<br>`_index_registration_fee` | 1.0 | Per [contested index](./data-contract-document.md#contested-indices). Used for identity/username resolution; requires voting and [conflict resolution](../explanations/dpns.md#conflict-resolution) by masternodes and evonodes. |
26+
| `token_registration_fee` | 0.1 | Per token defined in the contract. Reflects additional overhead from managing balances, transfers, and supply. |
27+
| `token_uses_perpetual`<br>`_distribution_fee` | 0.1 | Additional fee for tokens that use perpetual (e.g., block-based) distribution mechanisms. These create ongoing state changes triggered by network events. |
28+
| `token_uses_pre_programmed`<br>`_distribution_fee` | 0.1 | Charged when tokens use scheduled distributions (e.g., airdrops). Adds periodic complexity. |
29+
| `search_keyword_fee` | 0.1 per keyword | Charged per search keyword defined. Keywords enable reverse lookups and indexing, increasing on-chain storage and filtering load. |
30+
31+
These fees are additive. For example, a contract that defines two document types, each with one unique index, and one token using a perpetual distribution will incur the following total fee:
32+
33+
```text
34+
0.1 (base) + 0.02×2 (documents) + 0.01×2 (unique indices) = 0.16 DASH
35+
0.1 (token) + 0.1 (perpetual) = 0.2 DASH
36+
37+
Total fee: 0.16 + 0.2 = 0.36 DASH
38+
```
1239

1340
### General Constraints
1441

@@ -40,7 +67,7 @@ Include the following at the same level as the `properties` keyword to ensure pr
4067

4168
## Data Contract Object
4269

43-
The data contract object consists of the following fields as defined in the Rust reference client ([rs-dpp](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/v1/data_contract.rs#L67-L105)):
70+
The data contract object consists of the following fields as defined in the Rust reference client ([rs-dpp](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/data_contract/v1/data_contract.rs#L77-L121)):
4471

4572
| Property | Type | Size | Description |
4673
| --------------- | -------------- | ---- | ----------- |
@@ -54,6 +81,8 @@ The data contract object consists of the following fields as defined in the Rust
5481
| $defs | object | Varies | (Optional) Definitions for `$ref` references used in the `documents` object (if present, must be a non-empty object with \<= 100 valid properties) |
5582
| [groups](#data-contract-groups) | Group | Varies | (Optional) Groups that allow for specific multiparty actions on the contract. |
5683
| [tokens](./data-contract-token.md) | object | Varies | (Optional \*) Token definitions (see [Contract Tokens](./data-contract-token.md) for details) |
84+
| keywords | array of strings | Varies | (Optional) Keywords associated with the contract to improve searchability. Maximum of 20 words. |
85+
| description | string | 3-100 characters | (Optional) Brief description of the contract. |
5786

5887
\* The data contract object must define documents or tokens. It may include both documents and tokens.
5988

@@ -293,7 +322,9 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/
293322
"properties": {
294323
"position": true
295324
},
296-
"required": ["position"]
325+
"required": [
326+
"position"
327+
]
297328
}
298329
}
299330
}
@@ -353,6 +384,50 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/
353384
}
354385
}
355386
]
387+
},
388+
"documentActionTokenCost": {
389+
"type": "object",
390+
"properties": {
391+
"contractId": {
392+
"type": "array",
393+
"contentMediaType": "application/x.dash.dpp.identifier",
394+
"byteArray": true,
395+
"minItems": 32,
396+
"maxItems": 32
397+
},
398+
"tokenPosition": {
399+
"type": "integer",
400+
"minimum": 0,
401+
"maximum": 65535
402+
},
403+
"amount": {
404+
"type": "integer",
405+
"minimum": 1,
406+
"maximum": 281474976710655
407+
},
408+
"effect": {
409+
"type": "integer",
410+
"enum": [
411+
0,
412+
1
413+
],
414+
"description": "0 - TransferTokenToContractOwner (default), 1 - Burn"
415+
},
416+
"gasFeesPaidBy": {
417+
"type": "integer",
418+
"enum": [
419+
0,
420+
1,
421+
2
422+
],
423+
"description": "0 - DocumentOwner (default), 1 - ContractOwner, 2 - PreferContractOwner"
424+
}
425+
},
426+
"required": [
427+
"tokenPosition",
428+
"amount"
429+
],
430+
"additionalProperties": false
356431
}
357432
},
358433
"properties": {
@@ -442,7 +517,9 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/
442517
"maxLength": 256
443518
}
444519
},
445-
"required": ["resolution"],
520+
"required": [
521+
"resolution"
522+
],
446523
"additionalProperties": false
447524
}
448525
},
@@ -519,6 +596,30 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/
519596
],
520597
"description": "Key requirements. 0 - Unique Non Replaceable, 1 - Multiple, 2 - Multiple with reference to latest key."
521598
},
599+
"tokenCost": {
600+
"type": "object",
601+
"properties": {
602+
"create": {
603+
"$ref": "#/$defs/documentActionTokenCost"
604+
},
605+
"replace": {
606+
"$ref": "#/$defs/documentActionTokenCost"
607+
},
608+
"delete": {
609+
"$ref": "#/$defs/documentActionTokenCost"
610+
},
611+
"transfer": {
612+
"$ref": "#/$defs/documentActionTokenCost"
613+
},
614+
"update_price": {
615+
"$ref": "#/$defs/documentActionTokenCost"
616+
},
617+
"purchase": {
618+
"$ref": "#/$defs/documentActionTokenCost"
619+
}
620+
},
621+
"additionalProperties": false
622+
},
522623
"properties": {
523624
"type": "object",
524625
"additionalProperties": {
@@ -578,6 +679,17 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/
578679
"type": "string"
579680
}
580681
},
682+
"keywords": {
683+
"type": "array",
684+
"description": "List of up to 20 descriptive keywords for the contract, used in the Keyword Search contract",
685+
"items": {
686+
"type": "string",
687+
"minLength": 3,
688+
"maxLength": 50
689+
},
690+
"maxItems": 20,
691+
"uniqueItems": true
692+
},
581693
"additionalProperties": {
582694
"type": "boolean",
583695
"const": false

docs/protocol-ref/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Code range: 10100-10199
4848

4949
### Data Contract
5050

51-
Code range: 10200-10399
51+
Code range: 10200-10349
5252

5353
| Code | Error Description | Comment |
5454
| :---: | ----------------------------------------------- | ------- |

docs/protocol-ref/token.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Each token transition must comply with the [token base transition defined in rs-
2424

2525
#### Token id
2626

27-
The `$tokenId` is created by double sha256 hashing the token `$dataContractId` and `$tokenContractPosition` with a byte vector of the string "dash_token" as shown in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/tokens/mod.rs#L22-L27).
27+
The `$tokenId` is created by double sha256 hashing the token `$dataContractId` and `$tokenContractPosition` with a byte vector of the string "dash_token" as shown in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/tokens/mod.rs#L26-L31).
2828

2929
```rust
3030
// From the Rust reference implementation (rs-dpp)
@@ -57,7 +57,7 @@ The token transition actions [defined in rs-dpp](https://github.com/dashpay/plat
5757

5858
### Token Notes
5959

60-
Some token transitions include optional notes fields. The maximum note length for these fields is [2048 characters](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/tokens/mod.rs#L14).
60+
Some token transitions include optional notes fields. The maximum note length for these fields is [2048 characters](https://github.com/dashpay/platform/blob/v2.0-dev/packages/rs-dpp/src/tokens/mod.rs#L18).
6161

6262
### Token Burn Transition
6363

0 commit comments

Comments
 (0)