Platform Endpoints

Detailed platform gRPC endpoint reference

Please refer to the gRPC Overview for details regarding running the examples shown below, encoding/decoding the request/response data, and clients available for several languages.

Endpoint Details

👍

Added in Dash Platform 0.20.0

Dash Platform 0.20.0 introduced proofs to Platform gRPC endpoints so the data returned for a request can be verified as being valid. Full support is not yet available in the JavaScript client, but can be used via the low level via dapi-grpc library. Additional information about proofs is available on the Platform Proofs page.

This version also added some additional metadata to responses:

  • height: the last committed platform chain height
  • coreChainLockedHeight: height of the most recent ChainLock on the core chain

broadcastStateTransition

📘

Updated in Dash Platform 0.18.0

Since Dash Platform 0.18.0 broadcastStateTransition returns once the state transition has been accepted into the mempool instead of waiting until it is confirmed.

Note: The waitForStateTransitionResult endpoint should be used in conjunction with this one for instances where proof of block confirmation is required.

Broadcasts a state transition to the platform via DAPI to make a change to layer 2 data.

Returns: Nothing or error
Parameters:

NameTypeRequiredDescription
state_transitionBytes (Base64)YesA state transition

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const DashPlatformProtocol = require('@dashevo/dpp');

const client = new DAPIClient();
const dpp = new DashPlatformProtocol();

// Data Contract Create State Transition (JSON)
const stateTransitionObject = {
  protocolVersion: 0,
  type: 0,
  signature: 'HxAipUsLWQBE++C1suSRNQiQh91rI1LZbblvQhk2erUaIvRneAagxGYYsXXYNvEeO+lBzlF1a9KHGGTHgnO/8Ts=',
  signaturePublicKeyId: 0,
  dataContract: {
    protocolVersion: 0,
    '$id': 'CMc7RghKkHeHtFdwfSX5Hzy7CUdpCEJnwsbfHdsbmJ32',
    '$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
    ownerId: '8Z3ps3tNoGoPEDYerUNCd4yi7zDwgBh2ejgSMExxvkfD',
    documents: {
      note: {
        properties: { message: { type: 'string' } },
        additionalProperties: false,
      },
    },
  },
  entropy: '+RqUArypdL8f/gCMAo4b6c3CoQvxHzsQG0BdYrT5QT0=',
};

// Convert signature and entropy to buffer
stateTransitionObject.signature = Buffer.from(stateTransitionObject.signature, 'base64');
stateTransitionObject.entropy = Buffer.from(stateTransitionObject.entropy, 'base64');

dpp.stateTransition.createFromObject(stateTransitionObject, { skipValidation: true })
  .then((stateTransition) => {
    client.platform.broadcastStateTransition(stateTransition.toBuffer())
      .then(() => console.log('State Transition broadcast successfully'));
  });
const {
  v0: {
    PlatformPromiseClient,
    BroadcastStateTransitionRequest,
  },
} = require('@dashevo/dapi-grpc');
const DashPlatformProtocol = require('@dashevo/dpp');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const dpp = new DashPlatformProtocol();

// Data Contract Create State Transition (JSON)
const stateTransitionObject = {
  protocolVersion: 0,
  type: 0,
  signature: 'HxAipUsLWQBE++C1suSRNQiQh91rI1LZbblvQhk2erUaIvRneAagxGYYsXXYNvEeO+lBzlF1a9KHGGTHgnO/8Ts=',
  signaturePublicKeyId: 0,
  dataContract: {
    protocolVersion: 0,
    '$id': 'CMc7RghKkHeHtFdwfSX5Hzy7CUdpCEJnwsbfHdsbmJ32',
    '$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
    ownerId: '8Z3ps3tNoGoPEDYerUNCd4yi7zDwgBh2ejgSMExxvkfD',
    documents: {
      note: {
        properties: { message: { type: 'string' } },
        additionalProperties: false,
      },
    },
  },
  entropy: '+RqUArypdL8f/gCMAo4b6c3CoQvxHzsQG0BdYrT5QT0=',
};

// Convert signature and entropy to buffer
stateTransitionObject.signature = Buffer.from(stateTransitionObject.signature, 'base64');
stateTransitionObject.entropy = Buffer.from(stateTransitionObject.entropy, 'base64');

const broadcastStateTransitionRequest = new BroadcastStateTransitionRequest();

dpp.stateTransition.createFromObject(stateTransitionObject, { skipValidation: true })
  .then((stateTransition) => {
    console.log(stateTransition);
    broadcastStateTransitionRequest.setStateTransition(stateTransition.toBuffer());

    platformPromiseClient.broadcastStateTransition(broadcastStateTransitionRequest)
      .then(() => console.log('State Transition broadcast successfully'))
      .catch((e) => {
        console.error(e);
        console.error(e.metadata);
      });
  })
  .catch((e) => console.error(e));
# Submit an identity create State Transition
# `state_transition` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "state_transition":"pWR0eXBlAmlzaWduYXR1cmV4WEg3TWhFWDQ0Z3JzMVIwTE9XTU5IZjAxWFNpYVFQcUlVZ1JLRXQyMkxHVERsUlUrZ1BwQUlUZk5JUmhXd3IvYTVHd0lzWm1idGdYVVFxcVhjbW9lQWtUOD1qcHVibGljS2V5c4GkYmlkAGRkYXRheCxBdzh2UmYxeFFCTlVLbzNiY2llaHlaR2NhM0hBSThkY0ZvVWJTK3hLb0lITmR0eXBlAGlpc0VuYWJsZWT1bmxvY2tlZE91dFBvaW50eDBLT1VUSHB5YnFPek9DNnhEVUhFWm9uc1lNSVpqcGppTHFZNnkxYmlWNWxRQUFBQUFvcHJvdG9jb2xWZXJzaW9uAA=="

    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/broadcastStateTransition

