Retrieve an Identity
Retrieve details for a Dash Platform Identity
Overview
In this tutorial we will retrieve the identity created in the Register an Identity tutorial.
Prerequisites
- node.js (v12+)
- Basic familiarity with JavaScript asychronous functions using async/await
- The Dash JavaScript SDK is initialized (covered in Connecting to a Network)
- A Dash Platform Identity: Tutorial: Register an Identity
Code
const Dash = require('dash');
const client = new Dash.Client();
const retrieveIdentity = async () => {
return client.platform.identities.get('an identity ID goes here');
};
retrieveIdentity()
.then((d) => console.log('Identity retrieved:\n', d.toJSON()))
.catch((e) => console.error('Something went wrong:\n', e))
.finally(() => client.disconnect());
Example Identity
The following example response shows a retrieved identity:
{
"protocolVersion":0,
"id":"DVNRfGUspUc6r1CiUFN92zNMBh5Y5jc5cZqCiP1XSJ7G",
"publicKeys":[
{
"id":0,
"type":0,
"data":"A5IZf6peksdOOH2Qcuh2VDH+m5n52bL6dW6Xt1oMGWjq"
}
],
"balance":10998939,
"revision":0
}
What's Happening
After we initialize the Client, we request an identity. The platform.identities.get
method takes a single argument: an identity ID. After the identity is retrieved, it is displayed on the console.
Updated over 3 years ago