Platform Endpoints
Detailed platform gRPC endpoint reference
gRPC Overview
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
broadcastStateTransition
New in Dash Platform v0.15.0
Previously named
applyStateTransition
Broadcasts a state transition to the platform via DAPI to make a change to layer 2 data.
Returns: Nothing or error
Parameters:
Name | Type | Required | Description |
---|---|---|---|
state_transition | Bytes | Yes | A state transition |
Example Request and Response
# 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.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/broadcastStateTransition
const {
v0: {
PlatformPromiseClient,
BroadcastStateTransitionRequest,
},
} = require('@dashevo/dapi-grpc');
const DashPlatformProtocol = require('@dashevo/dpp');
const platformPromiseClient = new PlatformPromiseClient(
'http://seed-1.evonet.networks.dash.org:3010',
);
const dpp = new DashPlatformProtocol();
// Data Contract Create State Transition (JSON)
const stateTransitionObject = {
protocolVersion: 0,
type: 0,
signature: 'IAp3sn0tLA2FyxsWbEgrgIrjpNig0VdlgVHrBFiHtTvrAU7d7kkpQ0mUdK8PhMZjOKaepVOPRTDQgnHfVZ6HESA=',
signaturePublicKeyId: 0,
dataContract: {
protocolVersion: 0,
'$id': 'HvjAUGUHuVBWP7vXEWWmBSb4mTCoquhxenbziyGM14aF',
'$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
ownerId: '7NUbPf231ixt1kVBQsBvSMMBxd7AgPad8KtdtfFGhXDP',
documents: {
note: {
properties: { message: { type: 'string' } },
additionalProperties: false
}
}
},
entropy: 'XyuDb+YebayRZT4vxQQnzP7htozTXYEHRnBFL9KQjDg='
};
// 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));
Response: No response except on error
getIdentity
Returns: Identity information for the requested identity
Parameters:
Name | Type | Required | Description |
---|---|---|---|
id | Bytes | Yes | An identity id |
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('BhC9M3fQHyUCyuxH4WHdhn1VGgJ4JTLmer8qmTTHkYTe');
client.platform.getIdentity(identityId).then((response) => {
const identity = cbor.decode(response);
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.evonet.networks.dash.org:3010',
);
const id = Identifier.from('BhC9M3fQHyUCyuxH4WHdhn1VGgJ4JTLmer8qmTTHkYTe');
const idBuffer = Buffer.from(id);
const getIdentityRequest = new GetIdentityRequest();
getIdentityRequest.setId(idBuffer);
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":"nuCzumg/s5LC1SplgbztDxV9AfZBr1wNklM4zK8xZ90="
}' \
seed-1.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/getIdentity
{
id: <Buffer 9e e0 b3 ba 68 3f b3 92 c2 d5 2a 65 81 bc ed 0f 15 7d 01 f6 41 af 5c 0d 92 53 38 cc af 31 67 dd>,
balance: 10994307,
revision: 0,
publicKeys: [
{
id: 0,
data: <Buffer 03 f5 a6 bf e2 e1 c4 08 d2 04 4d 7d 77 73 89 09 46 b0 52 26 0e 44 5e 47 0c 37 ad 65 bb d3 0e 04 10>,
type: 0
}
],
protocolVersion: 0
}
{
"identity": "pWJpZFggnuCzumg/s5LC1SplgbztDxV9AfZBr1wNklM4zK8xZ91nYmFsYW5jZRoAp7gPaHJldmlzaW9uAGpwdWJsaWNLZXlzgaNiaWQAZGRhdGFYIQP1pr/i4cQI0gRNfXdziQlGsFImDkReRww3rWW70w4EEGR0eXBlAG9wcm90b2NvbFZlcnNpb24A"
}
getIdentitiesByPublicKeyHashes
Returns: Identity information associated with the provided public key hashes
Parameters:
Name | Type | Required | Description |
---|---|---|---|
public_key_hashes | Bytes | Yes | Public key hashes (double-sha256) of identity public keys |
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 = '2251b999499564dba481e36e0bfeeacfe5aa582e';
const publicKeysBuffer = [Buffer.from(publicKeyHash, 'hex')];
client.platform.getIdentitiesByPublicKeyHashes(publicKeysBuffer)
.then((response) => {
const retrievedIdentity = dpp.identity.createFromBuffer(response[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();
const platformPromiseClient = new PlatformPromiseClient(
'http://seed.evonet.networks.dash.org:3010',
);
const publicKeyHash = '2251b999499564dba481e36e0bfeeacfe5aa582e';
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":"IlG5mUmVZNukgeNuC/7qz+WqWC4="
}' \
seed-1.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/getIdentitiesByPublicKeyHashes
{
protocolVersion: 0,
id: 'BhC9M3fQHyUCyuxH4WHdhn1VGgJ4JTLmer8qmTTHkYTe',
publicKeys: [
{
id: 0,
type: 0,
data: 'A/Wmv+LhxAjSBE19d3OJCUawUiYORF5HDDetZbvTDgQQ'
}
],
balance: 10991631,
revision: 0
}
{
"identities": [
"pWJpZFggnuCzumg/s5LC1SplgbztDxV9AfZBr1wNklM4zK8xZ91nYmFsYW5jZRoAp7gPaHJldmlzaW9uAGpwdWJsaWNLZXlzgaNiaWQAZGRhdGFYIQP1pr/i4cQI0gRNfXdziQlGsFImDkReRww3rWW70w4EEGR0eXBlAG9wcm90b2NvbFZlcnNpb24A"
]
}
getIdentityIdsByPublicKeyHashes
Returns: Identity ID(s) associated with the provided public key hashes
Parameters:
Name | Type | Required | Description |
---|---|---|---|
public_key_hashes | Bytes | Yes | Public key hash (double-sha256) of an identity's public key |
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 = '2251b999499564dba481e36e0bfeeacfe5aa582e';
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.evonet.networks.dash.org:3010',
);
const publicKeyHash = '2251b999499564dba481e36e0bfeeacfe5aa582e';
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":"IlG5mUmVZNukgeNuC/7qz+WqWC4="
}' \
seed-1.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/getIdentityIdsByPublicKeyHashes
Identity ID: BhC9M3fQHyUCyuxH4WHdhn1VGgJ4JTLmer8qmTTHkYTe
{
"identityIds": [
"nuCzumg/s5LC1SplgbztDxV9AfZBr1wNklM4zK8xZ90="
]
}
getDataContract
Returns: Data Contract information for the requested data contract
Parameters:
Name | Type | Required | Description |
---|---|---|---|
id | Bytes | Yes | A data contract id |
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('Q894cs83D8REQNo7mAetj1wPJK2W3svrwqaN61aP25W');
client.platform.getDataContract(contractId).then((response) => {
const contract = cbor.decode(response);
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.evonet.networks.dash.org:3010',
);
const contractId = Identifier.from('Q894cs83D8REQNo7mAetj1wPJK2W3svrwqaN61aP25W');
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":"BexuQvZ7zeNK51eNqJDUMOCGHzPC+wfHrnqjqsg/CWk="
}' \
seed-1.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/getDataContract
{
'$id': Buffer(32) [Uint8Array] [
5, 236, 110, 66, 246, 123, 205, 227,
74, 231, 87, 141, 168, 144, 212, 48,
224, 134, 31, 51, 194, 251, 7, 199,
174, 122, 163, 170, 200, 63, 9, 105
],
'$schema': 'https://schema.dash.org/dpp-0-4-0/meta/data-contract',
ownerId: Buffer(32) [Uint8Array] [
158, 224, 179, 186, 104, 63, 179, 146,
194, 213, 42, 101, 129, 188, 237, 15,
21, 125, 1, 246, 65, 175, 92, 13,
146, 83, 56, 204, 175, 49, 103, 221
],
documents: {
note: {
properties: { message: { type: 'string' } },
additionalProperties: false
}
},
protocolVersion: 0
}
{
"dataContract": "pWMkaWRYIAXsbkL2e83jSudXjaiQ1DDghh8zwvsHx656o6rIPwlpZyRzY2hlbWF4NGh0dHBzOi8vc2NoZW1hLmRhc2gub3JnL2RwcC0wLTQtMC9tZXRhL2RhdGEtY29udHJhY3Rnb3duZXJJZFggnuCzumg/s5LC1SplgbztDxV9AfZBr1wNklM4zK8xZ91pZG9jdW1lbnRzoWRub3Rlompwcm9wZXJ0aWVzoWdtZXNzYWdloWR0eXBlZnN0cmluZ3RhZGRpdGlvbmFsUHJvcGVydGllc/RvcHJvdG9jb2xWZXJzaW9uAA=="
}
getDocuments
Returns: Document information for the requested document(s)
Parameters:
Name | Type | Required | Description |
---|---|---|---|
data_contract_id | Bytes | Yes | A data contract id |
document_type | String | Yes | A document type defined by the data contract (e.g. preorder or domain for the DPNS contract) |
where * | Bytes | No | Where clause to filter the results (must be CBOR encoded) |
order_by * | Bytes | No | Sort records by the field(s) provided (must be CBOR encoded) |
limit | Integer | No | Maximum number of results to return |
---------- | |||
One of the following: | |||
start_at | Integer | No | Return records beginning with the index provided |
start_after | Integer | No | Return records beginning after the index provided |
- Parameter constraints
The
where
,order_by
,limit
,start_at
, andstart_after
parameters must comply with the limits defined on the Query Syntax page.Additionally, note that
where
andorder_by
must be CBOR encoded.
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('Q894cs83D8REQNo7mAetj1wPJK2W3svrwqaN61aP25W');
client.platform.getDocuments(contractId, 'note', { limit: 1 }).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.evonet.networks.dash.org:3010',
);
const contractId = Identifier.from('Q894cs83D8REQNo7mAetj1wPJK2W3svrwqaN61aP25W');
const contractIdBuffer = Buffer.from(contractId);
const getDocumentsRequest = new GetDocumentsRequest();
const type = 'note';
const limit = 1;
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":"BexuQvZ7zeNK51eNqJDUMOCGHzPC+wfHrnqjqsg/CWk=",
"document_type":"note",
"limit":1
}' \
seed-1.evonet.networks.dash.org:3010 \
org.dash.platform.dapi.v0.Platform/getDocuments
{
'$id': <Buffer 31 39 11 9a bc 87 b9 d7 a8 f0 76 d0 bb 85 9f 0b 7c cc 99 ed 21 65 1c 4c 79 14 9d c1 35 07 39 d6>,
'$type': 'note',
message: 'Tutorial Test @ Thu, 29 Oct 2020 20:39:40 GMT',
'$ownerId': <Buffer 9e e0 b3 ba 68 3f b3 92 c2 d5 2a 65 81 bc ed 0f 15 7d 01 f6 41 af 5c 0d 92 53 38 cc af 31 67 dd>,
'$revision': 1,
'$dataContractId': <Buffer 05 ec 6e 42 f6 7b cd e3 4a e7 57 8d a8 90 d4 30 e0 86 1f 33 c2 fb 07 c7 ae 7a a3 aa c8 3f 09 69>,
'$protocolVersion': 0
}
{
"documents": [
"p2MkaWRYIDE5EZq8h7nXqPB20LuFnwt8zJntIWUcTHkUncE1BznWZSR0eXBlZG5vdGVnbWVzc2FnZXgtVHV0b3JpYWwgVGVzdCBAIFRodSwgMjkgT2N0IDIwMjAgMjA6Mzk6NDAgR01UaCRvd25lcklkWCCe4LO6aD+zksLVKmWBvO0PFX0B9kGvXA2SUzjMrzFn3WkkcmV2aXNpb24BbyRkYXRhQ29udHJhY3RJZFggBexuQvZ7zeNK51eNqJDUMOCGHzPC+wfHrnqjqsg/CWlwJHByb3RvY29sVmVyc2lvbgA="
]
}
Deprecated Endpoints
applyStateTransition
Deprecated RPC
Renamed to
broadcastStateTransition
in Dash Platform v0.15.0
getIdentityByFirstPublicKey
Removed in Dash Platform v0.16
Similar functionality available with getIdentitiesByPublicKeyHashes
getIdentityIdByFirstPublicKey
Removed in Dash Platform v0.16
Similar functionality available with getIdentityIdsByPublicKeyHashes
Code Reference
Implementation details related to the information on this page can be found in:
- The DAPI repository
lib/grpcServer/handlers/platform
folder - The dapi-grpc repository
protos
folder
Updated almost 4 years ago