Response: No response except on error

getIdentity

Returns: Identity information for the requested identity
Parameters:

NameTypeRequiredDescription
idBytesYesAn identity id
proveBooleanNoSet to true to receive a proof that contains the requested identity

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const Identifier = require('@dashevo/dpp/lib/Identifier');
const cbor = require('cbor');

const client = new DAPIClient();

const identityId = Identifier.from('BbSrAN8tKaoQgFxV9T1as8vKSTxRVYx5bWxDqJoVv5jQ');
client.platform.getIdentity(identityId).then((response) => {
  const identity = cbor.decode(response.identity);
  console.log(identity);
});
const {
  v0: {
    PlatformPromiseClient,
  },
} = require('@dashevo/dapi-grpc');
const Identifier = require('@dashevo/dpp/lib/Identifier');
const cbor = require('cbor');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const id = Identifier.from('BbSrAN8tKaoQgFxV9T1as8vKSTxRVYx5bWxDqJoVv5jQ');
const idBuffer = Buffer.from(id);
const getIdentityRequest = new GetIdentityRequest();
getIdentityRequest.setId(idBuffer);
getIdentityRequest.setProve(false);

platformPromiseClient.getIdentity(getIdentityRequest)
  .then((response) => {
    const identityResponse = response.getIdentity();
    const identityBuffer = Buffer.from(identityResponse);
    console.log(cbor.decode(identityBuffer));
  })
  .catch((e) => console.error(e));
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "id":"nWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITM="
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentity
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "id":"nWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITM=",
    "prove":true
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentity
{
  id: <Buffer 9d 67 d7 bf 13 95 1d 28 02 59 e6 48 2a e6 09 a7 b5 06 ce 1d eb 4f fa f2 8f 7f 0a 58 9f b3 21 33>,
  balance: 10996072,
  revision: 0,
  publicKeys: [
    {
      id: 0,
      data: <Buffer 03 17 4b f2 6e e7 cb 22 06 03 d6 3c a3 64 3d 2c 48 ff 69 43 1d ac c7 71 5b 2e b4 c1 e9 0d 3a 7e 49>,
      type: 0
    }
  ],
  protocolVersion: 0
}
{
  "identity": "pWJpZFggnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITNnYmFsYW5jZRoAp8loaHJldmlzaW9uAGpwdWJsaWNLZXlzgaNiaWQAZGRhdGFYIQMXS/Ju58siBgPWPKNkPSxI/2lDHazHcVsutMHpDTp+SWR0eXBlAG9wcm90b2NvbFZlcnNpb24A",
  "metadata": {
    "height": 115,
    "coreChainLockedHeight": 545261
  }
}
// The storeTreeProof contains the requested data
{
  "proof": {
    "rootTreeProof": "AQAAAAO/730XK2ZpQ8M/rke2FCWUEvUkNe3Zm7+TMURBHDrqtPcn5nTrzcUK8RoqqZvgwYyvERWIxOuojAWh9JxFPs4on5yLLeYx9zIJIAv5uUESaTlcLrm5kWqtzGcwvrp3rg4BAw==",
    "storeTreeProof": "AWyO60NAEaeZnR0hsk6K4NIzhxgC/SxLM4XGAGJpnptfAqshUDZ+353VykAJTytGq/tbOq3wOGwdkljpOZfB+6j/EAFKHml+7jyjG8o3OFVcNZkLd1ZGxu/vwiDRG4p0iXkVXgMgnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITMAjaViaWRYIJ1n178TlR0oAlnmSCrmCae1Bs4d60/68o9/ClifsyEzZ2JhbGFuY2UaAKfJaGhyZXZpc2lvbgBqcHVibGljS2V5c4GjYmlkAGRkYXRhWCEDF0vybufLIgYD1jyjZD0sSP9pQx2sx3FbLrTB6Q06fklkdHlwZQBvcHJvdG9jb2xWZXJzaW9uABABJwjSChrmnHIgWreCpNnrdgp5+5QBlr+oeoxemFrpoRcREQ==",
    "signatureLlmqHash": "AAAAU76r1uJML75iJSdN/Ev94VMJtsl4KH9m/ULmCII=",
    "signature": "lbOEbMLb2xr0Swq8k1yD2F2MOl8jwSH255O0ZNw2b3HEGv02j+zwE092pCzlJYNhBKk0orXtLSQwMHV51WQ/SKBQnYTlt4GAbyjall5fQJc5mzP5SVIx9MbBUEdwL8Jg"
  },
  "metadata": {
    "height": 116,
    "coreChainLockedHeight": 545262
  }
}

getIdentitiesByPublicKeyHashes

Returns: Identity information associated with the provided public key hashes
Parameters:

NameTypeRequiredDescription
public_key_hashesBytesYesPublic key hashes (double-sha256) of identity public keys
proveBooleanNoSet to true to receive a proof that contains the requested identities

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

📘

Public key hash

Note: the hash must be done using all fields of the identity public key object - e.g.

{
  id: 0,
  type: 0,
  data: 'A/Wmv+LhxAjSBE19d3OJCUawUiYORF5HDDetZbvTDgQQ'
}

