Data Trigger#
Data Trigger Overview#
Although data contracts provide much needed constraints on the structure of the data being stored on Dash Platform, there are limits to what they can do. Certain system data contracts may require server-side validation logic to operate effectively. For example, DPNS must enforce some rules to ensure names remain DNS compatible. Dash Platform Protocol (DPP) supports this application-specific custom logic using Data Triggers.
Details#
Since all application data is submitted in the form of documents, data triggers are defined in the context of documents. To provide even more granularity, they also incorporate the document transition action so separate triggers can be created for the CREATE, REPLACE, or DELETE actions.
When document state transitions are received, DPP checks if there is a trigger associated with the document transition type and action. If there is, it then executes the trigger logic.
Note: Successful execution of the trigger logic is necessary for the document to be accepted and applied to the platform state.
Example#
As an example, DPP contains several data triggers for DPNS as defined in the data trigger bindings. The domain document has added constraints for creation, replacement or deletion:
Data Contract |
Document |
Action(s) |
Trigger Description |
|---|---|---|---|
DPNS |
|
Enforces DNS compatibility, validates provided hashes, and restricts top-level domain (TLD) registration |
|
—- |
—- |
—- |
—- |
DPNS |
|
Prevents updates to existing documents |
|
DPNS |
|
Prevents deletion of existing documents |
|
DPNS |
|
Prevents transfer of existing documents |
|
DPNS |
|
Prevents purchase of existing documents |
|
DPNS |
|
Prevents updating price of existing documents |
DPNS Trigger Constraints
The following table details the DPNS constraints applied via data triggers. These constraints are in addition to the ones applied directly by the DPNS data contract.
Document |
Action |
Constraint |
|---|---|---|
|
|
Full domain length <= 253 characters |
|
|
|
|
|
|
|
|
|
|
|
Only creating a top-level domain with an authorized identity |
|
|
Referenced |
|
|
Subdomain registration for non-top-level domains prevented if the new domain’s |
|
|
Subdomain registration only allowed by the parent domain owner if the parent domain’s |
|
|
Referenced |
|
|
Action not allowed |
|
|
Action not allowed |
|
|
Action not allowed |
|
|
Action not allowed |
|
|
Action not allowed |
Note
The trigger for domain CREATE attempts to validate that ownerId matches
records.dashUniqueIdentityId or records.dashAliasIdentityId. However, the
DPNS v1 schema defines only records.identity and sets additionalProperties: false, so neither field can exist in a valid document. Both checks are
therefore permanent no-ops and records.identity is not validated against
ownerId at the trigger level.
Other System Contract Triggers#
In addition to DPNS, the following system contracts have registered data triggers:
Dashpay
Document |
Action |
Trigger Description |
|---|---|---|
|
|
Validates contact request fields and permissions |
Masternode Rewards
Document |
Action |
Trigger Description |
|---|---|---|
|
|
Rejected unconditionally (masternodes manage reward shares via internal platform operations) |
|
|
Rejected unconditionally (masternodes manage reward shares via internal platform operations) |
|
|
Rejected unconditionally (masternodes manage reward shares via internal platform operations) |
Withdrawals
Document |
Action |
Trigger Description |
|---|---|---|
|
|
Rejected by data trigger (withdrawal documents cannot be updated) |
|
|
Rejected unless status is |