diff --git a/docs/protocol-ref/address-system.md b/docs/protocol-ref/address-system.md index 9392150c4..f3253208f 100644 --- a/docs/protocol-ref/address-system.md +++ b/docs/protocol-ref/address-system.md @@ -36,12 +36,12 @@ Platform addresses are derived from standard Bitcoin/Dash address formats and en **Encoding:** -- **Mainnet HRP:** `evo` -- **Testnet HRP:** `tevo` +- **Mainnet HRP:** `dash` +- **Testnet HRP:** `tdash` (also used for Devnet and Regtest) **Derivation:** Standard Bitcoin derivation using `Hash160(compressed_pubkey)` where Hash160 = RIPEMD160(SHA256(x)). -See the [Platform address implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/address_funds/platform_address.rs). +See the [Platform address implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs). ### Address Witness @@ -63,10 +63,10 @@ Witnesses provide cryptographic proof of address ownership. Each input in an add 1. Verify redeem script hashes to address 2. Parse script for threshold (M) and public keys (N) -3. Hash signable bytes once (reused for all signatures) +3. Double-SHA256 hash the signable bytes (reused for all signatures) 4. Match M signatures to N public keys in order -See the [witness implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/address_funds/witness.rs). +See the [witness implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/witness.rs). ### Fee Strategy @@ -81,7 +81,7 @@ The fee strategy specifies how transaction fees are deducted from inputs or outp Fee strategy cannot be empty. Maximum steps: 4 (`max_address_fee_strategies`). No duplicate steps allowed. Steps are processed in sequence until the fee is fully covered. ::: -See the [fee strategy implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/address_funds/fee_strategy/mod.rs). +See the [fee strategy implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/fee_strategy/mod.rs). ### Common Type Aliases @@ -110,7 +110,7 @@ Transfer credits from an existing identity to one or more Platform addresses. Minimum recipients: 1. Maximum recipients: `max_address_outputs`. Minimum per recipient: 500,000 credits. Minimum fee: 500,000 credits. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_to_addresses_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_to_addresses_transition/). ### Identity Create from Addresses @@ -131,7 +131,7 @@ Create a new identity funded from Platform address balances. **Cost:** Base cost 2,000,000 + 6,500,000 per key. Example: 2 keys = 15,000,000 credits. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_from_addresses_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_from_addresses_transition/). ### Identity Top-Up from Addresses @@ -152,7 +152,7 @@ Add credits to an existing identity from Platform address balances. **Fee:** Base top-up cost: 500,000 credits. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_from_addresses_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_from_addresses_transition/). ### Address Funds Transfer @@ -176,7 +176,7 @@ Unlike other address transitions, fund transfers enforce strict balance preserva **Fee:** 500,000 credits per input + 6,000,000 credits per output. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funds_transfer_transition/). ### Address Funding from Asset Lock @@ -202,7 +202,7 @@ Exactly one output must have a `None` value. This remainder output receives what **Constraints:** Minimum outputs: 1. Maximum inputs: `max_address_inputs`. Maximum outputs: `max_address_outputs`. Minimum per input: 100,000 credits. Minimum per explicit output: 500,000 credits. No output can also be an input. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/). ### Address Credit Withdrawal @@ -225,7 +225,7 @@ Withdraw credits from Platform addresses back to the Core chain. **Fee:** 400,000,000 credits. Withdrawal fees are significantly higher due to the complexity and finality of moving funds back to the Core chain. ::: -See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.0.0/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_credit_withdrawal_transition/). +See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_credit_withdrawal_transition/). ### Address State Transition Signing @@ -246,8 +246,8 @@ For complete constants reference, see [Protocol Constants](protocol-constants.md | `min_input_amount` | 100,000 credits | 64 bits | Minimum per input | | `min_output_amount` | 500,000 credits | 64 bits | Minimum per output | | `min_identity_funding_amount`| 200,000 credits | 64 bits | Minimum for identity creation/top-up | -| `max_address_inputs` | 0 (unlimited) | 16 bits | Maximum inputs per transition | -| `max_address_outputs` | 0 (unlimited) | 16 bits | Maximum outputs per transition | -| `max_address_fee_strategies` | 4 | 8 bits | Maximum fee strategy steps | +| `max_address_inputs` | 16 | 16 bits | Maximum inputs per transition (Protocol Version 11+) | +| `max_address_outputs` | 128 | 16 bits | Maximum outputs per transition (Protocol Version 11+) | +| `max_address_fee_strategies` | 4 | 16 bits | Maximum fee strategy steps | For related identity operations, see [Identity](identity.md) and [State Transitions](state-transition.md). diff --git a/docs/protocol-ref/data-contract-document.md b/docs/protocol-ref/data-contract-document.md index 315366966..f26f0e6a6 100644 --- a/docs/protocol-ref/data-contract-document.md +++ b/docs/protocol-ref/data-contract-document.md @@ -4,6 +4,10 @@ The `documents` object defines each type of document in the data contract. At a minimum, a document must consist of 1 or more properties. The `additionalProperties` properties keyword must be included as described in the [constraints](./data-contract.md#additional-properties) section and each property must be [assigned a position](#assigning-position). +:::{note} +The `$schema` property is required for each document type but is automatically injected by the platform during [contract enrichment](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/schema/enrich_with_base_schema/v0/mod.rs). Do not include it in user-submitted document type definitions — providing it will result in a validation error. +::: + The following example shows a minimal `documents` object defining a single document (`note`) with one property (`message`). ```json @@ -117,10 +121,10 @@ There are a variety of constraints currently defined for performance and securit | Description | Value | | ----------- | ----- | -| Minimum number of properties | [1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L22) | -| Maximum number of properties | [100](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L23) | -| Minimum property name length | [1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L20) | -| Maximum property name length | [64](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L20) | +| Minimum number of properties | [1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L22) | +| Maximum number of properties | [100](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L23) | +| Minimum property name length | [1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L20) | +| Maximum property name length | [64](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L20) | | Property name characters | Alphanumeric (`A-Z`, `a-z`, `0-9`)
Hyphen (`-`)
Underscore (`_`) | ## Document Indices @@ -130,7 +134,7 @@ Document indices may be defined if indexing on document fields is required. The The `indices` array consists of one or more objects that each contain: * A unique `name` for the index -* A `properties` array composed of a `` object for each document field that is part of the index +* A `properties` array composed of a `` object for each document field that is part of the index (only `asc` is currently supported) :::{admonition} Compound Indices :class: attention @@ -145,8 +149,8 @@ The `indices` array consists of one or more objects that each contain: { "name": "", "properties": [ - { "": "" }, - { "": "" } + { "": "asc" }, + { "": "asc" } ], "unique": true|false, "nullSearchable": true|false, @@ -163,7 +167,7 @@ The `indices` array consists of one or more objects that each contain: { "name": "", "properties": [ - { "": "" }, + { "": "asc" }, ], } ] @@ -207,15 +211,15 @@ For performance and security reasons, indices have the following constraints. Th | Description | Value | | ----------- | ----- | -| Minimum/maximum length of index `name` | [1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L357) / [32](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L358) | -| Maximum number of indices | [10](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L438) | -| Maximum number of unique indices | [10](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v2.rs#L27) | -| Maximum number of contested indices | [1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v2.rs#L26) | -| Maximum number of properties in a single index | [10](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L377) | -| Maximum length of indexed string property | [63](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L35) | +| Minimum/maximum length of index `name` | [1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L357) / [32](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L358) | +| Maximum number of indices | [10](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L438) | +| Maximum number of unique indices | [10](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v2.rs#L27) | +| Maximum number of contested indices | [1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v2.rs#L26) | +| Maximum number of properties in a single index | [10](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L377) | +| Maximum length of indexed string property | [63](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L22) | | Usage of `$id` in an index [disallowed](https://github.com/dashpay/platform/pull/178) | N/A | -| **Note: Dash Platform [does not allow indices for arrays](https://github.com/dashpay/platform/pull/225).**
Maximum length of indexed byte array property | [255](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L36) | -| **Note: Dash Platform [does not allow indices for arrays](https://github.com/dashpay/platform/pull/225).**
Maximum number of indexed array items | [1024](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L37) | +| **Note: Dash Platform [does not allow indices for arrays](https://github.com/dashpay/platform/pull/225).**
Maximum length of indexed byte array property | [255](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L24) | +| **Note: Dash Platform [does not allow indices for arrays](https://github.com/dashpay/platform/pull/225).**
Maximum number of indexed array items | [1024](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L25) | :::{seealso} For all protocol constants, see [Protocol Constants](protocol-constants.md). @@ -250,6 +254,7 @@ Documents support the following configuration options to provide flexibility in | `transferable` | integer | Transferable without a marketplace sell:
`0` - Never
`1` - Always
See the [NFT page](../explanations/nft.md#transfer-and-trade) for more details | | `tradeMode` | integer | Built-in marketplace system:
`0` - None
`1` - Direct purchase (the purchaser can buy the item without requiring approval)
See the [NFT page](../explanations/nft.md#transfer-and-trade) for more details | | `creationRestrictionMode` | integer | Restriction of document creation:
`0` - No restrictions
`1` - Contract owner only
`2` - No creation (System Only)
See the [NFT page](../explanations/nft.md#creation-restrictions) for more details | +| `keywords` | array of strings | Up to 20 strings (3–50 characters each) describing the document type for searchability | | Security option | Type | Description | |-----------------|------|-------------| @@ -257,14 +262,37 @@ Documents support the following configuration options to provide flexibility in | [`requiresIdentity`
`DecryptionBoundedKey`](./data-contract.md#key-management) | integer | Key requirements for identity decryption:
`0` - Unique non-replaceable
`1` - Multiple
`2` - Multiple with reference to latest key | | `signatureSecurity`
`LevelRequirement` | integer | Public key security level:
`1` - Critical
`2` - High
`3` - Medium. Default is High if none specified. | +### Token Costs + +The `tokenCost` option allows document types to require token payment for operations. When configured, users must pay a specified amount of tokens to perform each operation type. Each operation cost is defined as a [documentActionTokenCost](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json#L293-336) object with the following properties: + +| Property | Type | Required | Description | +|----------|------|----------|-------------| +| `contractId` | array (32 bytes) | No | Identifier of the contract containing the payment token. Defaults to the current contract if omitted. | +| `tokenPosition` | integer (0–65535) | Yes | Position of the token within the contract | +| `amount` | integer (1–281474976710655) | Yes | Number of tokens required for the operation | +| `effect` | integer | No | Token disposition after payment:
`0` - Transfer to contract owner (default)
`1` - Burn (tokens destroyed) | +| `gasFeesPaidBy` | integer | No | Who pays gas fees for the operation:
`0` - Document owner (default)
`1` - Contract owner
`2` - Prefer contract owner (falls back to document owner if insufficient) | + +The following operation types can each have an independent cost configuration: + +| Operation | Description | +|-----------|-------------| +| `create` | Creating a new document | +| `replace` | Replacing an existing document | +| `delete` | Deleting a document | +| `transfer` | Transferring document ownership | +| `update_price` | Updating a document's purchase price | +| `purchase` | Purchasing a document | + :::{dropdown} List of all usable document properties - This list of properties is defined in the [Rust DPP implementation](https://github.com/dashpay/platform/blob/master/packages/rs-dpp/src/data_contract/document_type/mod.rs#L31) and the [document meta-schema](https://github.com/dashpay/platform/blob/master/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json). + This list of properties is defined in the [Rust DPP implementation](https://github.com/dashpay/platform/blob/master/packages/rs-dpp/src/data_contract/document_type/mod.rs#L41) and the [document meta-schema](https://github.com/dashpay/platform/blob/master/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json). | Property Name | Type | Description | |---------------|------|-------------| | `type` | string | Specifies the type of the document, constrained to "object". | - | `$schema` | string | The schema URL reference for the document. | + | `$schema` | string | Platform-injected during enrichment; not accepted in user submissions. | | `$defs` | object | References the `documentProperties` definition. | | [`indices`](#document-indices) | array | Defines indices for the document with properties like `name`, `unique`, `nullSearchable`, and `contested`. | | `signatureSecurity`
`LevelRequirement` | integer | Public key security level:
`1` - Critical
`2` - High
`3` - Medium. Default is High if none specified. | @@ -278,6 +306,8 @@ Documents support the following configuration options to provide flexibility in | [`requiresIdentity`
`DecryptionBoundedKey`](./data-contract.md#key-management) | integer | Key requirements for identity decryption:
`0` - Unique non-replaceable
`1` - Multiple
`2` - Multiple with reference to latest key | | [`properties`](#document-properties) | object | Defines the properties of the document. | | [`transient`](#transient-properties) | array | An array of strings specifying transient properties that are validated by Platform but not stored. | + | `tokenCost` | object | Defines token costs for document operations (create, replace, update_price, delete, transfer, purchase) | + | `keywords` | array | Up to 20 strings (3–50 characters each) for searchability | | [`additionalProperties`](./data-contract.md#additional-properties) | boolean | Specifies whether additional properties are allowed. Must be set to false, meaning no additional properties are allowed beyond those defined. | ::: @@ -303,7 +333,7 @@ The following example (from the [DPNS contract's `domain` document](https://gith There are a variety of keyword constraints currently defined for performance and security reasons. The following constraints apply to document definitions. Unless otherwise noted, these constraints are defined in the platform's JSON Schema rules (e.g., [rs-dpp document meta -schema](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json)). +schema](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json)). | Keyword | Constraint | | ------- | ---------- | @@ -372,4 +402,4 @@ This example syntax shows the structure of a documents object that defines two d ## Document Schema -See full document schema details in the [rs-dpp document meta schema](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json). +See full document schema details in the [rs-dpp document meta schema](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json). diff --git a/docs/protocol-ref/data-contract-token.md b/docs/protocol-ref/data-contract-token.md index 1fca138ec..731ba7c3f 100644 --- a/docs/protocol-ref/data-contract-token.md +++ b/docs/protocol-ref/data-contract-token.md @@ -2,7 +2,11 @@ ## Contract Token Overview -The `tokens` object defines each type of token in the data contract. At a minimum, a token must consist of [conventions](#token-conventions) and [change control rules](#token-change-control-rules). Each token must be assigned a unique [position](#assigning-position) within the contract and follow the [token constraints](#token-constraints). +The `tokens` object defines each type of token in the data contract. At a minimum, a token must define [conventions](#token-conventions). All other fields have sensible defaults. Each token must be assigned a unique [position](#assigning-position) within the contract and follow the [token constraints](#token-constraints). + +:::{note} +The protocol only requires `conventions`. However, some SDKs (e.g., the JavaScript SDK) may require [change control rules](#token-change-control-rules) to be provided explicitly. +::: The following example shows a minimal `tokens` object defining a single token with basic conventions: @@ -44,10 +48,10 @@ Token creation incurs specific fees based on which token features are used: | Operation | Fee (DASH)| Description | |-----------|-----------|-------------| -| Token registration | [0.1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L11)| Base fee for adding a token to a contract | -| Perpetual distribution | [0.1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L12) | Fee for enabling perpetual distribution | -| Pre-programmed distribution | [0.1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L13) | Fee for enabling pre-programmed distribution | -| Search keyword fee | [0.1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L14) | Per keyword fee for including search keywords | +| Token registration | [0.1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L11)| Base fee for adding a token to a contract | +| Perpetual distribution | [0.1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L12) | Fee for enabling perpetual distribution | +| Pre-programmed distribution | [0.1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L13) | Fee for enabling pre-programmed distribution | +| Search keyword fee | [0.1](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs#L14) | Per keyword fee for including search keywords | ## Assigning Position @@ -95,6 +99,10 @@ The `localizations` object contains language-specific display properties using [ } ``` +::::{note} +An English (`en`) localization entry is required. Tokens without an `en` key in the `localizations` map will fail protocol validation with a `MissingDefaultLocalizationError`. +:::: + ### Decimal Precision The `decimals` property specifies the number of decimal places for token amounts. This affects how token balances are displayed and calculated. If `decimals` is set to zero, token operations (e.g., mint, transfer) will only allow integer amounts. @@ -111,6 +119,12 @@ The `decimals` property specifies the number of decimal places for token amounts Token configuration controls behavioral aspects of token operations, including supply management, operational controls, and security features. +### General + +| Property | Type | Description | +|----------|------|-------------| +| `description` | string | Optional text describing the token's purpose or behavior (3–100 characters) | + ### Supply Management | Property | Type | Description | @@ -151,7 +165,7 @@ Change control rules define authorization requirements for modifying various asp ### Authorized Parties -Rules can authorize no one, specific identities, or multiparty groups. The complete set of options [defined by DPP](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/change_control_rules/authorized_action_takers.rs#L14-L21) is: +Rules can authorize no one, specific identities, or multiparty groups. The complete set of options [defined by DPP](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/change_control_rules/authorized_action_takers.rs#L15-L22) is: | Authorized Party | Description | |----------------------|-------------| @@ -163,7 +177,7 @@ Rules can authorize no one, specific identities, or multiparty groups. The compl ### Change Rule Structure -Each rule consists of the following parameters [defined in DPP](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/change_control_rules/v0/mod.rs) that control its behavior: +Each rule consists of the following parameters [defined in DPP](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/change_control_rules/v0/mod.rs) that control its behavior: | Field | Description | | - | - | @@ -196,7 +210,6 @@ Tokens support the following change control rules: | `conventionsChangeRules` | Controls who can modify token conventions (localization) | | `maxSupplyChangeRules` | Controls who can modify the maximum supply limit | | `perpetualDistributionRules` | Controls who can modify perpetual distribution settings (subset of `distributionRules`) | -| `preProgrammedDistribution` | Controls who can modify pre-programmed distribution settings (subset of `distributionRules`) | | `newTokensDestinationIdentityRules` | Controls who can change where new tokens are sent (subset of `distributionRules`)| | `mintingAllowChoosingDestinationRules` | Controls who can modify minting destination rules (subset of `distributionRules`)| | `changeDirectPurchasePricingRules` | Controls who can set direct purchase pricing (subset of `distributionRules`)| @@ -232,7 +245,6 @@ Distribution rules govern how tokens are created, allocated, and priced within t |----------|------|-------------| | `perpetualDistribution` | object | Ongoing distribution mechanism for continuous token allocation | | `perpetualDistributionRules` | object | Change control rules for perpetual distribution | -| `preProgrammedDistribution` | object | Scheduled distribution events with specific timing and recipients | | `newTokensDestinationIdentity` | string | Default identity to receive newly minted tokens | | `newTokensDestinationIdentityRules` | object | Change control rules for destination identity | | `mintingAllowChoosingDestination` | boolean | Whether minting operations can specify custom destinations | @@ -260,6 +272,18 @@ Perpetual distribution enables ongoing token allocation. The following configura } ``` +#### Distribution Types + +The `distributionType` field accepts one of three schedule types: + +| Type | Interval Unit | Description | +|------|---------------|-------------| +| `BlockBasedDistribution` | Block height | Emits tokens every N blocks. If `start` is not set, begins at the block when the data contract is registered. | +| `TimeBasedDistribution` | Milliseconds | Emits tokens every N milliseconds. If `start` is not set, begins at the time of the block when the data contract is registered. | +| `EpochBasedDistribution` | Epochs | Emits tokens every N epochs. If `start` is not set, begins at the epoch of the block when the data contract is registered. Distribution happens at the start of the following epoch. Required when using `EvonodesByParticipation` as the distribution recipient. | + +Each type wraps an `interval` (the period length) and a `function` (the emission pattern from the options below). + #### Perpetual Distribution Options A wide variety of emission patterns are provided to cover most common scenarios. The following table summarizes the options and links to further details. @@ -323,13 +347,16 @@ Emits a random number of tokens within a specified range. Emits tokens that decrease in discrete steps at fixed intervals. -- **Formula:** `f(x) = n * (1 - (numerator / denominator))^((x - s) / step_count)` -- **Description:** Reduces token emissions by a fixed percentage at regular intervals. Includes optional start offset and minimum emission floor. - - `step_count`: number of periods between each step - - `numerator` and `denominator`: the reduction factor per step - - `s`: optional start period offset (e.g., start block or time). If not provided, the contract creation start is used. - - `n`: initial token emission amount - - `min_value`: optional minimum emission value +- **Formula:** `f(x) = distribution_start_amount * (1 - (decrease_per_interval_numerator / decrease_per_interval_denominator))^((x - start_decreasing_offset) / step_count)` +- **Description:** Reduces token emissions by a fixed percentage at regular intervals. + - `step_count` (u32): number of periods between each step + - `decrease_per_interval_numerator` (u16): reduction factor numerator + - `decrease_per_interval_denominator` (u16): reduction factor denominator + - `start_decreasing_offset` (optional u64): start period offset. If not provided, the contract creation start is used. Before this offset, `distribution_start_amount` is emitted every interval. + - `distribution_start_amount` (TokenAmount): initial token emission amount + - `max_interval_count` (optional u16): maximum number of decreasing intervals. **Defaults to 128 if not set.** After this many cycles, `trailing_distribution_interval_amount` is emitted per interval. Maximum value: 1024. + - `trailing_distribution_interval_amount` (TokenAmount): token emission after all decreasing intervals are exhausted + - `min_value` (optional u64): minimum emission floor - **Use Case:** Reward systems with predictable decay—ideal for Bitcoin-style halvings or Dash-style gradual reductions - **Example:** - Bitcoin: 50% reduction every 210,000 blocks @@ -395,21 +422,17 @@ A polynomial function using fixed-point arithmetic for fractional or integer exp Emits tokens following an exponential function. -- **Formula:** `f(x) = a * e^(b * x) + c` -- **Description:** - - `b` > 0 -> rapid growth - - `b` < 0 -> rapid decay +- **Formula:** `f(x) = (a * e^(m * (x - s + o) / n)) / d + b` +- **Description:** Exponential growth or decay depending on parameter signs - **Use Case:** Early contributor boosts or quick emission tapering -- **Example:** f(x) = 100 * e^(-0.693 * x) + 5 ##### Logarithmic Logarithmic growth of token emissions. -- **Formula:** `f(x) = a * log_b(x) + c` -- **Description:** Growth slows as `x` increases +- **Formula:** `f(x) = (a * ln(m * (x - s + o) / n)) / d + b` +- **Description:** Growth slows as `x` increases (uses natural log) - **Use Case:** Sustainable long-term emission tapering -- **Example:** f(x) = 20 * log_2(x) + 5 ##### Inverted Logarithmic @@ -551,6 +574,39 @@ Marketplace rules define how tokens can be traded within Platform's built-in mar } ``` +## Token Distribution Function Parameters + +The distribution functions use the following parameters defined across various implementations: + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `a` | integer | - | Coefficient/scaling factor | +| `b` | integer | - | Base offset or constant term | +| `c` | integer | - | Additional offset | +| `d` | integer | 1 | Divisor for precision control | +| `m` | integer | - | Exponent numerator | +| `n` | integer | 1 | Exponent denominator | +| `o` | integer | 0 | Offset inside function input | +| `s` | integer | 0 | Start period offset | +| `min_value` | integer | - | Minimum emission bound | +| `max_value` | integer | - | Maximum emission bound | +| `step_count` | integer | - | Periods between steps | +| `numerator` | integer | - | Reduction factor numerator | +| `denominator` | integer | - | Reduction factor denominator | +| `interval` | integer | - | Time interval in milliseconds | + +### Distribution Recipients + +| Recipient | Description | +|-----------|-------------| +| `ContractOwner` | Tokens sent to the contract owner | +| `Identity(Identifier)` | Tokens sent to a specific identity | +| `EvonodesByParticipation` | Tokens distributed to evonodes proportional to their participation (only valid with `EpochBasedDistribution`) | + +:::{seealso} +For all protocol constants, see [Protocol Constants](protocol-constants.md). +::: + ## Token Constraints For performance and security reasons, tokens have the following constraints: @@ -559,27 +615,27 @@ For performance and security reasons, tokens have the following constraints: | Parameter | Value | |-----------|-------| -| Maximum number of keywords | [50](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L272-L277) | -| Keyword length | [3 to 50 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L279-L287) | -| Description length | [3 to 100 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L312-L323) | -| Maximum note length | [2048 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/tokens/mod.rs#L19) | +| Maximum number of keywords | [20 at creation; 50 on update](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L272-L277) | +| Keyword length | [3 to 50 characters](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L279-L287) | +| Description length | [3 to 100 characters](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/methods/validate_update/v0/mod.rs#L312-L323) | +| Maximum note length | [2048 bytes](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L19) | | Maximum number of tokens per contract | Only limited by [maximum contract size](./data-contract.md#data-size) | ### Convention Constraints | Parameter | Value | |-----------|-------| -| Language code length | [2 to 12 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L97-L101) | -| Token name length (singular) | [3 to 25 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L84-L89) | -| Token name length (plural) | [3 to 25 characters](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L90-L95) | -| Decimal places | [0 to 16](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L31-L36) | +| Language code length | [2 to 12 characters](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L97-L101) | +| Token name length (singular) | [3 to 25 characters](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L84-L89) | +| Token name length (plural) | [3 to 25 characters](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L90-L95) | +| Decimal places | [0 to 16](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_convention/methods/validate_localizations/v0/mod.rs#L31-L36) | | Maximum localization entries | Only limited by [maximum contract size](./data-contract.md#data-size) | ### Supply Constraints | Parameter | Value | |-----------|-------| -| Maximum token amount | [2^64 - 1](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/errors/consensus/basic/data_contract/invalid_token_base_supply_error.rs#L12-L16) | +| Maximum token amount | [i64::MAX (2^63 - 1 = 9,223,372,036,854,775,807)](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/errors/consensus/basic/data_contract/invalid_token_base_supply_error.rs#L12-L16) | ## Example Syntax diff --git a/docs/protocol-ref/data-contract.md b/docs/protocol-ref/data-contract.md index 2b9b35ea9..6a47adb8a 100644 --- a/docs/protocol-ref/data-contract.md +++ b/docs/protocol-ref/data-contract.md @@ -31,8 +31,8 @@ The table below outlines the current fee structure for various data contract com 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: ```text -0.1 (base) + 0.02×2 (documents) + 0.01×2 (unique indices) = 0.16 DASH -0.1 (token) + 0.1 (perpetual) = 0.2 DASH +0.1 (base contract) + 0.02×2 (document types) + 0.01×2 (1 unique index per document type × 2) = 0.16 DASH +0.1 (token registration) + 0.1 (perpetual distribution) = 0.2 DASH Total fee: 0.16 + 0.2 = 0.36 DASH ``` @@ -45,9 +45,9 @@ There are a variety of constraints currently defined for performance and securit | Parameter | Size | | - | - | -| Maximum serialized data contract size | [16384 bytes (16 KB)](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/system_limits/v1.rs#L4) | -| Maximum field value size | [5120 bytes (5 KB)](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/system_limits/v1.rs#L5) | -| Maximum state transition size | [20480 bytes (20 KB)](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-version/src/version/system_limits/v1.rs#L6) | +| Estimated maximum serialized data contract size | [16384 bytes (16 KB)](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L4) | +| Maximum field value size | [5120 bytes (5 KB)](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L5) | +| Maximum state transition size | [20480 bytes (20 KB)](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L6) | A document cannot exceed the maximum state transition size in any case. For example, although it is possible to define a data contract with 10 document fields that each support the maximum field size @@ -67,28 +67,33 @@ Include the following at the same level as the `properties` keyword to ensure pr ## Data Contract Object -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.1/packages/rs-dpp/src/data_contract/v1/data_contract.rs#L77-L121)): +The data contract object consists of the following fields as defined in the Rust reference client ([rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/v1/data_contract.rs#L77-L121)): | Property | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | -| $version | unsigned integer | 32 bits | The platform protocol version ([currently `8`](https://github.com/dashpay/platform/blob/v1.8.0/packages/rs-platform-version/src/version/mod.rs#L26)) | -| [$schema](#data-contract-schema) | string | Varies | A valid URL | -| [id](#data-contract-id) | array of bytes | 32 bytes | Contract ID generated from `ownerId` and entropy (content media type: `application/x.dash.dpp.identifier`) | -| [version](#data-contract-version) | unsigned integer | Yes | The data contract version | +| [$schema](#data-contract-schema) | string | Varies | Schema URL; injected per-document-type during enrichment (not stored on the contract directly) | +| [id](#data-contract-id) | array of bytes | 32 bytes | Contract ID generated from `ownerId` and identity nonce (content media type: `application/x.dash.dpp.identifier`) | +| [version](#data-contract-version) | unsigned integer | 32 bits | The data contract version | | ownerId | array of bytes | 32 bytes | [Identity](../protocol-ref/identity.md) that registered the data contract defining the document (content media type: `application/x.dash.dpp.identifier`) | | [documents](./data-contract-document.md) | object | Varies | (Optional \*) Document definitions (see [Contract Documents](./data-contract-document.md) for details) | | [config](#data-contract-config) | DataContractConfig | Varies | (Optional) Internal configuration for the contract | | $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) | | [groups](#data-contract-groups) | Group | Varies | (Optional) Groups that allow for specific multiparty actions on the contract. | | [tokens](./data-contract-token.md) | object | Varies | (Optional \*) Token definitions (see [Contract Tokens](./data-contract-token.md) for details) | -| keywords | array of strings | Varies | (Optional) Keywords associated with the contract to improve searchability. Maximum of 20 words. | +| keywords | array of strings | Varies | (Optional) Keywords associated with the contract to improve searchability. Maximum of 20 keywords at creation; contract updates allow up to 50. | | description | string | 3-100 characters | (Optional) Brief description of the contract. | +| createdAt | unsigned integer | 64 bits | (Read-only) Timestamp in milliseconds when the contract was created. Set by platform. | +| updatedAt | unsigned integer | 64 bits | (Read-only) Timestamp in milliseconds when the contract was last updated. Set by platform. | +| createdAtBlockHeight | unsigned integer | 64 bits | (Read-only) Block height at contract creation. Set by platform. | +| updatedAtBlockHeight | unsigned integer | 64 bits | (Read-only) Block height at last contract update. Set by platform. | +| createdAtEpoch | unsigned integer | 16 bits | (Read-only) Epoch index at contract creation. Set by platform. | +| updatedAtEpoch | unsigned integer | 16 bits | (Read-only) Epoch index at last contract update. Set by platform. | \* The data contract object must define documents or tokens. It may include both documents and tokens. ### Data Contract schema -The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/document_type/schema/enrich_with_base_schema/v0/mod.rs#L6-L7), hosted on [GitHub](https://github.com/dashpay/platform/blob/master/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json), and can be viewed by expanding this dropdown: +The full schema is [defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/schema/enrich_with_base_schema/v0/mod.rs#L6-L7), hosted on [GitHub](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json), and can be viewed by expanding this dropdown: ::: {dropdown} Full schema @@ -708,7 +713,7 @@ The full schema is [defined is rs-dpp](https://github.com/dashpay/platform/blob/ ### Data Contract id -The data contract `id` is a hash of the `ownerId` and entropy as shown [here](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/generate_data_contract.rs). +The data contract `id` is a hash of the `ownerId` and `identity_nonce` as shown in the [rs-dpp implementation](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/generate_data_contract.rs). ```rust // From the Rust reference implementation (rs-dpp) @@ -736,13 +741,14 @@ See the [data contract documents](./data-contract-document.md) page for details. ### Data Contract config -The data contract config defines configuration options for data contracts, controlling their lifecycle, mutability, history management, and encryption requirements. Data contracts support three categories of configuration options to provide flexibility in contract design. It is only necessary to include them in a data contract when non-default values are used. The default values for these configuration options are defined in the [Rust DPP implementation](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/config/fields.rs). +The data contract config defines configuration options for data contracts, controlling their lifecycle, mutability, history management, and encryption requirements. Data contracts support three categories of configuration options to provide flexibility in contract design. It is only necessary to include them in a data contract when non-default values are used. The default values for these configuration options are defined in the [Rust DPP implementation](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/config/fields.rs). | Contract option | Default | Description | |-----------------------------------------|---------|-------------| -| `canBeDeleted` | `false` | Determines if the contract can be deleted | +| `canBeDeleted` | `false` | Determines if the data contract itself can be deleted. Note: documents have a separate `canBeDeleted` option (default: `true`) defined per document type in [data-contract-document.md](./data-contract-document.md). | | `readonly` | `false` | Determines if the contract is read-only. Read-only contracts cannot be updated. | | `keepsHistory` | `false` | Determines if changes to the contract itself are tracked, maintaining a historical record of contract modifications. | +| `sizedIntegerTypes` | `true` | Enables sized integer types for the contract. | | Document default option | Default | Description | |-----------------------------------------|---------|-------------| @@ -765,7 +771,7 @@ These security options can be set at the root level of the data contract or the **Example** -The following example (from the [DashPay contract's `contactRequest` document](https://github.com/dashpay/platform/blob/master/packages/dashpay-contract/schema/v1/dashpay.schema.json#L142-L146)) demonstrates the use of both key-related options at the document level: +The following example (from the [DashPay contract's `contactRequest` document](https://github.com/dashpay/platform/blob/v3.1-dev/packages/dashpay-contract/schema/v1/dashpay.schema.json#L142-L146)) demonstrates the use of both key-related options at the document level: ``` json "contactRequest": { @@ -774,7 +780,7 @@ The following example (from the [DashPay contract's `contactRequest` document](h } ``` -See the data contract [config implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/config/v0/mod.rs#L18-L43) for more details. +See the data contract [config implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/config/v1/mod.rs#L21-L48) for more details. ### Data Contract groups @@ -792,8 +798,8 @@ Groups can be used to distribute contract configuration and update authorization | Constant | Value | Description | |----------|-------|-------------| | `max_contract_group_size` | 256 | Maximum members per group | -| Maximum member power | 65,535 (u16::MAX) | Maximum voting power per member | -| Maximum required power | 4,294,967,295 (u32::MAX) | Maximum threshold power | +| Maximum member power | 65,535 (u32; cap enforced at u16::MAX) | Maximum voting power per member | +| Maximum required power | 65,535 (u32; cap enforced at u16::MAX) | Maximum threshold power | #### Group Action Info @@ -802,7 +808,8 @@ When submitting a group-authorized action, the transition includes: | Field | Type | Description | |-------|------|-------------| | `groupContractPosition` | u16 | Position of the group in the contract | -| `signerPower` | GroupMemberPower | Power of the signing member | +| `actionId` | Identifier (32 bytes) | The action identifier | +| `actionIsProposer` | bool | Whether the signer is the action proposer | #### Use Cases @@ -829,7 +836,7 @@ When submitting a group-authorized action, the transition includes: In this example, any two of the three members can authorize an action. -See the [groups implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/group/v0/mod.rs#L32-L35) for more details. +See the [groups implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/group/v0/mod.rs#L36-L39) for more details. ### Data Contract tokens @@ -850,16 +857,15 @@ Data contracts are created on the platform by submitting the [data contract obje | Field | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | -| $version | unsigned integer | 32 bits | The platform protocol version (currently `1`) | +| $version | unsigned integer | 32 bits | The state transition format version (currently `0`) | | type | unsigned integer | 8 bits | State transition type (`0` for data contract create) | | dataContract | [data contract object](#data-contract-object) | Varies | Object containing the data contract details | -| identityNonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | -| entropy | array of bytes | 32 bytes | Entropy used to generate the data contract ID. Generated as [shown here](../protocol-ref/state-transition.md#entropy-generation). | +| identityNonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | | userFeeIncrease | unsigned integer | 16 bits | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signaturePublicKeyId | unsigned integer | 32 bits | The `id` of the [identity public key](../protocol-ref/identity.md#identity-publickeys) that signed the state transition (`=> 0`) | | signature | array of bytes | 65 bytes | Signature of state transition data | -See the [data contract create implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs#L37-L45) for more details. +See the [data contract create implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs#L40-L48) for more details. ### Data Contract Update @@ -875,13 +881,15 @@ object](#data-contract-object) in a data contract update state transition consis | Field | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | -| $version | unsigned integer | 32 bits | The platform protocol version (currently `1`) | +| $version | unsigned integer | 32 bits | The state transition format version (currently `0`) | | type | unsigned integer | 8 bits | State transition type (`4` for data contract update) | | dataContract | [data contract object](#data-contract-object) | Varies | Object containing the updated data contract details
**Note:** the data contract's [`version` property](#data-contract-version) must be incremented with each update | +| identityContractNonce | unsigned integer | 64 bits | Identity contract nonce for replay protection | +| userFeeIncrease | unsigned integer | 16 bits | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signaturePublicKeyId | unsigned integer | 32 bits | The `id` of the [identity public key](../protocol-ref/identity.md#identity-publickeys) that signed the state transition (`=> 0`) | | signature | array of bytes | 65 bytes | Signature of state transition data | -See the [data contract update implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs#L33-L45) for more details. +See the [data contract update implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs#L35-L47) for more details. ### Data Contract State Transition Signing diff --git a/docs/protocol-ref/data-trigger.md b/docs/protocol-ref/data-trigger.md index 5f6a5455d..bf8b84795 100644 --- a/docs/protocol-ref/data-trigger.md +++ b/docs/protocol-ref/data-trigger.md @@ -18,14 +18,17 @@ When document state transitions are received, DPP checks if there is a trigger a ### Example -As an example, DPP contains several data triggers for DPNS as defined in the [data triggers factory](https://github.com/dashpay/platform/blob/v0.24.5/packages/rs-dpp/src/data_trigger/get_data_triggers_factory.rs). The `domain` document has added constraints for creation. All DPNS document types have constraints on replacing or deleting: +As an example, DPP contains several data triggers for DPNS as defined in the [data trigger bindings](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/bindings/list/v0/mod.rs). The `domain` document has added constraints for creation, replacement or deletion: | Data Contract | Document | Action(s) | Trigger Description | | ------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | -| DPNS | `domain` | [`CREATE`](https://github.com/dashpay/platform/blob/v0.24.5/packages/rs-dpp/lib/dataTrigger/dpnsTriggers/createDomainDataTrigger.js) | Enforces DNS compatibility, validates provided hashes, and restricts top-level domain (TLD) registration | +| DPNS | `domain` | [`CREATE`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/dpns/v0/mod.rs#L48) | Enforces DNS compatibility, validates provided hashes, and restricts top-level domain (TLD) registration | | ---- | ---- | ---- | ---- | -| DPNS | All Document Types | [`REPLACE`](https://github.com/dashpay/platform/blob/v0.24.5/packages/rs-dpp/src/data_trigger/reject_data_trigger.rs) | Prevents updates to existing documents | -| DPNS | All Document Types | [`DELETE`](https://github.com/dashpay/platform/blob/v0.24.5/packages/rs-dpp/src/data_trigger/reject_data_trigger.rs) | Prevents deletion of existing documents | +| DPNS | `domain` | [`REPLACE`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/reject/v0/mod.rs#L25) | Prevents updates to existing documents | +| DPNS | `domain` | [`DELETE`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/reject/v0/mod.rs#L25) | Prevents deletion of existing documents | +| DPNS | `domain` | [`TRANSFER`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/reject/v0/mod.rs#L25) | Prevents transfer of existing documents | +| DPNS | `domain` | [`PURCHASE`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/reject/v0/mod.rs#L25) | Prevents purchase of existing documents | +| DPNS | `domain` | [`UPDATE_PRICE`](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/data_triggers/triggers/reject/v0/mod.rs#L25) | Prevents updating price of existing documents | **DPNS Trigger Constraints** @@ -34,14 +37,41 @@ The following table details the DPNS constraints applied via data triggers. Thes | Document | Action | Constraint | | ---------- | --------- | ----------------------------------------------------------------------------------------------------------- | | `domain` | `CREATE` | Full domain length \<= 253 characters | -| `domain` | `CREATE` | `normalizedLabel` matches lowercase `label` | +| `domain` | `CREATE` | `normalizedLabel` matches homograph-safe conversion of `label` (lowercase with character substitutions: o→0, l/i→1) | +| `domain` | `CREATE` | `normalizedParentDomainName` matches homograph-safe conversion of `parentDomainName` | | `domain` | `CREATE` | `ownerId` matches `records.dashUniqueIdentityId` or `dashAliasIdentityId` (whichever one is present) | | `domain` | `CREATE` | Only creating a top-level domain with an authorized identity | | `domain` | `CREATE` | Referenced `normalizedParentDomainName` must be an existing parent domain | -| `domain` | `CREATE` | Subdomain registration for non top level domains prevented if `subdomainRules.allowSubdomains` is true | -| `domain` | `CREATE` | Subdomain registration only allowed by the parent domain owner if `subdomainRules.allowSubdomains` is false | +| `domain` | `CREATE` | Subdomain registration for non-top-level domains prevented if the new domain's `subdomainRules.allowSubdomains` is true | +| `domain` | `CREATE` | Subdomain registration only allowed by the parent domain owner if the parent domain's `subdomainRules.allowSubdomains` is false | | `domain` | `CREATE` | Referenced `preorder` document must exist | | `domain` | `REPLACE` | Action not allowed | -| `domain` | `DELETE` | Action not allowed | -| `preorder` | `REPLACE` | Action not allowed | -| `preorder` | `DELETE` | Action not allowed | +| `domain` | `DELETE` | Action not allowed | +| `domain` | `TRANSFER` | Action not allowed | +| `domain` | `PURCHASE` | Action not allowed | +| `domain` | `UPDATE_PRICE` | Action not allowed | + +### Other System Contract Triggers + +In addition to DPNS, the following system contracts have registered data triggers: + +**Dashpay** + +| Document | Action | Trigger Description | +| ---------------- | -------- | ------------------------------------------------ | +| `contactRequest` | `CREATE` | Validates contact request fields and permissions | + +**Masternode Rewards** + +| Document | Action | Trigger Description | +| ------------- | --------- | ----------------------------------------------------------- | +| `rewardShare` | `CREATE` | Rejected unconditionally (masternodes manage reward shares via internal platform operations) | +| `rewardShare` | `REPLACE` | Rejected unconditionally (masternodes manage reward shares via internal platform operations) | +| `rewardShare` | `DELETE` | Rejected unconditionally (masternodes manage reward shares via internal platform operations) | + +**Withdrawals** + +| Document | Action | Trigger Description | +| ------------ | --------- | ------------------- | +| `withdrawal` | `REPLACE` | Rejected by data trigger (withdrawal documents cannot be updated) | +| `withdrawal` | `DELETE` | Rejected unless status is `COMPLETE` | diff --git a/docs/protocol-ref/document.md b/docs/protocol-ref/document.md index 170fcbbcf..6da973652 100644 --- a/docs/protocol-ref/document.md +++ b/docs/protocol-ref/document.md @@ -6,29 +6,29 @@ ## Document Overview -Once a [data contract](./data-contract.md) has been created, data can be stored by submitting documents that comply with the document structure specified in the contract. Each document consists of one or more fields and the indices necessary to support querying. Documents are [created](#document-create-transition), [updated](#document-replace-transition), or [deleted](#document-delete-transition) by sending by submitting them to the platform in a [batch state transition](./state-transition.md#batch). +Once a [data contract](./data-contract.md) has been created, data can be stored by submitting documents that comply with the document structure specified in the contract. Each document consists of one or more fields and the indices necessary to support querying. Documents are [created](#document-create-transition), [replaced](#document-replace-transition), [deleted](#document-delete-transition), [transferred](#document-transfer-transition), [purchased](#document-purchase-transition), or have their [price updated](#document-update-price-transition) by submitting them to the platform in a [batch state transition](./state-transition.md#batch). ## Document State Transition Details -All document transitions include the [document base transition fields](#document-base-transition). Some document transitions (.e.g., [document create](#document-create-transition)) require additional fields to provide their functionality. +All document transitions include the [document base transition fields](#document-base-transition). Some document transitions (e.g., [document create](#document-create-transition)) require additional fields to provide their functionality. ### Document Base Transition -The following fields are included in all document transitions: +The following fields are included in all document transitions. Note that `$action` is present in the JSON wire format as a type discriminator (see [Document Transition Action](#document-transition-action)) but is not a stored field in the base transition structure — it is derived from the transition variant type. | Field | Type | Size | Description| | ----- | ---- | ---- | ---------- | | [$id](#document-id) | array | 32 bytes | The [document ID](#document-id) | -| [$action](#document-transition-action) | array of integers | Varies | [Action](#document-transition-action) the platform should take for the associated document | | $identityContractNonce | unsigned integer | 64 bits | Identity contract nonce | | $type | string | 1-64 characters | Name of a document type found in the data contract associated with the `dataContractId`| -| $dataContractId | array | 32 bytes | Data contract ID [generated](../protocol-ref/data-contract.md#data-contract-id) from the data contract's `ownerId` and `entropy` | +| $dataContractId | array | 32 bytes | Data contract ID [generated](../protocol-ref/data-contract.md#data-contract-id) from the data contract's `ownerId` and `identity nonce` | +| [$tokenPaymentInfo](#token-payment-info) | object | Varies | (Optional, V1+) Token-based fee payment information for this transition | -Each document transition must comply with the [document base transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_base_transition/v0/mod.rs#L43-L61). +Each document transition must comply with the [document base transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_base_transition/v1/mod.rs#L38-L56). #### Document id -The document `$id` is created by double sha256 hashing the document's `dataContractId`, `ownerId`, `type`, and `entropy` as shown in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/document/generate_document_id.rs). +The document `$id` is created by double sha256 hashing the document's `dataContractId`, `ownerId`, `type`, and `entropy` as shown in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/document/generate_document_id.rs). ```rust // From the Rust reference implementation (rs-dpp) @@ -50,9 +50,40 @@ pub fn generate_document_id_v0( } ``` +#### Token Payment Info + +When a document type requires token payment (configured via [`tokenCost`](./data-contract-document.md#token-costs) in the data contract), the `$tokenPaymentInfo` object specifies which token to use and the cost limits the client is willing to accept. The object is defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/token_payment_info/v0/mod.rs#L36-L56). + +| Field | Type | Size | Description | +| - | - | - | - | +| paymentTokenContractId | array | 32 bytes | (Optional) Identifier of the contract containing the payment token. Defaults to the current contract if omitted. | +| tokenContractPosition | unsigned integer | 16 bits | Position of the token within the contract to use for payment | +| minimumTokenCost | unsigned integer | 64 bits | (Optional) Minimum acceptable token cost. Not typically set by clients. | +| maximumTokenCost | unsigned integer | 64 bits | (Optional) Maximum token cost the client is willing to pay. Recommended when the contract allows prices to be changed, to protect against unexpected cost increases. | +| gasFeesPaidBy | integer | 8 bits | Who pays the gas fees for the operation:
`0` - Document owner (default)
`1` - Contract owner
`2` - Prefer contract owner (falls back to document owner if insufficient) | + +::: {note} +The `gasFeesPaidBy` value must match what the data contract's `tokenCost` configuration allows for the operation type. +::: + +#### Entropy Generation + +Dash Platform uses the following entropy generator found in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/util/entropy_generator.rs#L9-L14): + +```rust +// From the Rust reference implementation (rs-dpp) +// entropy_generator.rs +fn generate(&self) -> anyhow::Result<[u8; 32]> { + let mut buffer = [0u8; 32]; + getrandom::getrandom(&mut buffer) + .map_err(|e| anyhow::anyhow!(format!("generating entropy failed: {}", e)))?; + Ok(buffer) +} +``` + #### Document Transition Action -Document transition actions indicate what operation platform should perform with the provided transition data. Documents provide CRUD functionality, ownership transfer, and NFT features as [defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs#L6-L14). +Document transition actions indicate what operation platform should perform with the provided transition data. Documents provide CRUD functionality, ownership transfer, and NFT features as [defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs#L6-L14). | Action | Name | Description | | :-: | - | - | @@ -62,6 +93,7 @@ Document transition actions indicate what operation platform should perform with | 3 | [Transfer](#document-transfer-transition) | Transfer the referenced document to a new owner | | 4 | [Purchase](#document-purchase-transition) | Purchase the referenced document | | 5 | [Update price](#document-update-price-transition) | Update the price for the document | +| 6 | IgnoreWhileBumpingRevision | Internal action type used to bypass revision bump | ### Document Create Transition @@ -69,11 +101,11 @@ The document create transition extends the [base transition](#document-base-tran | Field | Type | Size | Description | | - | - | - | - | -| $entropy | array | 32 bytes | Entropy used in creating the [document ID](#document-id). Generated as [shown here](../protocol-ref/state-transition.md#entropy-generation). | +| $entropy | array | 32 bytes | Entropy used in creating the [document ID](#document-id). Generated as [shown here](#entropy-generation). | | data | | Varies | Document data being submitted. | | $prefundedVotingBalance | | Varies | (Optional) Prefunded amount of credits reserved for unique index conflict resolution voting (e.g., [premium DPNS name](../explanations/dpns.md#conflict-resolution)).| -Each document create transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_create_transition/v0/mod.rs#L58-L82) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). +Each document create transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_create_transition/v0/mod.rs#L57-L78) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). ::: {note} The document create transition data field must include all [required document properties](./data-contract-document.md#required-properties) specified in the data contract. @@ -87,6 +119,7 @@ The following example document create transition and subsequent table demonstrat "$dataContractId": "5wpZAEWndYcTeuwZpkmSa8s49cHXU5q2DhdibesxFSu8", "$id": "6oCKUeLVgjr7VZCyn1LdGbrepqKLmoabaff5WQqyTKYP", "$type": "note", + "$identityContractNonce": 1, "$entropy": "yfo6LnZfJ5koT2YUwtd8PdJa8SXzfQMVDz", "message": "Tutorial Test @ Mon, 27 Apr 2020 20:23:35 GMT" } @@ -94,10 +127,10 @@ The following example document create transition and subsequent table demonstrat | Field | Required By | | - | - | -| $action | Document [base transition](#document-base-transition) | | $dataContractId | Document [base transition](#document-base-transition) | | $id | Document [base transition](#document-base-transition) | | $type | Document [base transition](#document-base-transition) | +| $identityContractNonce | Document [base transition](#document-base-transition) | | $entropy | Document [create transition](#document-create-transition) | | message | Data Contract (the `message` document defined in the referenced data contract -`5wpZAEWndYcTeuwZpkmSa8s49cHXU5q2DhdibesxFSu8`) | @@ -110,13 +143,13 @@ The document replace transition extends the [base transition](#document-base-tra | $revision | unsigned integer | 64 bits | Document revision (=> 1) | | data | | Varies | Document data being updated | -Each document replace transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_replace_transition/v0/mod.rs#L35-L45) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). +Each document replace transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_replace_transition/v0/mod.rs#L35-L42) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). ::: {note} The document replace transition data field must include all [required document properties](./data-contract-document.md#required-properties) specified in the data contract. ::: -The following example document create transition and subsequent table demonstrate how the document transition base, document create transition, and data contract document definitions are assembled into a complete transition for inclusion in a [state transition](#document-overview): +The following example document replace transition and subsequent table demonstrate how the document transition base, document replace transition, and data contract document definitions are assembled into a complete transition for inclusion in a [state transition](#document-overview): ```json { @@ -124,6 +157,7 @@ The following example document create transition and subsequent table demonstrat "$dataContractId": "5wpZAEWndYcTeuwZpkmSa8s49cHXU5q2DhdibesxFSu8", "$id": "6oCKUeLVgjr7VZCyn1LdGbrepqKLmoabaff5WQqyTKYP", "$type": "note", + "$identityContractNonce": 1, "$revision": 1, "message": "Tutorial Test @ Mon, 27 Apr 2020 20:23:35 GMT" } @@ -131,16 +165,16 @@ The following example document create transition and subsequent table demonstrat | Field | Required By | | - | - | -| $action | Document [base transition](#document-base-transition) | | $dataContractId | Document [base transition](#document-base-transition) | | $id | Document [base transition](#document-base-transition) | | $type | Document [base transition](#document-base-transition) | +| $identityContractNonce | Document [base transition](#document-base-transition) | | $revision | Document revision | | message | Data Contract (the `message` document defined in the referenced data contract -`5wpZAEWndYcTeuwZpkmSa8s49cHXU5q2DhdibesxFSu8`) | ### Document Delete Transition -The document delete transition only requires the fields found in the [base document transition](#document-base-transition). See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_delete_transition/v0/mod.rs#L21-L24) for details. +The document delete transition only requires the fields found in the [base document transition](#document-base-transition). See the [implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_delete_transition/v0/mod.rs#L21-L24) for details. ### Document Transfer Transition @@ -151,7 +185,7 @@ The document transfer transition allows a document owner to transfer document ow | $revision | unsigned integer | 64 bits | Document revision (=> 1) | | recipientOwnerId | array of bytes | 32 bytes | Identifier of the recipient (new owner). See the [NFT page](../explanations/nft.md#transfer-and-trade) for more details. | -Each document transfer transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transfer_transition/v0/mod.rs#L33-L46) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). +Each document transfer transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transfer_transition/v0/mod.rs#L33-L40) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). ### Document Purchase Transition @@ -162,7 +196,7 @@ The document purchase transition allows an identity to purchase a document previ | $revision | unsigned integer | 64 bits | Document revision (=> 1) | | price | unsigned integer | 64 bits | Number of credits being offered for the purchase. See the [NFT page](../explanations/nft.md#transfer-and-trade) for more details. | -Each document purchase transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_purchase_transition/v0/mod.rs#L23-L33) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). +Each document purchase transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_purchase_transition/v0/mod.rs#L23-L30) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). ### Document Update Price Transition @@ -173,19 +207,18 @@ The document update price transition allows a document owner to set or update th | $revision | unsigned integer | 64 bits | Document revision (=> 1) | | $price | unsigned integer | 64 bits | Updated price for the document. Can only be set by the current document owner. See the [NFT page](../explanations/nft.md#transfer-and-trade) for more details. | -Each document update price transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_update_price_transition/v0/mod.rs#L27-L40) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). +Each document update price transition must comply with the structure defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_update_price_transition/v0/mod.rs#L27-L34) (in addition to the [document base transition](#document-base-transition) that is required for all document transitions). ## Document Object -The document object represents the data provided by the platform in response to a query. Responses consist of an array of these objects containing the following fields as defined in the Rust reference client ([rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/document/v0/mod.rs#L35-L105)): +The document object represents the data provided by the platform in response to a query. Responses consist of an array of these objects containing the following fields as defined in the Rust reference client ([rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/document/v0/mod.rs#L39-L124)): | Property | Type | Required | Description | | - | - | - | - | -| protocolVersion | integer | Yes | The platform protocol version (currently `1`) | | $id | array | Yes | The [document ID](#document-id) (32 bytes)| | $type | string | Yes | Document type defined in the referenced contract (1-64 characters) | | $revision | unsigned integer (64 bits) | No | Document revision (=>1) if the document is mutable | -| $dataContractId | array | Yes | Data contract ID [generated](../protocol-ref/data-contract.md#data-contract-id) from the data contract's `ownerId` and `entropy` (32 bytes) | +| $dataContractId | array | Yes | Data contract ID [generated](../protocol-ref/data-contract.md#data-contract-id) from the data contract's `ownerId` and `identity nonce` (32 bytes) | | $ownerId | array | Yes | [Identity](../protocol-ref/identity.md) of the user submitting the document (32 bytes) | | $createdAt | unsigned integer (64 bits) | No | Time (in milliseconds) at document creation, if required by the document type schema | | $updatedAt | unsigned integer (64 bits) | No | Last document update time in milliseconds, if required by the document type schema | @@ -193,15 +226,15 @@ The document object represents the data provided by the platform in response to | $createdAt
BlockHeight | unsigned integer (64 bits) | No | Block height at document creation, if required by the schema | | $updatedAt
BlockHeight | unsigned integer (64 bits) | No | Block height at the document's last update, if required by the schema | | $transferredAt
BlockHeight | unsigned integer (64 bits) | No | Block height when document was last transferred, if required by the schema | -| $createdAt
CoreBlockHeight | unsigned integer (64 bits) | No | Core block height at document creation, if required by the schema | -| $updatedAt
CoreBlockHeight | unsigned integer (64 bits) | No |Core block height at the document's last update, if required by the schema | -| $transferredAt
CoreBlockHeight | unsigned integer (64 bits) | No |Core block height when document was last transferred, if required by the schema | +| $createdAt
CoreBlockHeight | unsigned integer (32 bits) | No | Core block height at document creation, if required by the schema | +| $updatedAt
CoreBlockHeight | unsigned integer (32 bits) | No |Core block height at the document's last update, if required by the schema | +| $transferredAt
CoreBlockHeight | unsigned integer (32 bits) | No |Core block height when document was last transferred, if required by the schema | +| $creatorId | array | No | Identity of the document creator (32 bytes), if required by the document type schema | ### Example Document Object ```json { - "$protocolVersion": 1, "$id": "4mWnFcDDzCpeLExJqE8v7pfN4EERC8NE2xn4hw3VKriU", "$type": "note", "$dataContractId": "63au7XVDt8aHtPrsYKoHx2bnRTSenwH62pDN1BQ5n5m9", diff --git a/docs/protocol-ref/errors.md b/docs/protocol-ref/errors.md index 2f7d75851..11c238dd8 100644 --- a/docs/protocol-ref/errors.md +++ b/docs/protocol-ref/errors.md @@ -6,7 +6,7 @@ ## Platform Error Codes -Dash Platform Protocol implements a comprehensive set of consensus error codes. Refer to the tables below for a list of the codes as specified in [code.rs](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/errors/consensus/codes.rs) of the consensus source code. +Dash Platform Protocol implements a comprehensive set of consensus error codes. Refer to the tables below for a list of the codes as specified in [codes.rs](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/errors/consensus/codes.rs) of the consensus source code. Platform error codes are organized into four categories. Each category may be further divided into sub-categories. The four categories and their error code ranges are: @@ -105,7 +105,29 @@ Code range: 10200-10349 | 10250 | DataContractTokenConfigurationUpdateError | | | 10251 | InvalidTokenBaseSupplyError | | | 10252 | NonContiguousContractGroupPositionsError | | -| 10253 | NonContiguousContractTokenPositionsError | | +| 10253 | NonContiguousContractTokenPositionsError | | +| 10254 | InvalidTokenDistributionFunctionDivideByZeroError | | +| 10255 | InvalidTokenDistributionFunctionInvalidParameterError | | +| 10256 | InvalidTokenDistributionFunctionInvalidParameterTupleError | | +| 10257 | InvalidTokenDistributionFunctionIncoherenceError | | +| 10258 | MissingDefaultLocalizationError | | +| 10259 | UnknownGasFeesPaidByError | | +| 10260 | UnknownDocumentActionTokenEffectError | | +| 10261 | TokenPaymentByBurningOnlyAllowedOnInternalTokenError | | +| 10262 | TooManyKeywordsError | | +| 10263 | DuplicateKeywordsError | | +| 10264 | InvalidDescriptionLengthError | | +| 10265 | NewTokensDestinationIdentityOptionRequiredError | | +| 10266 | InvalidTokenNameCharacterError | | +| 10267 | InvalidTokenNameLengthError | | +| 10268 | InvalidTokenLanguageCodeError | | +| 10269 | InvalidKeywordCharacterError | | +| 10270 | InvalidKeywordLengthError | | +| 10271 | DecimalsOverLimitError | | +| 10272 | InvalidTokenDistributionBlockIntervalTooShortError | | +| 10273 | InvalidTokenDistributionTimeIntervalTooShortError | | +| 10274 | InvalidTokenDistributionTimeIntervalNotMinuteAlignedError | | +| 10275 | RedundantDocumentPaidForByTokenWithContractId | | ### Group @@ -120,6 +142,9 @@ Code range: 10350-10399 | 10354 |GroupExceedsMaxMembersError | | | 10355 |GroupMemberHasPowerOfZeroError | | | 10356 |GroupMemberHasPowerOverLimitError | | +| 10357 |MainGroupIsNotDefinedError | | +| 10358 |GroupRequiredPowerIsInvalidError | | +| 10359 |GroupHasTooFewMembersError | | ### Document @@ -160,6 +185,10 @@ Code range: 10450-10499 | 10454 | DestinationIdentityForTokenMintingNotSetError | | | 10455 | ChoosingTokenMintRecipientNotAllowedError | | | 10456 | TokenTransferToOurselfError | | +| 10457 | InvalidTokenConfigUpdateNoChangeError | | +| 10458 | InvalidTokenAmountError | | +| 10459 | InvalidTokenNoteTooBigError | | +| 10460 | TokenNoteOnlyAllowedWhenProposerError | | ### Identity @@ -188,9 +217,9 @@ Code range: 10500-10599 | 10518 | TooManyMasterPublicKeyError | | | 10519 | InvalidIdentityPublicKeySecurityLevelError | | | 10520 | InvalidIdentityKeySignatureError | | -| 10521 | InvalidIdentityCreditWithdrawalTransitionOutputScriptError | | -| 10522 | InvalidIdentityCreditWithdrawalTransitionCoreFeeError | | -| 10523 | NotImplementedIdentityCreditWithdrawalTransitionPoolingError | | +| 10521 | InvalidCreditWithdrawalTransitionOutputScriptError | | +| 10522 | InvalidCreditWithdrawalTransitionCoreFeeError | | +| 10523 | NotImplementedCreditWithdrawalTransitionPoolingError | | | 10524 | InvalidIdentityCreditTransferAmountError | | | 10525 | InvalidIdentityCreditWithdrawalTransitionAmountError | | | 10526 | InvalidIdentityUpdateTransitionEmptyError | | @@ -200,6 +229,7 @@ Code range: 10500-10599 | 10530 | IdentityAssetLockTransactionOutPointNotEnoughBalanceError | | | 10531 | IdentityAssetLockStateTransitionReplayError | | | 10532 | WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError | | +| 10533 | InvalidKeyPurposeForContractBoundsError | | ### State Transition @@ -210,6 +240,7 @@ Code range: 10600-10699 | 10600 | InvalidStateTransitionTypeError | | | 10601 | MissingStateTransitionTypeError | | | 10602 | StateTransitionMaxSizeExceededError | | +| 10603 | StateTransitionNotActiveError | | ### General @@ -219,6 +250,39 @@ Code range: 10700-10799 | ----- | ------------------- | ------- | | 10700 | OverflowError | | +### Address + +Code range: 10800-10899 + +| Code | Error Description | Comment | +| :---: | ---------------------------------------------- | ------- | +| 10800 | TransitionOverMaxInputsError | | +| 10801 | TransitionOverMaxOutputsError | | +| 10802 | InputWitnessCountMismatchError | | +| 10803 | TransitionNoInputsError | | +| 10804 | TransitionNoOutputsError | | +| 10805 | FeeStrategyEmptyError | | +| 10806 | FeeStrategyDuplicateError | | +| 10807 | FeeStrategyIndexOutOfBoundsError | | +| 10808 | FeeStrategyTooManyStepsError | | +| 10809 | InputBelowMinimumError | | +| 10810 | OutputBelowMinimumError | | +| 10811 | InputOutputBalanceMismatchError | | +| 10812 | OutputsNotGreaterThanInputsError | | +| 10813 | WithdrawalBalanceMismatchError | | +| 10814 | InsufficientFundingAmountError | | +| 10815 | InputsNotLessThanOutputsError | | +| 10816 | OutputAddressAlsoInputError | | +| 10817 | InvalidRemainderOutputCountError | | +| 10818 | WithdrawalBelowMinAmountError | | +| 10819 | ShieldedNoActionsError | | +| 10820 | ShieldedEmptyProofError | | +| 10821 | ShieldedZeroAnchorError | | +| 10822 | ShieldedInvalidValueBalanceError | | +| 10823 | *(reserved/unassigned)* | | +| 10824 | *(reserved/unassigned)* | | +| 10825 | ShieldedTooManyActionsError | | + ## Signature Errors | Code | Error Description | Comment | @@ -235,6 +299,7 @@ Code range: 10700-10799 | 20009 | BasicECDSAError | | | 20010 | BasicBLSError | | | 20011 | InvalidSignaturePublicKeyPurposeError | | +| 20012 | UncompressedPublicKeyNotAllowedError | | ## Fee Errors @@ -255,6 +320,11 @@ Code range: 40000-40099 | 40002 | DataContractConfigUpdateError | | | 40003 | DataContractUpdatePermissionError | | | 40004 | DataContractUpdateActionNotAllowedError | | +| 40005 | PreProgrammedDistributionTimestampInPastError | | +| 40006 | IdentityInTokenConfigurationNotFoundError | | +| 40007 | IdentityMemberOfGroupNotFoundError | | +| 40008 | DataContractNotFoundError | | +| 40009 | InvalidTokenPositionStateError | | ### Document State @@ -277,25 +347,38 @@ Code range: 40100-40149 | 40112 | DocumentContestIdentityAlreadyContestantError | | | 40113 | DocumentContestDocumentWithSameIdAlreadyPresentError | | | 40114 | DocumentContestNotPaidForError | | +| 40115 | RequiredTokenPaymentInfoNotSetError | | +| 40116 | IdentityHasNotAgreedToPayRequiredTokenAmountError | | +| 40117 | IdentityTryingToPayWithWrongTokenError | | ### Token State -Code range: 40150-40199 - -| Code | Error Description | Comment | -| :---: | ------------------------------------------------- | ------- | -| 40150 | IdentityDoesNotHaveEnoughTokenBalanceError | | -| 40151 | UnauthorizedTokenActionError | | -| 40152 | IdentityTokenAccountFrozenError | | -| 40153 | IdentityTokenAccountNotFrozenError | | -| 40154 | TokenSettingMaxSupplyToLessThanCurrentSupplyError | | -| 40155 | TokenMintPastMaxSupplyError | | -| 40156 | NewTokensDestinationIdentityDoesNotExistError | | -| 40157 | NewAuthorizedActionTakerIdentityDoesNotExistError | | -| 40158 | NewAuthorizedActionTakerGroupDoesNotExistError | | -| 40159 | NewAuthorizedActionTakerMainGroupNotSetError | | -| 40160 | InvalidGroupPositionError | | -| 40161 | TokenIsPausedError | | +Code range: 40700-40799 + +| Code | Error Description | Comment | +| :---: | ------------------------------------------------------ | ------- | +| 40700 | IdentityDoesNotHaveEnoughTokenBalanceError | | +| 40701 | UnauthorizedTokenActionError | | +| 40702 | IdentityTokenAccountFrozenError | | +| 40703 | IdentityTokenAccountNotFrozenError | | +| 40704 | TokenSettingMaxSupplyToLessThanCurrentSupplyError | | +| 40705 | TokenMintPastMaxSupplyError | | +| 40706 | NewTokensDestinationIdentityDoesNotExistError | | +| 40707 | NewAuthorizedActionTakerIdentityDoesNotExistError | | +| 40708 | NewAuthorizedActionTakerGroupDoesNotExistError | | +| 40709 | NewAuthorizedActionTakerMainGroupNotSetError | | +| 40710 | InvalidGroupPositionError | | +| 40711 | TokenIsPausedError | | +| 40712 | IdentityTokenAccountAlreadyFrozenError | | +| 40713 | TokenAlreadyPausedError | | +| 40714 | TokenNotPausedError | | +| 40715 | InvalidTokenClaimPropertyMismatch | | +| 40716 | InvalidTokenClaimNoCurrentRewards | | +| 40717 | InvalidTokenClaimWrongClaimant | | +| 40718 | TokenTransferRecipientIdentityNotExistError | | +| 40719 | TokenDirectPurchaseUserPriceTooLow | | +| 40720 | TokenAmountUnderMinimumSaleAmount | | +| 40721 | TokenNotForDirectSale | | ### Identity State @@ -319,6 +402,7 @@ Code range: 40200-40299 | 40214 | MissingTransferKeyError | | | 40215 | NoTransferKeyForCoreWithdrawalAvailableError | | | 40216 | RecipientIdentityDoesNotExistError | | +| 40217 | IdentityToFreezeDoesNotExistError | | ### Voting State @@ -345,7 +429,7 @@ Code range: 40400-40499 ### Data Trigger State -Code range: 40500-40799 +Code range: 40500-40599 | Code | Error Description | Comment | | :---: | ----------------------------- | ------- | @@ -353,6 +437,17 @@ Code range: 40500-40799 | 40501 | DataTriggerExecutionError | | | 40502 | DataTriggerInvalidResultError | | +### Address State + +Code range: 40600-40699 + +| Code | Error Description | Comment | +| :---: | ------------------------------- | ------- | +| 40600 | AddressDoesNotExistError | | +| 40601 | AddressNotEnoughFundsError | | +| 40602 | AddressesNotEnoughFundsError | | +| 40603 | AddressInvalidNonceError | | + ### Group State Code range: 40800-40899 @@ -363,3 +458,16 @@ Code range: 40800-40899 | 40801 | GroupActionDoesNotExistError | | | 40802 | GroupActionAlreadyCompletedError | | | 40803 | GroupActionAlreadySignedByIdentityError | | +| 40804 | ModificationOfGroupActionMainParametersNotPermittedError | | + +### Shielded State + +Code range: 40900-40999 + +| Code | Error Description | Comment | +| :---: | ------------------------------- | ------- | +| 40900 | InvalidAnchorError | | +| 40901 | NullifierAlreadySpentError | | +| 40902 | InvalidShieldedProofError | | +| 40903 | InsufficientPoolNotesError | | +| 40904 | InsufficientShieldedFeeError | | diff --git a/docs/protocol-ref/identity.md b/docs/protocol-ref/identity.md index 9c4d5c080..08ffa2ea1 100644 --- a/docs/protocol-ref/identity.md +++ b/docs/protocol-ref/identity.md @@ -12,19 +12,17 @@ Identities consist of multiple objects that are described in the following secti | Field | Type | Description | | --------------- | -------------- | ------------------------------------------- | -| $version | integer | The protocol version | | [id](#identity-id) | array of bytes | The identity id (32 bytes) | | [publicKeys](#identity-publickeys) | array of keys | Public key(s) associated with the identity | -| [balance](#identity-balance) | integer | Credit balance associated with the identity | +| [balance](#identity-balance) | unsigned integer (64-bit) | Credit balance associated with the identity | | revision | integer | Identity update revision | -See the [identity implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/v0/mod.rs#L34-L43) for more details. +See the [identity implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/v0/mod.rs#L36-L45) for more details. **Example Identity** ```json { - "protocolVersion":1, "id":"6YfP6tT9AK8HPVXMK7CQrhpc8VMg7frjEnXinSPvUmZC", "publicKeys":[ { @@ -48,17 +46,17 @@ The identity `id` is a unique identifier created from the double sha256 hash of `id = base58(sha256(sha256()))` :::{note} -The identity `id` uses the Dash Platform specific `application/x.dash.dpp.identifier` content media type. For additional information, please refer to the [js-dpp PR 252](https://github.com/dashevo/js-dpp/pull/252) that introduced it and [identifier.rs](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-platform-value/src/types/identifier.rs). +The identity `id` uses the Dash Platform specific `application/x.dash.dpp.identifier` content media type. For additional information, please refer to the [js-dpp PR 252](https://github.com/dashevo/js-dpp/pull/252) that introduced it and [identifier.rs](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-value/src/types/identifier.rs). ::: -See rs-dpp for examples of using [InstantSend](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs#L29-L36) or [ChainLocks](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs#L45-L51) to create the identity id. +See rs-dpp for examples of using [InstantSend](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs#L146) or [ChainLocks](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs#L54) to create the identity id. ### Identity publicKeys The identity `publicKeys` array stores information regarding each public key associated with the identity. Multiple identities may use the same public key. :::{note} -Each identity must have at least two public keys: a primary key ([security level](#public-key-securitylevel) `0`) that is only used when updating the identity and an additional one ([security level](#public-key-securitylevel) `2`) used to sign state transitions. The maximum number of keys is 15000 as [defined by rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/fields.rs#L7). +Each identity must have exactly one master key ([security level](#public-key-securitylevel) `0`) used for updating the identity. Having an additional key ([security level](#public-key-securitylevel) `1` or `2`) for signing state transitions is strongly recommended but not enforced by the protocol. The maximum number of keys is 15000 as [defined by rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/fields.rs#L7). ::: Each item in the `publicKeys` array consists of an object containing: @@ -72,9 +70,10 @@ Each item in the `publicKeys` array consists of an object containing: | [securityLevel](#public-key-securitylevel) | integer | Public key security level (`0` - Master, `1` - Critical, `2` - High, `3` - Medium) | | [readonly](#public-key-readonly) | boolean | Identity public key can't be modified with `readOnly` set to `true`. This can’t be changed after adding a key. | | [disabledAt](#public-key-disabledat) | integer | Timestamp indicating that the key was disabled at a specified time | +| contractBounds | object (optional) | Restricts this key to a specific data contract or document type context | | signature | array of bytes | Signature of the signable identity create or topup state transition by the private key associated with this public key | -See the [public key implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/identity_public_key/v0/mod.rs#L39-L50) for more details. +See the [public key implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/identity_public_key/v0/mod.rs#L42-L53) for more details. #### Public Key `id` @@ -82,7 +81,7 @@ Each public key in an identity's `publicKeys` array must be assigned a unique in #### Public Key `type` -The `type` field indicates the algorithm used to derive the key. Available key types [defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/identity_public_key/key_type.rs#L56-L62) include: +The `type` field indicates the algorithm used to derive the key. Available key types [defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/identity_public_key/key_type.rs#L46-L53) include: | Type | Size (bytes) | Description | | :--: | :----------: | ----------- | @@ -98,7 +97,7 @@ The `data` field contains the compressed public key. #### Public Key `purpose` -The `purpose` field describes which operations are supported by the key. Please refer to [DIP11 - Identities](https://github.com/dashpay/dips/blob/master/dip-0011.md#keys) for additional information regarding this. Keys for some purposes must meet certain the security level criteria [defined by rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/methods/validate_identity_public_keys_structure/v0/mod.rs#L22-L37) as detailed below: +The `purpose` field describes which operations are supported by the key. Please refer to [DIP11 - Identities](https://github.com/dashpay/dips/blob/master/dip-0011.md#keys) for additional information regarding this. Keys for some purposes must meet certain the security level criteria [defined by rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/methods/validate_identity_public_keys_structure/v0/mod.rs#L22-L37) as detailed below: | Type | Description | Allowed Security Level(s) | | :--: | -------------- | ------------------------- | @@ -107,6 +106,15 @@ The `purpose` field describes which operations are supported by the key. Please | `2` | Decryption | Medium | | `3` | Transfer | Critical | +The system automatically creates the following key types for masternodes and evonodes. They cannot +be created or updated manually: + +| Type | Description | Allowed Security Level | +| :--: | -------------- | ---------------------- | +| `4` | System | Critical | +| `5` | Voting | High | +| `6` | Owner | Critical | + #### Public Key `securityLevel` The `securityLevel` field indicates how securely the key should be stored by clients. Please refer to [DIP11 - Identities](https://github.com/dashpay/dips/blob/master/dip-0011.md#keys) for additional information regarding this. @@ -131,25 +139,73 @@ The `disabledAt` field indicates that the key has been disabled. Its value equal Each identity has a balance of credits established by an [asset lock transaction](inv:user:std#ref-txs-assetlocktx) on the Core chain. This credit balance is used to pay the fees associated with state transitions. +## Identity Constants and Limits + +The following constants and limits apply to identities: + +| Constant | Value | Description | +|----------|-------|-------------| +| `IDENTITY_MAX_KEYS` | 15,000 | Maximum number of public keys per identity | +| `MAX_CREDITS` | 9,223,372,036,854,775,807 | Maximum credit balance (i64::MAX) | +| `max_public_keys_in_creation` | 6 | Maximum keys when creating an identity | +| `min_identity_funding_amount` | 200,000 credits | Minimum funding for address-based identity create and top-up transitions | +| `identity_create_base_cost` | 2,000,000 credits | Base fee for identity creation | +| `identity_key_in_creation_cost` | 6,500,000 credits | Fee per key during creation | +| `identity_topup_base_cost` | 500,000 credits | Base fee for identity top-up | + +### Identity Creation Cost Calculation + +The total cost to create an identity is: + +```text +Total = identity_create_base_cost + (number_of_keys × identity_key_in_creation_cost) +``` + +**Examples:** + +- 1 key: 2,000,000 + 6,500,000 = **8,500,000 credits** (0.000085 Dash) +- 2 keys: 2,000,000 + 13,000,000 = **15,000,000 credits** (0.00015 Dash) +- 6 keys: 2,000,000 + 39,000,000 = **41,000,000 credits** (0.00041 Dash) + +### Minimum Funding Requirements + +| Operation | Required Balance (credits) | Required Balance (Dash) | +|-----------|---------------------------|------------------------| +| Identity create (asset lock) | 200,000,000 | 0.002 | +| Identity top-up (asset lock) | 50,000,000 | 0.0005 | +| Address funding | 50,000,000 | 0.0005 | + +:::{seealso} +For all protocol constants, see [Protocol Constants](protocol-constants.md). +::: + ## Identity State Transition Details There are five identity-related state transitions: [identity create](#identity-create), [identity topup](#identity-topup), [identity update](#identity-update), [identity credit transfer](#identity-credit-transfer), and [identity credit withdrawal](#identity-credit-withdrawal). Details are provided in this section including information about [asset locking](#asset-lock) and [signing](#identity-state-transition-signing) required for these state transitions. +:::{note} +Protocol Version 11 introduced additional address-based identity operations. See [Address-Based State Transitions](address-system.md) for: + +- Identity Credit Transfer to Addresses (type 9) +- Identity Create from Addresses (type 10) +- Identity Top-Up from Addresses (type 11) +::: + ### Identity Create Identities are created on the platform by submitting the identity information in an identity create state transition. | Field | Type | Description | | --------------- | -------------- | ----------- | -| $version | integer | The protocol version (currently `1`) | +| $version | integer | The state transition format version (currently `0`) | | type | integer | State transition type (`2` for identity create) | | publicKeys | array of [keys](#identity-publickeys) | Public key(s) associated with the identity | | assetLockProof | [proof object](#asset-lock) | Asset lock proof object proving the [asset lock transaction](inv:user:std#ref-txs-assetlocktx) exists on the Core chain and is locked | | userFeeIncrease | integer | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signature | array of bytes | Signature of state transition data by the single-use key from the asset lock (65 bytes) | -| identityId | array of bytes | An [identity id](#identity-id) for the identity being created (32 bytes) | +| identityId | array of bytes | An [identity id](#identity-id) for the identity being created (32 bytes). Computed from the asset lock proof outpoint and excluded from the serialized payload. | -See the [identity create implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs#L44-L55) for more details. +See the [identity create implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs#L47-L58) for more details. ### Identity TopUp @@ -157,14 +213,14 @@ Identity credit balances are increased by submitting the topup information in an | Field | Type | Description | | --------------- | -------------- | ----------- | -| $version | integer | The protocol version (currently `1`) | +| $version | integer | The state transition format version (currently `0`) | | type | integer | State transition type (`3` for identity topup) | | assetLockProof | [proof object](#asset-lock) | Asset lock proof object proving the layer 1 locking transaction exists and is locked | | identityId | array of bytes | An [identity id](#identity-id) for the identity receiving the topup (can be any identity) (32 bytes) | | userFeeIncrease | integer | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signature | array of bytes | Signature of state transition data by the single-use key from the asset lock (65 bytes) | -See the [identity topup implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs#L40-L47) for more details. +See the [identity topup implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs#L43-L50) for more details. ### Identity Update @@ -172,18 +228,18 @@ Identities are updated on the platform by submitting the identity information in | Field | Type | Description | | -------------------- | -------------------- | ----------- | -| $version | integer | The protocol version (currently `1`) | +| $version | integer | The state transition format version (currently `0`) | | type | integer | State transition type (`5` for identity update) | | identityId | array of bytes | The [identity id](#identity-id) (32 bytes) | | revision | integer | Identity update revision | -| nonce | integer | Identity nonce for this transition to prevent replay attacks | -| addPublicKeys | array of public [keys](#identity-publickeys) | (Optional) Array of up to 10 new public keys to add to the identity. Required if adding keys. | +| nonce | unsigned integer (64 bits) | Identity nonce for this transition to prevent replay attacks | +| addPublicKeys | array of public [keys](#identity-publickeys) | (Optional) Array of up to 6 new public keys to add to the identity. Required if adding keys. | | disablePublicKeys | array of integers | (Optional) Array of up to 10 existing identity public key ID(s) to disable for the identity. Required if disabling keys. | | userFeeIncrease | integer | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signaturePublicKeyId | integer | The ID of public key used to sign the state transition | | signature | array of bytes | Signature of state transition data (65 bytes) | -See the [identity update implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs#L40-L69) for more details. +See the [identity update implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs#L43-L72) for more details. ### Identity Credit Transfer @@ -191,17 +247,17 @@ Identities can transfer credits on the platform by submitting an identity credit | Field | Type | Description | | -------------------- | -------------- | ----------- | -| $version | integer | The protocol version (currently `1`) | -| type | integer | State transition type (`6` for identity credit transfer) | +| $version | integer | The state transition format version (currently `0`) | +| type | integer | State transition type (`7` for identity credit transfer) | | identityId | array of bytes | The [identity id](#identity-id) of the sender (32 bytes) | | recipientId | array of bytes | The [identity id](#identity-id) of the recipient (32 bytes) | | amount | integer | The credit amount to transfer | -| nonce | integer | Identity nonce for this transition to prevent replay attacks | +| nonce | unsigned integer (64 bits) | Identity nonce for this transition to prevent replay attacks | | userFeeIncrease | integer | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signaturePublicKeyId | integer | The ID of public key used to sign the state transition | | signature | array of bytes | Signature of state transition data (65 bytes) | -See the [identity credit transfer implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L39-L50) for more details. +See the [identity credit transfer implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L42-L53) for more details. ### Identity Credit Withdrawal @@ -210,28 +266,28 @@ Credits can be withdrawn from an identity to an external Core wallet using an id | Field | Type | Description | | -------------------- | -------------- | ----------- | | $version | integer | The protocol version (currently `1`) | -| type | integer | State transition type (`7` for identity credit withdrawal) | +| type | integer | State transition type (`6` for identity credit withdrawal) | | identityId | array of bytes | An [identity id](#identity-id) (32 bytes) | | amount | integer | The amount of credits to withdraw (64 bits) | | coreFeePerByte | integer | Fee per byte for the transaction on Core (32 bits) | | pooling | integer | Pooling mode for transaction batching | | outputScript | array of bytes | (Optional) The output script for receiving the withdrawal (if not set, defaults to Core address) | -| nonce | integer | Identity nonce for this transition to prevent replay attacks | +| nonce | unsigned integer (64 bits) | Identity nonce for this transition to prevent replay attacks | | userFeeIncrease | integer | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signaturePublicKeyId | integer | The ID of public key used to sign the state transition | | signature | array of bytes | Signature of state transition data (65 bytes) | -See the [identity credit withdrawal implementation in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L32-L45) for more details. +See the [identity credit withdrawal implementation in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L35-L48) for more details. ### Asset Lock The [identity create](#identity-create) and [identity topup](#identity-topup) state transitions both include an asset lock proof object. This object references the Core chain [asset lock transaction](inv:user:std#ref-txs-assetlocktx) and includes proof that the transaction is locked. -Currently there are two types of asset lock proofs [defined by rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/mod.rs#L135-L138): InstantSend and ChainLock. Transactions almost always receive InstantSend locks, so the InstantSend asset lock proof is the predominate type. See rs-dpp for examples of using [InstantSend](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs) or [ChainLocks](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs) as the asset lock proof. +Currently there are two types of asset lock proofs [defined by rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/mod.rs#L135-L138): InstantSend and ChainLock. Transactions almost always receive InstantSend locks, so the InstantSend asset lock proof is the predominate type. See rs-dpp for examples of using [InstantSend](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs) or [ChainLocks](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs) as the asset lock proof. #### InstantSend Asset Lock Proof -The InstantSend asset lock proof is used for transactions that have received an InstantSend lock. Asset locks using an InstantSend lock as proof must comply with this structure established in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs#L29-L36). +The InstantSend asset lock proof is used for transactions that have received an InstantSend lock. Asset locks using an InstantSend lock as proof must comply with this structure established in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs#L38-L45). | Field | Type | Description | | ----------- | -------------- | ----------- | @@ -242,11 +298,11 @@ The InstantSend asset lock proof is used for transactions that have received an #### ChainLock Asset Lock Proof -The ChainLock asset lock proof is used for transactions that have note received an InstantSend lock, but have been included in a block that has received a ChainLock. Asset locks using a ChainLock as proof must comply with this structure established in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs#L15-L20). +The ChainLock asset lock proof is used for transactions that have not received an InstantSend lock, but have been included in a block that has received a ChainLock. Asset locks using a ChainLock as proof must comply with this structure established in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs#L24-L29). | Field | Type | Description | | --------------------- | -------------- | ----------- | -| type | array of bytes | The type of asset lock proof (`1` for ChainLocks) | +| type | integer | The type of asset lock proof (`1` for ChainLocks) | | coreChainLockedHeight | integer | Height of the ChainLocked Core block containing the transaction | | outPoint | object | The [outpoint](https://docs.dash.org/en/stable/docs/core/resources/glossary.html#outpoint) being used as the asset lock | diff --git a/docs/protocol-ref/overview.md b/docs/protocol-ref/overview.md index 632df74fb..6d392772f 100644 --- a/docs/protocol-ref/overview.md +++ b/docs/protocol-ref/overview.md @@ -8,7 +8,7 @@ The Dash Platform Protocol (DPP) defines a protocol for the data objects (e.g., [identities](../protocol-ref/identity.md), data contracts, documents, state transitions) that can be stored on [Dash's layer 2 platform](../intro/what-is-dash-platform.md). All data stored on Dash Platform is governed by DPP to ensure data consistency and integrity is maintained. -Dash Platform data objects consist of JSON and are validated using the JSON Schema specification via pre-defined JSON Schemas and meta-schemas described in these sections. The meta-schemas allow for creation of DPP-compliant schemas which define fields for third-party Dash Platform applications. +Dash Platform data objects consist of JSON and are validated primarily through Rust-native validation logic, with supplementary JSON Schemas and meta-schemas used for data contract document definitions. The meta-schemas allow for creation of DPP-compliant schemas which define fields for third-party Dash Platform applications. In addition to ensuring data complies with predefined JSON Schemas, DPP also defines rules for hashing and serialization of these objects. diff --git a/docs/protocol-ref/protocol-constants.md b/docs/protocol-ref/protocol-constants.md index acc2de194..6c9086d9c 100644 --- a/docs/protocol-ref/protocol-constants.md +++ b/docs/protocol-ref/protocol-constants.md @@ -2,10 +2,6 @@ .. _protocol-ref-constants: ``` -:::{attention} -Draft page - work in progress -::: - # Protocol Constants This page provides a comprehensive reference for all constants, limits, and default values defined in the Dash Platform Protocol implementation (rs-dpp). @@ -16,17 +12,18 @@ Maximum sizes and limits for various platform components. | Limit | Value | Description | Source | |-------|-------|-------------|--------| -| Max contract size | 16,384 bytes (16 KiB) | Maximum serialized data contract | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L4) | -| Max field value size | 5,120 bytes (5 KiB) | Maximum single field value | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L5) | -| Max state transition size | 20,480 bytes (20 KiB) | Maximum serialized state transition | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L6) | -| Max transitions in documents batch | 1 | Maximum document transitions per batch | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L7) | -| Withdrawals per block | 4 | Maximum withdrawal transactions per block | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L8) | -| Retry signing expired withdrawals per block | 1 | Max expired withdrawal retries per block | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L9) | -| Max withdrawal amount | 50,000,000,000,000 credits | 500 Dash maximum per withdrawal | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L10) | -| Max contract group size | 256 | Maximum members per group | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L11) | -| Max token redemption cycles | 128 | Maximum redemption cycles | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L12) | -| Max CBOR encoded length | 16,384 bytes (16 KiB) | Maximum CBOR encoding size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/util/cbor_serializer.rs#L8) | -| Contract deserialization limit | 15,000 | Maximum contract deserialization | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/serialized_version/mod.rs#L35) | +| Max contract size | 16,384 bytes (16 KiB) | Maximum serialized data contract | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L4) | +| Max field value size | 5,120 bytes (5 KiB) | Maximum single field value | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L5) | +| Max state transition size | 20,480 bytes (20 KiB) | Maximum serialized state transition | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L6) | +| Max transitions in documents batch | 1 | Maximum document transitions per batch | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L7) | +| Withdrawals per block | 4 | Maximum withdrawal transactions per block | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L8) | +| Retry signing expired withdrawals per block | 1 | Max expired withdrawal retries per block | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L9) | +| Max withdrawal amount | 50,000,000,000,000 credits | 500 Dash maximum per withdrawal | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L10) | +| Max contract group size | 256 | Maximum members per group | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L11) | +| Max token redemption cycles | 128 | Maximum redemption cycles | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L12) | +| Max shielded transition actions | 100 | Maximum shielded transitions per batch | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L13) | +| Max CBOR encoded length | 16,384 bytes (16 KiB) | Maximum CBOR encoding size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/util/cbor_serializer.rs#L8) | +| Contract deserialization limit | 15,000 | Maximum contract deserialization | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/serialized_version/mod.rs#L38) | ## Credit System @@ -34,8 +31,8 @@ Credits are the unit of account for fees on Dash Platform. They are created from | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| `CREDITS_PER_DUFF` | 1,000 | Credits created per duff (satoshi) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/balances/credits.rs#L40) | -| `MAX_CREDITS` | 9,223,372,036,854,775,807 | Maximum credit value (i64::MAX) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/balances/credits.rs#L38) | +| `CREDITS_PER_DUFF` | 1,000 | Credits created per duff (satoshi) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/balances/credits.rs#L42) | +| `MAX_CREDITS` | 9,223,372,036,854,775,807 | Maximum credit value (i64::MAX) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/balances/credits.rs#L40) | **Conversion:** 1 Dash = 100,000,000 duffs = 100,000,000,000 credits @@ -47,13 +44,13 @@ These constants define the base costs for state transition processing. | Constant | Value (Credits) | Description | Source | |----------|-----------------|-------------|--------| -| `BASE_ST_PROCESSING_FEE` | 10,000 | Base state transition processing fee | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L3) | -| `DEFAULT_USER_TIP` | 0 | Default priority tip | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L4) | -| `STORAGE_CREDIT_PER_BYTE` | 5,000 | Storage cost per byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L5) | -| `PROCESSING_CREDIT_PER_BYTE` | 12 | Processing cost per byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L6) | -| `DELETE_BASE_PROCESSING_COST` | 2,000 | Base deletion cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L7) | -| `READ_BASE_PROCESSING_COST` | 8,400 | Base read cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L8) | -| `WRITE_BASE_PROCESSING_COST` | 6,000 | Base write cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L9) | +| `BASE_ST_PROCESSING_FEE` | 10,000 | Base state transition processing fee | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L3) | +| `DEFAULT_USER_TIP` | 0 | Default priority tip | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L4) | +| `STORAGE_CREDIT_PER_BYTE` | 5,000 | Storage cost per byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L5) | +| `PROCESSING_CREDIT_PER_BYTE` | 12 | Processing cost per byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L6) | +| `DELETE_BASE_PROCESSING_COST` | 2,000 | Base deletion cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L7) | +| `READ_BASE_PROCESSING_COST` | 8,400 | Base read cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L8) | +| `WRITE_BASE_PROCESSING_COST` | 6,000 | Base write cost | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs#L9) | ### State Transition Pricing @@ -61,20 +58,20 @@ These constants define minimum values required for a state transition to be cons | State Transition | Min Fee (Credits) | Min Fee (Dash) | Source | |------------------|-------------------|----------------|--------| -| Credit Transfer | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L4) | -| Credit Transfer to Addresses | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L5) | -| Credit Withdrawal | 400,000,000 | 0.004 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L6) | -| Identity Update | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L7) | -| Document Batch (per sub-transition) | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L8) | -| Contract Create | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L9) | -| Contract Update | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L10) | -| Masternode Vote | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L11) | -| Address Credit Withdrawal | 400,000,000 | 0.004 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L13) | -| Address Funds Transfer (per input) | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L14) | -| Address Funds Transfer (per output) | 6,000,000 | 0.00006 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L15) | -| Identity Create (base) | 2,000,000 | 0.00002 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L16) | -| Identity Key (per key at creation) | 6,500,000 | 0.000065 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L17) | -| Identity TopUp (base) | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L18) | +| Credit Transfer | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L4) | +| Credit Transfer to Addresses | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L5) | +| Credit Withdrawal | 400,000,000 | 0.004 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L6) | +| Identity Update | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L7) | +| Document Batch (per sub-transition) | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L8) | +| Contract Create | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L9) | +| Contract Update | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L10) | +| Masternode Vote | 100,000 | 0.000001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L11) | +| Address Credit Withdrawal | 400,000,000 | 0.004 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L13) | +| Address Funds Transfer (per input) | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L14) | +| Address Funds Transfer (per output) | 6,000,000 | 0.00006 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L15) | +| Identity Create (base) | 2,000,000 | 0.00002 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L16) | +| Identity Key (per key at creation) | 6,500,000 | 0.000065 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L17) | +| Identity TopUp (base) | 500,000 | 0.000005 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs#L18) | ### Execution and Resource Pricing @@ -86,15 +83,16 @@ Fees for specific operations during state transition processing. | Operation | Fee (Credits) | Source | |-----------|---------------|--------| -| Fetch identity balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L4) | -| Fetch identity revision | 9,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L5) | -| Fetch identity balance and revision | 15,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L6) | -| Fetch identity key by ID | 9,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L7) | -| Fetch identity token balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L8) | -| Fetch prefunded specialized balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L9) | -| Fetch single identity key | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L10) | -| Network threshold signing | 100,000,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L11) | -| Validate key structure | 50 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L12) | +| Fetch identity balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L4) | +| Fetch identity revision | 9,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L5) | +| Fetch identity balance and revision | 15,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L6) | +| Fetch identity key by ID | 9,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L7) | +| Fetch identity token balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L8) | +| Fetch prefunded specialized balance | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L9) | +| Fetch key with type, nonce and balance | 12,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L10) | +| Fetch single identity key | 10,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L11) | +| Network threshold signing | 100,000,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L12) | +| Validate key structure | 50 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/processing/v1.rs#L13) | #### Storage @@ -102,11 +100,11 @@ Fees related to data storage operations. | Operation | Fee (Credits) | Source | |-----------|---------------|--------| -| Storage disk usage (per byte) | 27,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | -| Storage processing (per byte) | 400 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | -| Storage load (per byte) | 20 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | -| Non-storage load (per byte) | 10 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | -| Storage seek | 2,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | +| Storage disk usage (per byte) | 27,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | +| Storage processing (per byte) | 400 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | +| Storage load (per byte) | 20 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | +| Non-storage load (per byte) | 10 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | +| Storage seek | 2,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/storage/v1.rs) | #### Cryptographic Operations @@ -116,11 +114,11 @@ Fees for verifying different signature types. | Key Type | Verification Fee (Credits) | Source | |----------|----------------------------|--------| -| ECDSA Secp256k1 | 15,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | -| BLS 12-381 | 300,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | -| ECDSA Hash160 | 15,500 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | -| BIP13 Script Hash | 300,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | -| EdDSA 25519 Hash160 | 3,500 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | +| ECDSA Secp256k1 | 15,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | +| BLS 12-381 | 300,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | +| ECDSA Hash160 | 15,500 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | +| BIP13 Script Hash | 300,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | +| EdDSA 25519 Hash160 | 3,500 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/signature/v1.rs) | ##### Hashing @@ -128,12 +126,27 @@ Fees for cryptographic hash operations. | Operation | Fee (Credits) | Source | |-----------|---------------|--------| -| Single SHA256 (base) | 100 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | -| Blake3 (base) | 100 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | -| SHA256 + RIPEMD160 (base) | 6,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | -| SHA256 (per block) | 5,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | -| Blake3 (per block) | 300 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | -| RIPEMD160 (per block) | 5,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| Single SHA256 (base) | 100 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| Blake3 (base) | 100 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| SHA256 + RIPEMD160 (base) | 6,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| SHA256 (per block) | 5,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| Blake3 (per block) | 300 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| RIPEMD160 (per block) | 5,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | +| Sinsemilla (base) | 40,000 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/hashing/v1.rs) | + +#### Data Contract Validation + +Fees for validating data contract structure during state transition processing. + +| Fee Type | Amount (Credits) | Source | +|----------|------------------|--------| +| Document type base fee | 500 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L5) | +| Schema size fee (per byte) | 10 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L6) | +| Per property fee | 40 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L7) | +| Non-unique index base fee | 50 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L8) | +| Non-unique index per property fee | 30 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L9) | +| Unique index base fee | 100 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L10) | +| Unique index per property fee | 60 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_validation/v1.rs#L11) | ### Voting @@ -141,9 +154,9 @@ Fees related to contested document voting. | Fee Type | Amount (Credits) | Amount (Dash) | Source | |----------|------------------|---------------|--------| -| Contested document vote resolution fund | 20,000,000,000 | 0.2 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | -| Contested document unlock fund | 400,000,000,000 | 4.0 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | -| Single vote cost | 10,000,000 | 0.0001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | +| Contested document vote resolution fund | 20,000,000,000 | 0.2 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | +| Contested document unlock fund | 400,000,000,000 | 4.0 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | +| Single vote cost | 10,000,000 | 0.0001 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs) | ## Identity Model @@ -151,19 +164,19 @@ Fees related to contested document voting. | Limit | Value | Description | Source | |-------|-------|-------------|--------| -| Max public keys per identity | 15,000 | Maximum keys an identity can have | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/identity/fields.rs#L7) | -| Max keys in creation | 6 | Keys allowed at identity creation | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L18) | -| Identity nonce value filter | 0xFFFFFFFFFF | 40-bit nonce filter | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/identity/identity_nonce.rs#L13) | -| Max missing identity revisions | 24 | Maximum revision gaps | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/identity/identity_nonce.rs#L15) | +| Max public keys per identity | 15,000 | Maximum keys an identity can have | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/fields.rs#L7) | +| Max keys in creation | 6 | Keys allowed at identity creation | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L18) | +| Identity nonce value filter | 0xFFFFFFFFFF | 40-bit nonce filter | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/identity_nonce.rs#L13) | +| Max missing identity revisions | 24 | Maximum revision gaps | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/identity/identity_nonce.rs#L15) | ### Identity Create Fees | Requirement | Value | Description | Source | |-------------|-------|-------------|--------| -| Min asset lock balance | 200,000 duffs | 0.002 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L20) | -| Min top-up balance | 50,000 duffs | 0.0005 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L21) | -| Min address funding balance | 50,000 duffs | 0.0005 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L22) | -| Min identity funding amount | 200,000 credits | Minimum for address-based creation | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L41) | +| Min asset lock balance | 200,000 duffs | 0.002 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L20) | +| Min top-up balance | 50,000 duffs | 0.0005 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L21) | +| Min address funding balance | 50,000 duffs | 0.0005 Dash minimum | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L22) | +| Min identity funding amount | 200,000 credits | Minimum for address-based creation | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L41) | ## Document & Data Contract Model @@ -171,20 +184,20 @@ Fees related to contested document voting. | Limit | Value | Description | Source | |-------|-------|-------------|--------| -| Max indexed string length | 63 characters | Maximum indexable string | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L23) | -| Max indexed byte array length | 255 bytes | Maximum indexable byte array | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L24) | -| Max indexed array items | 1,024 | Maximum items in indexed array | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L25) | -| Max index size | 255 bytes | Maximum total index size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L38) | -| Default hash size | 32 bytes | Standard hash size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L35) | -| Default float size | 8 bytes | Standard float size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L36) | -| Empty tree storage size | 33 bytes | Storage for empty tree | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L37) | -| Storage flags size | 2 bytes | Size of storage flags | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L39) | +| Max indexed string length | 63 characters | Maximum indexable string | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L23) | +| Max indexed byte array length | 255 bytes | Maximum indexable byte array | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L24) | +| Max indexed array items | 1,024 | Maximum items in indexed array | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs#L25) | +| Max index size | 255 bytes | Maximum total index size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L38) | +| Default hash size | 32 bytes | Standard hash size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L35) | +| Default float size | 8 bytes | Standard float size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L36) | +| Empty tree storage size | 33 bytes | Storage for empty tree | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L37) | +| Storage flags size | 2 bytes | Size of storage flags | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/document_type/mod.rs#L39) | ### Data Contract Constants | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| Initial contract version | 1 | Starting version number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/mod.rs#L76) | +| Initial contract version | 1 | Starting version number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/mod.rs#L76) | ### Data Contract Registration Fees @@ -192,15 +205,15 @@ One-time fees for registering data contracts and their components. | Component | Fee (Credits) | Fee (Dash) | Source | |-----------|---------------|------------|--------| -| Base contract registration | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Document type registration | 2,000,000,000 | 0.02 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Non-unique index registration | 1,000,000,000 | 0.01 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Unique index registration | 1,000,000,000 | 0.01 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Contested index registration | 100,000,000,000 | 1.0 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Token registration | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Token perpetual distribution | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Token pre-programmed distribution | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | -| Search keyword (per keyword) | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Base contract registration | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Document type registration | 2,000,000,000 | 0.02 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Non-unique index registration | 1,000,000,000 | 0.01 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Unique index registration | 1,000,000,000 | 0.01 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Contested index registration | 100,000,000,000 | 1.0 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Token registration | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Token perpetual distribution | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Token pre-programmed distribution | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | +| Search keyword (per keyword) | 10,000,000,000 | 0.1 | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/fee/data_contract_registration/v2.rs) | ### Tokens @@ -210,7 +223,7 @@ Tokens are defined within data contracts and share the same lifecycle, versionin | Limit | Value | Description | Source | |-------|-------|-------------|--------| -| Max token note length | 2,048 characters | Maximum note/memo length | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/tokens/mod.rs#L19) | +| Max token note length | 2,048 bytes | Maximum note/memo length | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L19) | #### Token Distribution Function Limits @@ -218,17 +231,17 @@ These limits apply to token perpetual distribution function parameters. | Parameter | Min | Max | Source | |-----------|-----|-----|--------| -| `MAX_DISTRIBUTION_PARAM` | 1 | 281,474,976,710,655 (2^48 - 1) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L12) | -| `MAX_DISTRIBUTION_CYCLES_PARAM` | 1 | 32,767 (2^(63-48) - 1) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L18) | -| Linear slope A | -255 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Polynomial M | -8 | 8 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Polynomial N | 0 | 32 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Polynomial A | -255 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Log A | -32,766 | 32,767 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Exponential A | 1 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Exponential M | -8 | 8 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Exponential N | 0 | 32 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | -| Default step decreasing max cycles | 128 | 128 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L20) | +| `MAX_DISTRIBUTION_PARAM` | 1 | 281,474,976,710,655 (2^48 - 1) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L14) | +| `MAX_DISTRIBUTION_CYCLES_PARAM` | 1 | 32,767 (2^(63-48) - 1) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L20) | +| Linear slope A | -255 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Polynomial M | -8 | 8 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Polynomial N | 0 | 32 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Polynomial A | -255 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Log A | -32,766 | 32,767 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Exponential A | 1 | 256 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Exponential M | -8 | 8 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Exponential N | 0 | 32 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs) | +| Default step decreasing max cycles | 128 | 128 | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs#L22) | ## Address System @@ -239,39 +252,41 @@ These limits apply to token perpetual distribution function parameters. | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| Address hash size | 20 bytes | Size of address hash | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L22) | -| Platform HRP (mainnet) | "dashevo" | Human-readable prefix | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L85) | -| Platform HRP (testnet) | "tdashevo" | Testnet human-readable prefix | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L87) | -| P2PKH address type | 0 | Pay-to-public-key-hash | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L91) | -| P2SH address type | 1 | Pay-to-script-hash | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L93) | +| Address hash size | 20 bytes | Size of address hash | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L22) | +| Platform HRP (mainnet) | "dash" | Human-readable prefix | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L89) | +| Platform HRP (testnet) | "tdash" | Testnet human-readable prefix | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L91) | +| P2PKH address type | 0xb0 (176) | Pay-to-public-key-hash encoding type byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L95) | +| P2SH address type | 0x80 (128) | Pay-to-script-hash encoding type byte | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/address_funds/platform_address.rs#L97) | ### Transaction Limits | Limit | Value | Description | Source | |-------|-------|-------------|--------| -| Min output amount | 500,000 credits | Minimum output per address | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L39) | -| Min input amount | 100,000 credits | Minimum input per address | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L40) | -| Max fee strategies | 4 | Maximum fee strategy steps | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L45) | +| Min output amount | 500,000 credits | Minimum output per address | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L39) | +| Min input amount | 100,000 credits | Minimum input per address | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L40) | +| Max fee strategies | 4 | Maximum fee strategy steps | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v1.rs#L45) | +| Max address inputs | 16 | Maximum input addresses per address-based transition | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v3.rs#L43) | +| Max address outputs | 128 | Maximum output addresses per address-based transition | [rs-platform-version](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/dpp_versions/dpp_state_transition_versions/v3.rs#L44) | ## Epoch and Time Constants | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| Genesis epoch index | 0 | First epoch number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L45) | -| Perpetual storage eras | 50 | Number of storage eras (~50 years) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L49) | -| Default epochs per era | 40 | Epochs in each era (~1 year) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L51) | -| Epoch key offset | 256 | Offset for epoch keys | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/block/epoch/mod.rs#L6) | -| Max epoch | 65,279 | Maximum epoch number (u16::MAX - 256) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/block/epoch/mod.rs#L9) | +| Genesis epoch index | 0 | First epoch number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L45) | +| Perpetual storage eras | 50 | Number of storage eras (~50 years) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L49) | +| Default epochs per era | 40 | Epochs in each era (~1 year) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/epoch/mod.rs#L51) | +| Epoch key offset | 256 | Offset for epoch keys | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/block/epoch/mod.rs#L6) | +| Max epoch | 65,279 | Maximum epoch number (u16::MAX - 256) | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/block/epoch/mod.rs#L9) | ## Refund Constants | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| Min refund limit | 32 bytes | Minimum bytes for refund | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/fee/fee_result/refunds.rs#L23) | +| Min refund limit | 32 bytes | Minimum bytes for refund | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/fee_result/refunds.rs#L23) | ## Withdrawal Constants | Constant | Value | Description | Source | |----------|-------|-------------|--------| -| Min withdrawal amount | ~181,000 credits | Based on unlock tx size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/) | -| Min core fee per byte | 1 | Must be Fibonacci number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.0-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/) | +| Min withdrawal amount | ~181,000 credits | Based on unlock tx size | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/mod.rs#L44-L45) | +| Min core fee per byte | 1 | Must be Fibonacci number | [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/mod.rs#L41) | diff --git a/docs/protocol-ref/state-transition.md b/docs/protocol-ref/state-transition.md index f15a615a9..da94a29b6 100644 --- a/docs/protocol-ref/state-transition.md +++ b/docs/protocol-ref/state-transition.md @@ -13,23 +13,27 @@ ### Fees -State transition fees are paid via the credits established when an identity is created. Credits are created at a rate of [1000 credits/satoshi](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/balances/credits.rs#L37). Fees for actions vary based on parameters related to storage and computational effort that are defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/fee/default_costs/constants.rs). +State transition fees are paid via the credits established when an identity is created. Credits are created at a rate of [1000 credits/satoshi](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/balances/credits.rs#L42). Fees for actions vary based on parameters related to storage and computational effort that are defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/fee/default_costs/constants.rs). ### Size -All serialized data (including state transitions) is limited to a maximum size of [16 KB](http://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/util/cbor_serializer.rs#L8). +State transitions are limited to a maximum size of [20 KB](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-platform-version/src/version/system_limits/v1.rs#L6). ### Common Fields -The list of common fields used by multiple state transitions is defined in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs). All state transitions include the following fields: +The list of common fields used by multiple state transitions is defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs). All state transitions include the following fields: | Field | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | -| $version | unsigned integer | 32 bits | The platform protocol version (currently `1`) | -| type | unsigned integer | 8 bits | State transition type:
`0` - [data contract create](../protocol-ref/data-contract.md#data-contract-create)
`1` - [batch](#batch)
`2` - [identity create](../protocol-ref/identity.md#identity-create)
`3` - [identity topup](identity.md#identity-topup)
`4` - [data contract update](data-contract.md#data-contract-update)
`5` - [identity update](identity.md#identity-update)
`6` - [identity credit transfer](identity.md#identity-credit-transfer)
`7` - [identity credit withdrawal](identity.md#identity-credit-withdrawal)
`8` - [masternode vote](#masternode-vote)
`9` - [identity credit transfer to addresses](address-system.md#type-9-identitycredittransfertoaddresses)
`10` - [identity create from addresses](address-system.md#type-10-identitycreatefromaddresses)
`11` - [identity topup from addresses](address-system.md#type-11-identitytopupfromaddresses)
`12` - [address funds transfer](address-system.md#type-12-addressfundstransfer)
`13` - [address funding from asset lock](address-system.md#type-13-addressfundingfromassetlock)
`14` - [address credit withdrawal](address-system.md#type-14-addresscreditwithdrawal) | +| $version | unsigned integer | 32 bits | The state transition format version (FeatureVersion). Currently `0` for most transitions, `1` for Batch. This is not the global platform protocol version, which is negotiated separately. | +| type | unsigned integer | 8 bits | State transition type (defined in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transition_types.rs#L21)):
`0` - [data contract create](../protocol-ref/data-contract.md#data-contract-create)
`1` - [batch](#batch)
`2` - [identity create](../protocol-ref/identity.md#identity-create)
`3` - [identity topup](identity.md#identity-topup)
`4` - [data contract update](data-contract.md#data-contract-update)
`5` - [identity update](identity.md#identity-update)
`6` - [identity credit withdrawal](identity.md#identity-credit-withdrawal)
`7` - [identity credit transfer](identity.md#identity-credit-transfer)
`8` - [masternode vote](#masternode-vote)
`9` - [identity credit transfer to addresses](address-system.md#identity-credit-transfer-to-addresses)
`10` - [identity create from addresses](address-system.md#identity-create-from-addresses)
`11` - [identity topup from addresses](address-system.md#identity-topup-from-addresses)
`12` - [address funds transfer](address-system.md#address-funds-transfer)
`13` - [address funding from asset lock](address-system.md#address-funding-from-asset-lock)
`14` - [address credit withdrawal](address-system.md#address-credit-withdrawal)
`15` - shield
`16` - shielded transfer
`17` - unshield
`18` - shield from asset lock
`19` - shielded withdrawal | | userFeeIncrease | unsigned integer | 16 bits | Extra fee to prioritize processing if the mempool is full. Typically set to zero. | | signature | array of bytes | 65 bytes |Signature of state transition data | +:::{note} +The [masternode vote](#masternode-vote) transition does not include the `userFeeIncrease` field. +::: + Additionally, all state transitions except the identity create and topup state transitions include: | Field | Type | Size | Description | @@ -38,45 +42,32 @@ Additionally, all state transitions except the identity create and topup state t ## State Transition Types -Dash Platform Protocol defines the [state transition types](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transition_types.rs#L21-L32) that perform identity, contract, document, and token operations. See the subsections below for details on each state transition type. +Dash Platform Protocol defines the [state transition types](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transition_types.rs#L21-L43) that perform identity, contract, document, and token operations. See the subsections below for details on each state transition type. ### Batch | Field | Type | Size | Description | | ----------- | -------------- | ---- | ----------- | | ownerId | array of bytes | 32 bytes | [Identity](../protocol-ref/identity.md) submitting the document(s) | -| transitions | array of transition objects | Varies | A batch of [document](../protocol-ref/document.md#document-overview) or token actions (up to 10 objects) | +| transitions | array of transition objects | Varies | A batch of [document](../protocol-ref/document.md#document-overview) or token actions (currently limited to 1 object per batch) | -More detailed information about the `transitions` array can be found in the [document section](../protocol-ref/document.md). See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/mod.rs#L29-L37). +More detailed information about the `transitions` array can be found in the [document section](../protocol-ref/document.md). See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/mod.rs#L31-L39). ### Data Contract Create | Field | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | | dataContract | [data contract object](../protocol-ref/data-contract.md#data-contract-object) | Varies | Object containing valid [data contract](../protocol-ref/data-contract.md) details | -| entropy | array of bytes | 32 bytes | Entropy used to generate the data contract ID | +| identityNonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | More detailed information about the `dataContract` object can be found in the [data contract section](../protocol-ref/data-contract.md). -#### Entropy Generation - -Entropy is included in [Data Contracts](../protocol-ref/data-contract.md#data-contract-create) and [Documents](../protocol-ref/document.md#document-create-transition). Dash Platform using the following entropy generator found in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/util/entropy_generator.rs#L12-L16): - -```rust -// From the Rust reference implementation (rs-dpp) -// entropyGenerator.js -fn generate(&self) -> anyhow::Result<[u8; 32]> { - let mut buffer = [0u8; 32]; - getrandom(&mut buffer).context("generating entropy failed")?; - Ok(buffer) -} -``` - ### Data Contract Update | Field | Type | Description | | --------------- | -------------- | ----------- | | dataContract | [data contract object](../protocol-ref/data-contract.md#data-contract-object) | Object containing valid [data contract](../protocol-ref/data-contract.md) details | +| identityContractNonce | unsigned integer (64 bits) | Identity contract nonce for replay protection | More detailed information about the `dataContract` object can be found in the [data contract section](../protocol-ref/data-contract.md). @@ -85,7 +76,7 @@ More detailed information about the `dataContract` object can be found in the [d | Field | Type | Size | Description | | --------------- | -------------- | ---- | ----------- | | assetLockProof | array of bytes | 36 bytes | Lock [outpoint](https://docs.dash.org/en/stable/docs/core/resources/glossary.html#outpoint) from the layer 1 locking transaction (36 bytes) | -| publicKeys | array of keys | Varies | [Public key(s)](../protocol-ref/identity.md#identity-publickeys) associated with the identity (maximum number of keys: `10`) | +| publicKeys | array of keys | Varies | [Public key(s)](../protocol-ref/identity.md#identity-publickeys) associated with the identity (maximum number of keys: `6`) | More detailed information about the `publicKeys` object can be found in the [identity section](../protocol-ref/identity.md). @@ -103,7 +94,7 @@ More detailed information about the `publicKeys` object can be found in the [ide | identityId | array of bytes | 32 bytes | The [Identity ID](../protocol-ref/identity.md#identity-id) for the identity being updated | | revision | unsigned integer | 64 bits | Identity update revision. Used for optimistic concurrency control. Incremented by one with each new update so that the update will fail if the underlying data is modified between reading and writing. | | nonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | -| addPublicKeys | array of public keys | Varies | (Optional) Array of up to 10 new public keys to add to the identity. Required if adding keys. | +| addPublicKeys | array of public keys | Varies | (Optional) Array of up to 6 new public keys to add to the identity. Required if adding keys. | | disablePublicKeys | array of integers | Varies | (Optional) Array of up to 10 existing identity public key ID(s) to disable for the identity. Required if disabling keys. | ### Identity Credit Transfer @@ -115,7 +106,7 @@ More detailed information about the `publicKeys` object can be found in the [ide | amount | unsigned integer | 64 bits | Number of credits being transferred | | nonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | -See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L39-L50). +See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L42-L53). ### Identity Credit Withdrawal @@ -123,12 +114,12 @@ See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0 | --------------- | -------------- | ---- | ----------- | | identityId | array of bytes | 32 bytes | An [Identity ID](../protocol-ref/identity.md#identity-id) for the identity sending the credits | | amount | unsigned integer | 64 bits | Number of credits being transferred | -| coreFeePerByte | unsigned integer | 32 bytes | | -| pooling | unsigned integer | 8 bytes | 0 = Never, 1 = If Available, 2 = Standard | +| coreFeePerByte | unsigned integer | 32 bits | | +| pooling | unsigned integer | 8 bits | 0 = Never, 1 = If Available, 2 = Standard | | outputScript | script | Varies | If None, the withdrawal is sent to the address set by Core | | nonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | -See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L32-L45). +See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L35-L48). ### Masternode Vote @@ -136,10 +127,10 @@ See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0 | --------------- | -------------- | ---- | ----------- | | proTxHash | array of bytes | 32 bytes | An identifier based on a masternode or evonode's [provider registration transaction](inv:user:std#ref-txs-proregtx) hash | | voterIdentityId | array of bytes | 32 bytes | The voter's [Identity ID](../protocol-ref/identity.md#identity-id). This will be a masternode identity based on the protx hash. | -| vote | [Vote](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/voting/votes/mod.rs#L20-L22) | Varies | Vote information | +| vote | [Vote](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/voting/votes/mod.rs#L25-L27) | Varies | Vote information | | nonce | unsigned integer | 64 bits | Identity nonce for this transition to prevent replay attacks | -See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs#L40-L50). +See the implementation in [rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs#L43-L53). ## State Transition Signing @@ -151,8 +142,14 @@ transition type: | Signing Method | State Transitions | | -------------- | ----------------- | | [Identity](#signing-with-identity) | Batch, Contract create, Contract update, Identity update, Identity credit transfer, Identity credit transfer to addresses, Identity credit withdrawal, Masternode vote | -| [Asset lock](#signing-with-asset-lock) | Identity create, Identity topup, Address funding from asset lock | -| [Address witness](#signing-with-address-witness) | Identity create from addresses, Identity topup from addresses, Address funds transfer, Address credit withdrawal | +| [Asset lock](#signing-with-asset-lock) | Identity create, Identity topup, Address funding from asset lock* | +| [Address witness](#signing-with-address-witness) | Identity create from addresses, Identity topup from addresses, Address funds transfer, Address credit withdrawal, Address funding from asset lock* | + +\* Address funding from asset lock requires both an asset lock signature and address witnesses (`input_witnesses`). + +:::{note} +Shield-related state transitions (types 15-19: Shield, ShieldedTransfer, Unshield, ShieldFromAssetLock, ShieldedWithdrawal) are defined in the protocol but their signing methods are not yet documented here. +::: :::{note} Address-based state transitions (types 9-14) were introduced in Protocol Version 11. For detailed information on these transitions, see [Address-Based State Transitions](address-system.md). @@ -195,6 +192,10 @@ The process to sign state transitions using an identity consists of the followin Address-based state transitions (types 10-12, 14) use address witnesses to prove ownership of Platform addresses. Unlike identity-signed transitions, these do not require an existing identity. Instead, each input address requires a corresponding witness containing cryptographic proof of address ownership. +:::{note} +Identity credit transfer to addresses (type 9) is **not** signed with address witnesses — it uses identity signing because it requires an existing identity. +::: + The process to sign state transitions using address witnesses consists of the following steps: 1. **Create a canonical, signable state transition** encoded using [Bincode](https://github.com/bincode-org/bincode). @@ -223,12 +224,12 @@ This table shows the fields that must be excluded when creating state transition | State transition | Signature | Signature public key ID | Identity ID | Identity public key signature(s) | | - | :-: | :-: | :-: | :-: | -| [Batch](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/mod.rs#L34-L37) | Exclude | Exclude | N/A | N/A | -| [Contract create](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs#L41-L44) | Exclude | Exclude | N/A | N/A | -| [Contract update](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs#L41-L44) | Exclude | Exclude | N/A | N/A | -| [Identity create](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs#L50-L54) | Exclude | N/A | Exclude | [Exclude](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/v0/mod.rs#L47-L48) | -| [Identity topup](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs#L45-L46) | Exclude | N/A | N/A | N/A | -| [Identity update](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs#L63-L68) | Exclude | Exclude | N/A | [Exclude for any keys being added by the state transition](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/v0/mod.rs#L47-L48) | -| [Identity credit transfer](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L46-L49) | Exclude | Exclude | N/A | N/A | -| [Identity credit withdrawal](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L41-L44) | Exclude | Exclude | N/A | N/A | -| [Masternode vote](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs#L46-L49) | Exclude | Exclude | N/A | N/A | +| [Batch](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/mod.rs#L35-L38) | Exclude | Exclude | N/A | N/A | +| [Contract create](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs#L44-L47) | Exclude | Exclude | N/A | N/A | +| [Contract update](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs#L43-L46) | Exclude | Exclude | N/A | N/A | +| [Identity create](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs#L53-L57) | Exclude | N/A | Exclude | [Exclude](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/v0/mod.rs#L50-L51) | +| [Identity topup](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs#L48-L49) | Exclude | N/A | N/A | N/A | +| [Identity update](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs#L67-L71) | Exclude | Exclude | N/A | [Exclude for any keys being added by the state transition](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/v0/mod.rs#L50-L51) | +| [Identity credit transfer](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs#L49-L52) | Exclude | Exclude | N/A | N/A | +| [Identity credit withdrawal](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs#L44-L47) | Exclude | Exclude | N/A | N/A | +| [Masternode vote](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs#L49-L52) | Exclude | Exclude | N/A | N/A | diff --git a/docs/protocol-ref/token.md b/docs/protocol-ref/token.md index b681f8ec9..bc327c585 100644 --- a/docs/protocol-ref/token.md +++ b/docs/protocol-ref/token.md @@ -4,6 +4,27 @@ Dash Platform lets developers create and manage tokens (similar to ERC-20 style assets) without writing smart contracts. Tokens leverage [data contracts](./data-contract.md), [state transitions](./state-transition.md), and built-in access control (via data contract groups) to enable flexible token management. All token operations are completed by submitting them to the platform in a [batch state transition](./state-transition.md#batch). +## Token Constants and Limits + +| Constant | Value | Description | +|----------|-------|-------------| +| `MAX_TOKEN_NOTE_LEN` | 2,048 bytes | Maximum length for public/private notes | +| `document_batch_sub_transition` | 100,000 credits | Minimum fee per token sub-transition | + +### Token Fee Payer Options + +Token transitions support flexible fee payment via the `GasFeesPaidBy` enum: + +| Value | Name | Description | +|-------|------|-------------| +| 0 | `DocumentOwner` | Fees paid by the identity submitting the transition | +| 1 | `ContractOwner` | Fees paid by the contract owner | +| 2 | `PreferContractOwner` | Fees paid by the contract owner if possible, otherwise by the document owner | + +:::{seealso} +For all protocol constants, see [Protocol Constants](protocol-constants.md). +::: + ## Token State Transition Details All token transitions include the [token base transition fields](#token-base-transition). Most token transitions (.e.g., [token mint](#token-mint-transition)) require additional fields to provide their functionality. @@ -14,17 +35,17 @@ The following fields are included in all token transitions: | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -| $identityContractNonce | unsigned integer | 64 bits | Identity contract nonce | +| $identity-contract-nonce | unsigned integer | 64 bits | Identity contract nonce | | $tokenContractPosition | unsigned integer | 16 bits | Position of the token within the contract | | $dataContractId | array | 32 bytes | Data contract ID [generated](../protocol-ref/data-contract.md#data-contract-id) from the data contract's `ownerId` and `entropy` | | [$tokenId](#token-id) | array | 32 bytes | Token ID generated from the data contract ID and the token position | -| usingGroupInfo | [GroupStateTransitionInfo object](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/group/mod.rs#L42-L59) | Varies | Optional field indicating group multi-party authentication rules | +| usingGroupInfo | [GroupStateTransitionInfo object](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/group/mod.rs#L42-L50) | Varies | Optional field indicating group multi-party authentication rules | -Each token transition must comply with the [token base transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_base_transition/v0/mod.rs#L45-L72). +Each token transition must comply with the [token base transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_base_transition/v0/mod.rs#L42-L60). #### Token id -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.1/packages/rs-dpp/src/tokens/mod.rs#L27-L32). +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/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L27-L32). ```rust // From the Rust reference implementation (rs-dpp) @@ -39,7 +60,7 @@ pub fn calculate_token_id(contract_id: &[u8; 32], token_pos: TokenContractPositi #### Token Transition Action -The token transition actions [defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition_action_type.rs#L15-L48) indicate what operation platform should perform with the provided transition data. +The token transition actions [defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition_action_type.rs#L15-L48) indicate what operation platform should perform with the provided transition data. | Action | Name | Description | | :-: | - | - | @@ -52,12 +73,16 @@ The token transition actions [defined in rs-dpp](https://github.com/dashpay/plat | 6 | [Claim](#token-claim-transition) | Retrieve tokens based on a specified distribution method | | 7 | [Emergency Action](#token-emergency-action-transition) | Execute an emergency protocol affecting tokens | | 8 | [Config Update](#token-config-update-transition) | Modify the configuration settings of a token | -| 9 | [Set Purchase Price](#token-set-purchase-price-transition) | Define or update the token’s direct purchase pricing schedule for users (enables or adjusts direct token sales) | -| 10 | [Purchase](#token-purchase-transition) | Purchase tokens directly from the token’s owner or distribution pool at the predefined price (transfers tokens to the buyer in exchange for Platform credits) | +| 9 | [Purchase](#token-purchase-transition) | Purchase tokens directly from the token’s owner or distribution pool at the predefined price (transfers tokens to the buyer in exchange for Platform credits) | +| 10 | [Set Purchase Price](#token-set-purchase-price-transition) | Define or update the token’s direct purchase pricing schedule for users (enables or adjusts direct token sales) | + +:::{note} +The numeric action codes above are for client-side reference ordering only. `TokenTransitionActionType` is not used by the platform backend consensus directly. +::: ### Token Notes -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.1/packages/rs-dpp/src/tokens/mod.rs#L19). +Some token transitions include optional notes fields. The maximum note length for these fields is [2048 bytes](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L19). ### Token Burn Transition @@ -66,9 +91,9 @@ The token burn transition extends the [base transition](#token-base-transition) | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | | burnAmount | unsigned integer | 64 bits | Number of tokens to be burned | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token burn transition must comply with the [token burn transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_burn_transition/v0/mod.rs#L22-L38). +Each token burn transition must comply with the [token burn transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_burn_transition/v0/mod.rs#L22-L38). ### Token Mint Transition @@ -78,9 +103,9 @@ The token mint transition extends the [base transition](#token-base-transition) | ----- | ---- | ---- | ----------- | | issuedToIdentityId | array | 32 bytes | Optional identity ID receiving the minted tokens. If this is not set then we issue to the identity set in contract settings. | | amount | unsigned integer | 64 bits | Number of tokens to mint | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token mint transition must comply with the [token mint transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_mint_transition/v0/mod.rs#L23-L43). +Each token mint transition must comply with the [token mint transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_mint_transition/v0/mod.rs#L23-L37). ### Token Transfer Transition @@ -90,11 +115,11 @@ The token transfer transition extends the [base transition](#token-base-transiti | ----- | ---- | ---- | ----------- | | amount | unsigned integer | 64 bits | Number of tokens to transfer | | recipientId | array | 32 bytes | Identity ID of the recipient | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | -| sharedEncryptedNote | [SharedEncryptedNote object](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/tokens/mod.rs#L20) | [<= 2048 characters](#token-notes) | Optional shared encrypted note | -| privateEncryptedNote | [PrivateEncryptedNote object](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/tokens/mod.rs#L21-L25) | [<= 2048 characters](#token-notes) | Optional private encrypted note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | +| sharedEncryptedNote | [SharedEncryptedNote object](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L20) | [<= 2048 bytes](#token-notes) | Optional shared encrypted note | +| privateEncryptedNote | [PrivateEncryptedNote object](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/mod.rs#L21-L25) | [<= 2048 bytes](#token-notes) | Optional private encrypted note | -Each token transfer transition must comply with the [token transfer transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transfer_transition/v0/mod.rs#L30-L61). +Each token transfer transition must comply with the [token transfer transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transfer_transition/v0/mod.rs#L30-L46). ### Token Freeze Transition @@ -103,9 +128,9 @@ The token freeze transition extends the [base transition](#token-base-transition | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | | frozenIdentityId | array | 32 bytes | Identity ID of the account to be frozen | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token freeze transition must comply with the [token freeze transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_freeze_transition/v0/mod.rs#L19-L35). +Each token freeze transition must comply with the [token freeze transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_freeze_transition/v0/mod.rs#L19-L35). ### Token Unfreeze Transition @@ -114,9 +139,9 @@ The token unfreeze transition extends the [base transition](#token-base-transiti | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | | frozenIdentityId | array | 32 bytes | Identity ID of the account to be unfrozen | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token unfreeze transition must comply with the [token unfreeze transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_unfreeze_transition/v0/mod.rs#L19-L35). +Each token unfreeze transition must comply with the [token unfreeze transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_unfreeze_transition/v0/mod.rs#L19-L29). ### Token Destroy Frozen Funds Transition @@ -125,9 +150,9 @@ The token destroy frozen funds transition extends the [base transition](#token-b | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | | frozenIdentityId | array | 32 bytes | Identity ID of the account whose frozen balance should be destroyed | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token destroy frozen funds transition must comply with the [token destroy frozen funds transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_destroy_frozen_funds_transition/v0/mod.rs#L17-L25). +Each token destroy frozen funds transition must comply with the [token destroy frozen funds transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_destroy_frozen_funds_transition/v0/mod.rs#L17-L25). ### Token Claim Transition @@ -135,10 +160,10 @@ The token claim transition extends the [base transition](#token-base-transition) | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -| distributionType | [TokenDistributionType enum](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_distribution_key.rs#L18-L25) | Varies | Type of [token distribution](../explanations/tokens.md#distribution-rules) targeted | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note (only saved for historical contracts) | +| distributionType | [TokenDistributionType enum](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_distribution_key.rs#L18-L25) | Varies | Type of [token distribution](../explanations/tokens.md#distribution-rules) targeted (`0` = PreProgrammed, `1` = Perpetual) | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note (only saved for historical contracts) | -Each token claim transition must comply with the [token claim transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_claim_transition/v0/mod.rs#L18-L26). +Each token claim transition must comply with the [token claim transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_claim_transition/v0/mod.rs#L18-L26). ### Token Emergency Action Transition @@ -146,10 +171,10 @@ The token emergency action transition extends the [base transition](#token-base- | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -| emergencyAction | [TokenEmergencyAction enum](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/tokens/emergency_action.rs#L14-L18) | Varies | The emergency action to be executed | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| emergencyAction | [TokenEmergencyAction enum](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/emergency_action.rs#L14-L18) | Varies | The emergency action to be executed (`0` = Pause, `1` = Resume) | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token emergency action transition must comply with the [token emergency action transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_emergency_action_transition/v0/mod.rs#L16-L24). +Each token emergency action transition must comply with the [token emergency action transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_emergency_action_transition/v0/mod.rs#L16-L24). ### Token Config Update Transition @@ -157,10 +182,10 @@ The token config update transition extends the [base transition](#token-base-tra | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -| updateTokenConfigurationItem | [TokenConfigurationChangeItem object](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/data_contract/associated_token/token_configuration_item.rs#L33-L67) | Varies | Updated token configuration item | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| updateTokenConfigurationItem | [TokenConfigurationChangeItem object](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/data_contract/associated_token/token_configuration_item.rs#L33-L67) | Varies | Updated token configuration item | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token configuration update transition must comply with the [token config update transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_config_update_transition/v0/mod.rs#L19-L27). +Each token configuration update transition must comply with the [token config update transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_config_update_transition/v0/mod.rs#L19-L27). ### Token Set Purchase Price Transition @@ -172,10 +197,10 @@ This transition extends the [base transition](#token-base-transition) to include | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -price | [TokenPricingSchedule](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/tokens/token_pricing_schedule.rs#L31-L47) | Variable | Set the fixed price or tiered price. Tiered pricing entries consists of a *minimum token amount* (unsigned 64-bit) and a *price in credits* (unsigned 64-bit) applicable for purchases of that size or greater. The smallest amount tier also defines the *minimum purchasable amount*. If the lowest tier has amount > 1, users cannot buy less than that amount in a single purchase. If multiple tiers are provided, they should be ordered by ascending minimum amount.
**Note:** An empty pricing schedule indicates direct purchases are disabled for the token. | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +price | Optional [TokenPricingSchedule](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/tokens/token_pricing_schedule.rs#L29-L45) | Variable | (Optional) Set the fixed price or tiered price. Tiered pricing entries consists of a *minimum token amount* (unsigned 64-bit) and a *price in credits* (unsigned 64-bit) applicable for purchases of that size or greater. The smallest amount tier also defines the *minimum purchasable amount*. If the lowest tier has amount > 1, users cannot buy less than that amount in a single purchase. If multiple tiers are provided, they should be ordered by ascending minimum amount.
**Note:** Setting price to null disables direct purchases for the token. | +| publicNote | string | [<= 2048 bytes](#token-notes) | Optional public note | -Each token set purchase price transition must comply with the [token set purchase price transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_set_price_for_direct_purchase_transition/v0/mod.rs#L18-L35). +Each token set purchase price transition must comply with the [token set purchase price transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_set_price_for_direct_purchase_transition/v0/mod.rs#L18-L29). ### Token Purchase Transition @@ -187,8 +212,7 @@ This transition extends the [base transition](#token-base-transition) to include | Field | Type | Size | Description | | ----- | ---- | ---- | ----------- | -| amount | unsigned integer | 64 bits | Number of tokens the user is purchasing. The `amount` must be at least the minimum purchase amount defined by the current pricing, and cannot exceed any available supply limits. | -| totalPrice | unsigned integer | 64 bits | Total price (in credits) that the purchaser agrees to pay for this purchase. This should equal the unit price (or tiered price) times the `amount` of tokens, according to the currently set pricing schedule. | -| publicNote | string | [<= 2048 characters](#token-notes) | Optional public note | +| tokenCount | unsigned integer | 64 bits | Number of tokens the user is purchasing. Must be at least the minimum purchase amount defined by the current pricing and cannot exceed any available supply limits. | +| totalAgreedPrice | unsigned integer | 64 bits | Maximum total price (in credits) the purchaser agrees to pay. Must be at least the unit price (or tiered price) times `tokenCount` according to the current pricing schedule. | -Each token purchase transition must comply with the [token direct purchase transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v2.0.1/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_direct_purchase_transition/v0/mod.rs#L20-L31). +Each token purchase transition must comply with the [token direct purchase transition defined in rs-dpp](https://github.com/dashpay/platform/blob/v3.1-dev/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_direct_purchase_transition/v0/mod.rs#L20-L31).