When using the js-dpp library, the hash can be accessed via the IdentityPublicKey object's hash method (e.g. identity.getPublicKeyById(0).hash()).

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const DashPlatformProtocol = require('@dashevo/dpp');

const client = new DAPIClient();
const dpp = new DashPlatformProtocol();

const publicKeyHash = 'bfb0b2a54a8d020b6c68fa4e20cbedcafc8422e0';
const publicKeysBuffer = [Buffer.from(publicKeyHash, 'hex')];

dpp.initialize().then(() => {
  client.platform.getIdentitiesByPublicKeyHashes(publicKeysBuffer)
    .then((response) => {
      const retrievedIdentity = dpp.identity.createFromBuffer(response.identities[0]);
      console.log(retrievedIdentity.toJSON());
    });
});
const {
  v0: {
    PlatformPromiseClient,
    GetIdentitiesByPublicKeyHashesRequest,
  },
} = require('@dashevo/dapi-grpc');
const cbor = require('cbor');
const DashPlatformProtocol = require('@dashevo/dpp');

const dpp = new DashPlatformProtocol();

dpp.initialize()
  .then(() => {
    const platformPromiseClient = new PlatformPromiseClient(
      'http://seed-1.testnet.networks.dash.org:3010',
    );

    const publicKeyHash = 'bfb0b2a54a8d020b6c68fa4e20cbedcafc8422e0';
    const publicKeysBuffer = [Buffer.from(publicKeyHash, 'hex')];

    const getIdentitiesByPublicKeyHashesRequest = new GetIdentitiesByPublicKeyHashesRequest();
    getIdentitiesByPublicKeyHashesRequest.setPublicKeyHashesList(publicKeysBuffer);

    platformPromiseClient.getIdentitiesByPublicKeyHashes(getIdentitiesByPublicKeyHashesRequest)
      .then((response) => {
        const identitiesResponse = response.getIdentitiesList();
        const identities = identitiesResponse
          .map((identity) => (identity.length > 0 ? cbor.decode(Buffer.from(identity)) : null));
        console.log(dpp.identity.createFromObject(identities[0]).toJSON());
      })
      .catch((e) => console.error(e));
    });
# `public_key_hashes` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "public_key_hashes":"v7CypUqNAgtsaPpOIMvtyvyEIuA="
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentitiesByPublicKeyHashes
# `public_key_hashes` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "public_key_hashes":"v7CypUqNAgtsaPpOIMvtyvyEIuA=",
    "prove": true
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentitiesByPublicKeyHashes
{
  protocolVersion: 0,
  id: 'BbSrAN8tKaoQgFxV9T1as8vKSTxRVYx5bWxDqJoVv5jQ',
  publicKeys: [
    {
      id: 0,
      type: 0,
      data: 'AxdL8m7nyyIGA9Y8o2Q9LEj/aUMdrMdxWy60wekNOn5J'
    }
  ],
  balance: 10996072,
  revision: 0
}
{
  "identities": [
    "pWJpZFggnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITNnYmFsYW5jZRoAp8loaHJldmlzaW9uAGpwdWJsaWNLZXlzgaNiaWQAZGRhdGFYIQMXS/Ju58siBgPWPKNkPSxI/2lDHazHcVsutMHpDTp+SWR0eXBlAG9wcm90b2NvbFZlcnNpb24A"
  ],
  "metadata": {
    "height": 121,
    "coreChainLockedHeight": 545274
  }
}
// The storeTreeProof contains the requested data
{
  "proof": {
    "rootTreeProof": "AQAAAAO/730XK2ZpQ8M/rke2FCWUEvUkNe3Zm7+TMURBHDrqtPcn5nTrzcUK8RoqqZvgwYyvERWIxOuojAWh9JxFPs4on5yLLeYx9zIJIAv5uUESaTlcLrm5kWqtzGcwvrp3rg4BAw==",
    "storeTreeProof": "AWyO60NAEaeZnR0hsk6K4NIzhxgC/SxLM4XGAGJpnptfAqshUDZ+353VykAJTytGq/tbOq3wOGwdkljpOZfB+6j/EAFKHml+7jyjG8o3OFVcNZkLd1ZGxu/vwiDRG4p0iXkVXgMgnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITMAjaViaWRYIJ1n178TlR0oAlnmSCrmCae1Bs4d60/68o9/ClifsyEzZ2JhbGFuY2UaAKfJaGhyZXZpc2lvbgBqcHVibGljS2V5c4GjYmlkAGRkYXRhWCEDF0vybufLIgYD1jyjZD0sSP9pQx2sx3FbLrTB6Q06fklkdHlwZQBvcHJvdG9jb2xWZXJzaW9uABABJwjSChrmnHIgWreCpNnrdgp5+5QBlr+oeoxemFrpoRcREQ==",
    "signatureLlmqHash": "AAAAU76r1uJML75iJSdN/Ev94VMJtsl4KH9m/ULmCII=",
    "signature": "CWqlvjvKTbQIeVPElzK2aOoktOzN2CHOjIXb8JH6HhwtdmtuD5ePY60B9GO8OGwdDjj03Cy6pEa0xksdrWWfDgRVZLFKWPXLGWqldUdJDtAMmhVFk4LaDk5JnaA7fB3f"
  },
  "metadata": {
    "height": 121,
    "coreChainLockedHeight": 545274
  }
}

getIdentityIdsByPublicKeyHashes

Returns: Identity ID(s) associated with the provided public key hashes
Parameters:

