Guides
Dash CoreDash PlatformDash.orgDash User DocsLog In
These docs are for v0.14.0. Click to read the latest docs for v0.25-redirect.

Document

Application data records

Overview

Dash Platform is based on document-oriented database concepts and uses related terminology. In short, JSON documents are stored into document collections which can then be fetched back using a query language similar to common document-oriented databases like MongoDB, CouchDB, or Firebase.

Documents are defined in an application's Data Contract and represent the structure of application-specific data. Each document consists of one or more fields and the indices necessary to support querying.

❗️

Work in Progress

This document is an work in progress. Details may be missing or incomplete and are subject to change.

Details

Base Fields

Dash Platform Protocol (DPP) defines a set of base fields that must be present in all documents. For the js-dpp reference implementation, the base fields shown below are defined in the document base schema.

Field NameDescription
$idDocument ID
$typeType of document (must match one of the document types defined in the data contract)
$dataContractIdID of the data contract that defines this document
$ownerIdIdentity submitting the document
$revisionDocument revision (=> 1)
$createdAt(Optional) Time (in milliseconds) the document was created
$updatedAt(Optional) Time (in milliseconds) the document was updated

🚧

Timestamp fields

Note: The $createdAt and $updatedAt fields will only be present in documents that add them to the list of required properties.

Data Contract Fields

Each application defines its own fields via document definitions in its data contract. Details of the DPNS data contract documents are described below as an example. This contract defines two document types (preorder and domain) and provides the functionality described in the Name Service explanation.

Document NameField NameData Type
preordersaltedDomainHashstring
---------
domainnameHashstring
domainlabelstring
domainnormalizedLabelstring
domainnormalizedParentvDomainNamestring
domainpreorderSaltstring
domainrecordsobject

Document Submission

Once a document has been created, it must be encapsulated in a State Transition to be sent to the platform. The structure of a document state transition is shown below. For additional details, see the State Transition explanation.

Field NameDescription
protocolVersionDash Platform Protocol version (currently 0)
typeState transition type (1 for documents)
ownerIdIdentity submitting the document(s)
transitionsDocument create, replace, or delete transitions (up to 10 objects)
signaturePublicKeyIdThe id of the identity public key that signed the state transition
signatureSignature of state transition data

Example Document

The following example shows the structure of a DPNS domain document as output from the document .toJSON() method. Note the $ prefix indicating the base fields.

{
  '$id': 'GbMwuXdxzN3BB9efMgLPRhbbqCA5jnyfka2jnbyvGyih',
  '$type': 'domain',
  '$dataContractId': '295xRRRMGYyAruG39XdAibaU9jMAzxhknkkAxFE7uVkW',
  '$ownerId': 'HjRuBghdteSmiN8w1VvGe9VHShdAxgt329xBHNQhyUGL',
  '$revision': 1,
  label: 'testName1234',
  records: {
    dashIdentity: 'HjRuBghdteSmiN8w1VvGe9VHShdAxgt329xBHNQhyUGL'
  },
  nameHash: '5620938ed72967fa06cfd9ebcd3bf9e5a5abf366563f5ea1f1874a531e7d78e75500',
  preorderSalt: 'ya9GK3VwCeLxyAS9jnQX7WTkGcXMJV96mX',
  normalizedLabel: 'testname1234',
  normalizedParentDomainName: 'dash'
}