Interactive operations

Get credentials

In order to request a user’s DID string, name, email or any other information stored in user’s identity, the connectivity SDK has to be used:

let didAccess = new DID.DIDAccess();
let presentation = await didAccess.getCredentials({
  claims: {
    name: true,
    avatar: {
      required: false,
      reason: "To check if you are handsome or not"

if (presentation) {
  let nameCredential = presentation.getCredentials().find((c) => {
    return c.getId().getFragment() === "name";
  if (nameCredential) {
      let userName = nameCredential.getSubject().getProperty("name");

Import a credential

When a web or mobile application wants to save some important information as part of a user’s identity profile, so that this information can be verified by anyone else, a credential has to be generated by the application, signed by the developer’s DID, and sent to user’s identity wallet for him to approve the import before the credential gets imported as part of user’s identity.

First, you need a signing identity that can be created as explained here.

// First, generate a credential - not in this sample.

// Send the credential to the identity wallet (i.e.: Elastos Essentials)
let didAccess = new DID.DIDAccess();
let importedCredentials = await didAccess.importCredentials([credential]);