NameTypeRequiredDescription
public_key_hashesBytesYesPublic key hash (double-sha256) of an identity's public key
proveBooleanNoSet to true to receive a proof that contains the requested identity IDs

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

📘

Public key hash

Note: the hash must be done using all fields of the identity public key object - e.g.

{
  id: 0,
  type: 0,
  data: 'A/Wmv+LhxAjSBE19d3OJCUawUiYORF5HDDetZbvTDgQQ'
}

When using the js-dpp library, the hash can be accessed via the IdentityPublicKey object's hash method (e.g. identity.getPublicKeyById(0).hash()).

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const Identifier = require('@dashevo/dpp/lib/Identifier');

const client = new DAPIClient();

// Get identity from hex public key hash
const publicKeyHash = 'bfb0b2a54a8d020b6c68fa4e20cbedcafc8422e0';
const publicKeysBuffer = [Buffer.from(publicKeyHash, 'hex')];

client.platform.getIdentityIdsByPublicKeyHashes(publicKeysBuffer)
  .then((response) => {
    for (const r of response) {
      console.log(`Identity ID: ${Identifier.from(r).toString()}`);
    }
  });
const {
  v0: {
    PlatformPromiseClient,
    GetIdentityIdsByPublicKeyHashesRequest,
  },
} = require('@dashevo/dapi-grpc');
const Identifier = require('@dashevo/dpp/lib/Identifier');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const publicKeyHash = 'bfb0b2a54a8d020b6c68fa4e20cbedcafc8422e0';
const publicKeysBuffer = [Buffer.from(publicKeyHash, 'hex')];

const getIdentityIdsByPublicKeyHashesRequest = new GetIdentityIdsByPublicKeyHashesRequest();
getIdentityIdsByPublicKeyHashesRequest.setPublicKeyHashesList(publicKeysBuffer);

platformPromiseClient.getIdentityIdsByPublicKeyHashes(getIdentityIdsByPublicKeyHashesRequest)
  .then((response) => {
    for (const r of response.getIdentityIdsList()) {
      const id = Buffer.from(r);
      console.log(`Identity ID: ${Identifier.from(id).toString()}`);
    }
  })
  .catch((e) => console.error(e));
# `public_key_hashes` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "public_key_hashes":"v7CypUqNAgtsaPpOIMvtyvyEIuA="
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentityIdsByPublicKeyHashes
# `public_key_hashes` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "public_key_hashes":"v7CypUqNAgtsaPpOIMvtyvyEIuA=",
    "prove": true
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getIdentityIdsByPublicKeyHashes
Identity ID: BbSrAN8tKaoQgFxV9T1as8vKSTxRVYx5bWxDqJoVv5jQ
{
  "identityIds": [
    "nWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITM="
  ],
  "metadata": {
    "height": 126,
    "coreChainLockedHeight": 545280
  }
}
// The storeTreeProof contains the requested data
{
  "proof": {
    "rootTreeProof": "AQAAAAPx389OUoMhPwNQz096/f4Ng4i2iIG260YscRpZcUMmKR7NvS3i3YD4jguNQuAcb+uPhaG29YHrd2EG45KSLM8Tn5yLLeYx9zIJIAv5uUESaTlcLrm5kWqtzGcwvrp3rg4BBQ==",
    "storeTreeProof": "ATeFN5n8xiKvWvMdvzysqD5u3DkaJAPvATjxds7IrqGlAo4LrtGX49t4RVNwm0NwwqysyHYeIke8adCFBPWk5squEAMUh1EY/fMYJqrQ3x52Svn/D0nJ/1IAIIUxI566SJ8tHo+d5bbQBlOESYAZy+tdC39j2P85E22uAxS/sLKlSo0CC2xo+k4gy+3K/IQi4AAgnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITMQAQJ61gkGg2cKVHGmUNUFZ04yHdDjj89QyjTdejs9b1pJERE=",
    "signatureLlmqHash": "AAAAABuz53KkQFcbIKei9yoOTb6Nj1/skLoLHj3T+Lc=",
    "signature": "Dm3nKYPP3trGIodvTgzm74qJk/NyGUOHQJrgJYW3z93NH0sRkil9U7y0dbQ8bJImBn/qMbpoqq9eIikYk/RV3MjX22GIf+b/ItSH/XQ6DaKce/B69sGTeFW1MmvPiUNX"
  },
  "metadata": {
    "height": 126,
    "coreChainLockedHeight": 545280
  }
}

getDataContract

Returns: Data Contract information for the requested data contract
Parameters:

NameTypeRequiredDescription
idBytesYesA data contract id
proveBooleanNoSet to true to receive a proof that contains the requested data contract

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const Identifier = require('@dashevo/dpp/lib/Identifier');
const cbor = require('cbor');

const client = new DAPIClient();

const contractId = Identifier.from('2aSUdJhasGANowpgjxARDY8N94dJYQNmp7VbH2WEXkmj');
client.platform.getDataContract(contractId).then((response) => {
  const contract = cbor.decode(response.dataContract);
  console.dir(contract, { depth: 10 });
});
const {
  v0: {
    PlatformPromiseClient,
    GetDataContractRequest,
  },
} = require('@dashevo/dapi-grpc');
const Identifier = require('@dashevo/dpp/lib/Identifier');
const cbor = require('cbor');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const contractId = Identifier.from('2aSUdJhasGANowpgjxARDY8N94dJYQNmp7VbH2WEXkmj');
const contractIdBuffer = Buffer.from(contractId);
const getDataContractRequest = new GetDataContractRequest();
getDataContractRequest.setId(contractIdBuffer);

