Issue a Credential to a 3rd Party

Issuing credentials to third parties is mainly used for application services to issue credentials to users, or KYC institutions to issue credentials of certified personal information to third entities. An example is as follows:

DIDStore store; // an opened DIDStore instance
String storePasswd = "secret";
DID example = new DID("did:elastos:examplekyc");

DIDDocument doc = store.loadDid(example);
Issuer kycIssuer = new Issuer(doc);

// Create a credential builder for 3rd party: 
//        did:elastos:igHQ6Mfp3RouLtqeiv7D3Uz5JDyVrW4W3A
VerifiableCredential.Builder cb = selfIssuer.issueFor(
// Create the credential
VerifiableCredential vc ="#profile")
    .type("EmailCredential", "")
    .type("SocialCredential", "")
    .property("name", "John");
    .property("gender", "Male");
    .property("nationality", "Singapore");
    .property("email", "");
    .property("twitter", "@john");

// or serialize the credential to string, send to the 3rd party in secure way
String serializedVc = vc.serialize();

To ensure that the credential can be verified, the DID of the entity issuing the credential needs to be published and uploaded to the chain.

A credential issued by customized DID, or one issued to customized DID, is consistent with primitive DID.

Last updated