platformPromiseClient.getDataContract(getDataContractRequest)
  .then((response) => {
    const contractResponse = response.getDataContract();
    const contractBuffer = Buffer.from(contractResponse);
    console.dir(cbor.decode(contractBuffer), { depth: 5 });
  })
  .catch((e) => console.error(e));
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "id":"F2yo52VQu4BQJomGoOrPEyrPVkOifemB5Eswr1oCRQ4="
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getDataContract
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "id":"F2yo52VQu4BQJomGoOrPEyrPVkOifemB5Eswr1oCRQ4=",
    "prove":true
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getDataContract
{
  '$id': Buffer(32) [Uint8Array] [
     23, 108, 168, 231, 101,  80, 187, 128,
     80,  38, 137, 134, 160, 234, 207,  19,
     42, 207,  86,  67, 162, 125, 233, 129,
    228,  75,  48, 175,  90,   2,  69,  14
  ],
  '$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
  ownerId: Buffer(32) [Uint8Array] [
    157, 103, 215, 191,  19, 149,  29,  40,
      2,  89, 230,  72,  42, 230,   9, 167,
    181,   6, 206,  29, 235,  79, 250, 242,
    143, 127,  10,  88, 159, 179,  33,  51
  ],
  documents: {
    note: {
      type: 'object',
      properties: { message: { type: 'string' } },
      additionalProperties: false
    }
  },
  protocolVersion: 0
}
{
  "dataContract": "pWMkaWRYIBdsqOdlULuAUCaJhqDqzxMqz1ZDon3pgeRLMK9aAkUOZyRzY2hlbWF4NGh0dHBzOi8vc2NoZW1hLmRhc2gub3JnL2RwcC0wLTQtMC9tZXRhL2RhdGEtY29udHJhY3Rnb3duZXJJZFggnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITNpZG9jdW1lbnRzoWRub3Rlo2R0eXBlZm9iamVjdGpwcm9wZXJ0aWVzoWdtZXNzYWdloWR0eXBlZnN0cmluZ3RhZGRpdGlvbmFsUHJvcGVydGllc/RvcHJvdG9jb2xWZXJzaW9uAA==",
  "metadata": {
    "height": 129,
    "coreChainLockedHeight": 545286
  }
}
// The storeTreeProof contains the requested data
{
  "proof": {
    "rootTreeProof": "AQAAAAMue8f0VKLw60DfGDnhpCHhLJj5g7fILfFlHx0Uvb7i8B7NvS3i3YD4jguNQuAcb+uPhaG29YHrd2EG45KSLM8Tn5yLLeYx9zIJIAv5uUESaTlcLrm5kWqtzGcwvrp3rg4BAQ==",
    "storeTreeProof": "AyAXbKjnZVC7gFAmiYag6s8TKs9WQ6J96YHkSzCvWgJFDgD0pWMkaWRYIBdsqOdlULuAUCaJhqDqzxMqz1ZDon3pgeRLMK9aAkUOZyRzY2hlbWF4NGh0dHBzOi8vc2NoZW1hLmRhc2gub3JnL2RwcC0wLTQtMC9tZXRhL2RhdGEtY29udHJhY3Rnb3duZXJJZFggnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITNpZG9jdW1lbnRzoWRub3Rlo2R0eXBlZm9iamVjdGpwcm9wZXJ0aWVzoWdtZXNzYWdloWR0eXBlZnN0cmluZ3RhZGRpdGlvbmFsUHJvcGVydGllc/RvcHJvdG9jb2xWZXJzaW9uAAKebAzm7RJJgwTqwNdlS3NJee8Xt5BYqDoWBIf3sSWG1BACRMS8jo36RpN7TSh79+gQL+UYqhYT7Waqmrb6cuysD4cQAQqdbDdz4OKqh5J81U6ndGXvGUb0V3NkxHagzQ7Vcb7GEQ==",
    "signatureLlmqHash": "AAAAABuz53KkQFcbIKei9yoOTb6Nj1/skLoLHj3T+Lc=",
    "signature": "hy3QXOZ+pcUbqL1wjGtLeFF8wTgTr0/locJKH4ITLvU9y5dh9l6Kllj21rmpGUHCEuqc6hvni7uWHSwZCo914agNFStRFmJIQxdb37oTIXvo6JFg4dOgXpJe/s+EfwLD"
  },
  "metadata": {
    "height": 130,
    "coreChainLockedHeight": 545289
  }
}

getDocuments

Returns: Document information for the requested document(s)
Parameters:

🚧
  • Parameter constraints

The where, order_by, limit, start_at, and start_after parameters must comply with the limits defined on the Query Syntax page.

Additionally, note that where and order_by must be CBOR encoded.

NameTypeRequiredDescription
data_contract_idBytesYesA data contract id
document_typeStringYesA document type defined by the data contract (e.g. preorder or domain for the DPNS contract)
where *BytesNoWhere clause to filter the results (must be CBOR encoded)
order_by *BytesNoSort records by the field(s) provided (must be CBOR encoded)
limitIntegerNoMaximum number of results to return
----------
One of the following:
start_atIntegerNoReturn records beginning with the index provided
start_afterIntegerNoReturn records beginning after the index provided
----------
proveBooleanNoSet to true to receive a proof that contains the requested document(s)

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const Identifier = require('@dashevo/dpp/lib/Identifier');
const cbor = require('cbor');

const client = new DAPIClient();

const contractId = Identifier.from('2aSUdJhasGANowpgjxARDY8N94dJYQNmp7VbH2WEXkmj');
client.platform.getDocuments(contractId, 'note', { limit: 10 }).then((response) => {
  for (const rawData of response) {
    console.log(cbor.decode(rawData));
  }
});
const {
  v0: {
    PlatformPromiseClient,
    GetDocumentsRequest,
  },
} = require('@dashevo/dapi-grpc');
const cbor = require('cbor');
const Identifier = require('@dashevo/dpp/lib/Identifier');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const contractId = Identifier.from('2aSUdJhasGANowpgjxARDY8N94dJYQNmp7VbH2WEXkmj');
const contractIdBuffer = Buffer.from(contractId);
const getDocumentsRequest = new GetDocumentsRequest();
const type = 'note';
const limit = 10;

getDocumentsRequest.setDataContractId(contractIdBuffer);
getDocumentsRequest.setDocumentType(type);
// getDocumentsRequest.setWhere(whereSerialized);
// getDocumentsRequest.setOrderBy(orderBySerialized);
getDocumentsRequest.setLimit(limit);
// getDocumentsRequest.setStartAfter(startAfter);
// getDocumentsRequest.setStartAt(startAt);

platformPromiseClient.getDocuments(getDocumentsRequest)
  .then((response) => {
    for (const document of response.getDocumentsList()) {
      console.log(cbor.decode(Buffer.from(document)));
    }
  })
  .catch((e) => console.error(e));
# Request one DPNS document
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "data_contract_id":"F2yo52VQu4BQJomGoOrPEyrPVkOifemB5Eswr1oCRQ4=",
    "document_type":"note",
    "limit":10
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getDocuments
# Request one DPNS document
# `id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "data_contract_id":"F2yo52VQu4BQJomGoOrPEyrPVkOifemB5Eswr1oCRQ4=",
    "document_type":"note",
    "limit":10,
    "prove":true
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/getDocuments
{
  '$id': <Buffer 3c a1 b4 cc cf 7a cd c2 d5 a6 d5 3a 3b 69 66 ad 75 c6 24 d0 45 05 aa e6 22 8e f5 83 25 9f 0a d7>,
  '$type': 'note',
  message: 'Tutorial CI Test @ Tue, 27 Jul 2021 13:06:35 GMT',
  '$ownerId': <Buffer 9d 67 d7 bf 13 95 1d 28 02 59 e6 48 2a e6 09 a7 b5 06 ce 1d eb 4f fa f2 8f 7f 0a 58 9f b3 21 33>,
  '$revision': 1,
  '$dataContractId': <Buffer 17 6c a8 e7 65 50 bb 80 50 26 89 86 a0 ea cf 13 2a cf 56 43 a2 7d e9 81 e4 4b 30 af 5a 02 45 0e>,
  '$protocolVersion': 0
}
{
  "documents": [
    "p2MkaWRYIDyhtMzPes3C1abVOjtpZq11xiTQRQWq5iKO9YMlnwrXZSR0eXBlZG5vdGVnbWVzc2FnZXgwVHV0b3JpYWwgQ0kgVGVzdCBAIFR1ZSwgMjcgSnVsIDIwMjEgMTM6MDY6MzUgR01UaCRvd25lcklkWCCdZ9e/E5UdKAJZ5kgq5gmntQbOHetP+vKPfwpYn7MhM2kkcmV2aXNpb24BbyRkYXRhQ29udHJhY3RJZFggF2yo52VQu4BQJomGoOrPEyrPVkOifemB5Eswr1oCRQ5wJHByb3RvY29sVmVyc2lvbgA="
  ],
  "metadata": {
    "height": 132,
    "coreChainLockedHeight": 545298
  }
}
// The storeTreeProof contains the requested data
{
  "proof": {
    "rootTreeProof": "AQAAAAI3K3b38xhhvsh49mtplZhoX9g81EXJEjxwHeuku+QsJdUkWafhJfD3uDjsl+ZmSHUDrjn7xwbwAozYDr1Uv6b4AQI=",
    "storeTreeProof": "AXNwJkbsrxIoxhurh+nOi7+LkOqQidT6rmHnqJqr0KfkAin9QcwUR4nCi2beKYCsCrARr2lAa2YnJY2BJu2lM2MbEAEraKbQuKTiu9dsfWhOKKFL3+XuAOO4s8EMWSMItNzOsQMgPKG0zM96zcLVptU6O2lmrXXGJNBFBarmIo71gyWfCtcA5qdjJGlkWCA8obTMz3rNwtWm1To7aWatdcYk0EUFquYijvWDJZ8K12UkdHlwZWRub3RlZ21lc3NhZ2V4MFR1dG9yaWFsIENJIFRlc3QgQCBUdWUsIDI3IEp1bCAyMDIxIDEzOjA2OjM1IEdNVGgkb3duZXJJZFggnWfXvxOVHSgCWeZIKuYJp7UGzh3rT/ryj38KWJ+zITNpJHJldmlzaW9uAW8kZGF0YUNvbnRyYWN0SWRYIBdsqOdlULuAUCaJhqDqzxMqz1ZDon3pgeRLMK9aAkUOcCRwcm90b2NvbFZlcnNpb24AEAF05KHTyyYguECyveRfD5nB+umrpuE+NUtdZ+bLsim0VRERAsf6E4Sx5AJ0bCpD6L4YbAeocPL1FqWExMMpKk/LYiYrEAFWv4FD9lfbosegLN5/13ajFH2I7XJ9gD2r3kx8KKRyMBE=",
    "signatureLlmqHash": "AAAAABuz53KkQFcbIKei9yoOTb6Nj1/skLoLHj3T+Lc=",
    "signature": "iHkJflUfSQ98L6gPVFu03s+ZuMM6L4VXgFs6KifrkLLFAhYPI8goe63AZKiePCoTDv/aaEr0oWTQT53WNrRuEabI0ABn8KZE4BndkTTn0FmIgQ7T6eg+pqFuTtrptBqM"
  },
  "metadata": {
    "height": 132,
    "coreChainLockedHeight": 545298
  }
}

waitForStateTransitionResult

👍

Added in Dash Platform 0.18.0

Returns: The state transition hash and either a proof that the state transition was confirmed in a block or an error.
Parameters:

NameTypeRequiredDescription
state_transition_hashBytesYesHash of the state transition
proveBooleanYesSet to true to request a proof

🚧

Note: When requesting proofs, the data requested will be encoded as part of the proof in the response. See the Platform Proofs page for details on decoding the data.

Example Request and Response

const DAPIClient = require('@dashevo/dapi-client');
const DashPlatformProtocol = require('@dashevo/dpp');
const crypto = require('crypto');

const client = new DAPIClient();
const dpp = new DashPlatformProtocol();

const stateTransitionObject = {
  protocolVersion: 0,
  type: 0,
  signature: 'HxAipUsLWQBE++C1suSRNQiQh91rI1LZbblvQhk2erUaIvRneAagxGYYsXXYNvEeO+lBzlF1a9KHGGTHgnO/8Ts=',
  signaturePublicKeyId: 0,
  dataContract: {
    protocolVersion: 0,
    '$id': 'CMc7RghKkHeHtFdwfSX5Hzy7CUdpCEJnwsbfHdsbmJ32',
    '$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
    ownerId: '8Z3ps3tNoGoPEDYerUNCd4yi7zDwgBh2ejgSMExxvkfD',
    documents: {
      note: {
        properties: { message: { type: 'string' } },
        additionalProperties: false,
      },
    },
  },
  entropy: '+RqUArypdL8f/gCMAo4b6c3CoQvxHzsQG0BdYrT5QT0=',
};

// Convert signature and entropy to buffer
stateTransitionObject.signature = Buffer.from(stateTransitionObject.signature, 'base64');
stateTransitionObject.entropy = Buffer.from(stateTransitionObject.entropy, 'base64');

dpp.stateTransition.createFromObject(stateTransitionObject, { skipValidation: true })
  .then((stateTransition) => {
    //  Calculate state transition hash
    const hash = crypto.createHash('sha256')
      .update(stateTransition.toBuffer())
      .digest();

    console.log(`Requesting proof of state transition with hash:\n\t${hash.toString('hex')}`);

    client.platform.waitForStateTransitionResult(hash, { prove: true })
      .then((response) => {
        console.log(response);
      });
  });
const {
  v0: {
    PlatformPromiseClient,
    WaitForStateTransitionResultRequest,
  },
} = require('@dashevo/dapi-grpc');
const DashPlatformProtocol = require('@dashevo/dpp');
const crypto = require('crypto');

const platformPromiseClient = new PlatformPromiseClient(
  'http://seed-1.testnet.networks.dash.org:3010',
);

const dpp = new DashPlatformProtocol();

const stateTransitionObject = {
  protocolVersion: 0,
  type: 0,
  signature: 'HxAipUsLWQBE++C1suSRNQiQh91rI1LZbblvQhk2erUaIvRneAagxGYYsXXYNvEeO+lBzlF1a9KHGGTHgnO/8Ts=',
  signaturePublicKeyId: 0,
  dataContract: {
    protocolVersion: 0,
    '$id': 'CMc7RghKkHeHtFdwfSX5Hzy7CUdpCEJnwsbfHdsbmJ32',
    '$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
    ownerId: '8Z3ps3tNoGoPEDYerUNCd4yi7zDwgBh2ejgSMExxvkfD',
    documents: {
      note: {
        properties: { message: { type: 'string' } },
        additionalProperties: false,
      },
    },
  },
  entropy: '+RqUArypdL8f/gCMAo4b6c3CoQvxHzsQG0BdYrT5QT0=',
};

// Convert signature and entropy to buffer
stateTransitionObject.signature = Buffer.from(stateTransitionObject.signature, 'base64');
stateTransitionObject.entropy = Buffer.from(stateTransitionObject.entropy, 'base64');

dpp.stateTransition.createFromObject(stateTransitionObject, { skipValidation: true })
  .then((stateTransition) => {
    //  Calculate state transition hash
    const hash = crypto.createHash('sha256')
      .update(stateTransition.toBuffer())
      .digest();

    const waitForStateTransitionResultRequest = new WaitForStateTransitionResultRequest();
    waitForStateTransitionResultRequest.setStateTransitionHash(hash);
    waitForStateTransitionResultRequest.setProve(true);

    console.log(`Requesting proof of state transition with hash:\n\t${hash.toString('hex')}`);

    platformPromiseClient.waitForStateTransitionResult(waitForStateTransitionResultRequest)
      .then((response) => {
        const rootTreeProof = Buffer.from(response.getProof().getRootTreeProof());
        const storeTreeProof = Buffer.from(response.getProof().getStoreTreeProof());
        console.log(`Root tree proof: ${rootTreeProof.toString('hex')}`);
        console.log(`Store tree proof: ${storeTreeProof.toString('hex')}`);
      })
        .catch((e) => console.error(e));
  });
# `state_transition_hash` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto -plaintext \
  -d '{
    "state_transition_hash":"iuk7icJyRV886NAdupmjooyVUCYqYCxrpE3gjlRdOqk=",
    "prove": "true"
    }' \
  seed-1.testnet.networks.dash.org:3010 \
  org.dash.platform.dapi.v0.Platform/waitForStateTransitionResult
{
  proof: {
    rootTreeProof: <Buffer 01 00 00 00 03 26 e0 35 e0 31 82 7e 7c 27 b0 91 23 41 ed d2 11 bf 3b 90 54 70 11 2c 68 5a 8e 76 8c 68 bb 39 21 3d cf 46 6d 09 d0 7a 28 e3 e9 0b 2b 0e ... 17 more bytes>,
    storeTreeProof: <Buffer 01 0b ee 31 ce ca 2a bd 44 6a db d4 9f 13 4a 7d 70 25 96 a9 b9 02 6e c4 e1 90 95 f7 a1 b4 c9 de 1f e4 63 e6 ce f7 58 3a 5b c3 10 01 78 9b 4f 98 9a c9 ... 526 more bytes>
  }
}
Requesting proof of state transition with hash:
        8ae93b89c272455f3ce8d01dba99a3a28c9550262a602c6ba44de08e545d3aa9
Root tree proof: 010000000326e035e031827e7c27b0912341edd211bf3b905470112c685a8e768c68bb39213dcf466d09d07a28e3e90b2b0e1d1510dede30214f68e32f8cf498220101
Store tree proof: 010bee31ceca2abd446adbd49f134a7d702596a9b9026ec4e19095f7a1b4c9de1fe463e6cef7583a5bc31001789b4f989ac9f8f524f1247fed372502d8c54a3c026072d5239f074422621673c250d1c74eadbb304a10013fb54a99ef641b9a7585d6d28dd443875e435a35022d92a0711f56ae23bc13f4a630a1455970451e3f1001fe2b060fca69ce2eb3d784cec28c0f575690f131026df252af068635bdf08f5448ea67c23d9a9a02831001a7df0a9f392682d7d7d0a29bd43d932c16b0d6530320a8b7df4cadb6cdfd5b5d1bb31cbb488d241e91d60cc1341cd686a3fbb6291f19e800a5632469645820a8b7df4cadb6cdfd5b5d1bb31cbb488d241e91d60cc1341cd686a3fbb6291f196724736368656d61783468747470733a2f2f736368656d612e646173682e6f72672f6470702d302d342d302f6d6574612f646174612d636f6e7472616374676f776e657249645820703796bfd3e2bbd54505a8e04929bb05b8aecfb1cd5c013ef8a8b84511770e0c69646f63756d656e7473a1646e6f7465a26a70726f70657274696573a1676d657373616765a1647479706566737472696e67746164646974696f6e616c50726f70657274696573f46f70726f746f636f6c56657273696f6e001001d94cd40044b8485e962d80e57c1992c77a182a1611111102abe7e3f7231ed71b8c4fd7ee09d4a1f970a51cd4100139312feadce145313ef34f720e940892d0ed2405111102245c6aaaf192b51207333be85ab77c9c9393af47100128ef7d4479e4f488373d92280fe8e52a9a48a6621111
{
  "proof": {
    "rootTreeProof": "AQAAAAMm4DXgMYJ+fCewkSNB7dIRvzuQVHARLGhajnaMaLs5IT3PRm0J0Hoo4+kLKw4dFRDe3jAhT2jjL4z0mCIBAQ==",
    "storeTreeProof": "AQvuMc7KKr1EatvUnxNKfXAllqm5Am7E4ZCV96G0yd4f5GPmzvdYOlvDEAF4m0+Ymsn49STxJH/tNyUC2MVKPAJgctUjnwdEImIWc8JQ0cdOrbswShABP7VKme9kG5p1hdbSjdRDh15DWjUCLZKgcR9WriO8E/SmMKFFWXBFHj8QAf4rBg/Kac4us9eEzsKMD1dWkPExAm3yUq8GhjW98I9USOpnwj2amgKDEAGn3wqfOSaC19fQopvUPZMsFrDWUwMgqLffTK22zf1bXRuzHLtIjSQekdYMwTQc1oaj+7YpHxnoAKVjJGlkWCCot99MrbbN/VtdG7Mcu0iNJB6R1gzBNBzWhqP7tikfGWckc2NoZW1heDRodHRwczovL3NjaGVtYS5kYXNoLm9yZy9kcHAtMC00LTAvbWV0YS9kYXRhLWNvbnRyYWN0Z293bmVySWRYIHA3lr/T4rvVRQWo4EkpuwW4rs+xzVwBPviouEURdw4MaWRvY3VtZW50c6Fkbm90ZaJqcHJvcGVydGllc6FnbWVzc2FnZaFkdHlwZWZzdHJpbmd0YWRkaXRpb25hbFByb3BlcnRpZXP0b3Byb3RvY29sVmVyc2lvbgAQAdlM1ABEuEheli2A5XwZksd6GCoWERERAqvn4/cjHtcbjE/X7gnUoflwpRzUEAE5MS/q3OFFMT7zT3IOlAiS0O0kBRERAiRcaqrxkrUSBzM76Fq3fJyTk69HEAEo731EeeT0iDc9kigP6OUqmkimYhER"
  }
}

Deprecated Endpoints

There are no recently deprecated endpoint, but the previous version of documentation can be viewed here.

Code Reference

Implementation details related to the information on this page can be found in:


Did this page help you?