Sitemap

Issuing a verifiable credential in 7 easy steps.

4 min readAug 20, 2021

--

This article is out of date because of the new Aries Framework JavaScript release. It is only applicable for AFJ version 0.1.0. For instructions on different versions, check out the docs.

Verifiable credentials are getting easier and easier to work with. In this piece, we’re going to show you how to issue a verifiable credential using Aries Framework JavaScript in around 100 lines of code. To see and copy the code, you can see this repo to run it yourself.

Imagine you just purchased a gold tier gym membership from a new gym in your neighborhood. This gym is modern and sleek and makes an effort to embrace new technologies, so they’re using a new membership system. Instead of a plastic card that proves you are a member, you are going to receive a verifiable credential on your phone!

First we’re going to create a holder Agent, this will be the Agent that receives the membership credential. During their life, the holder will collect many different verifiable credentials. Memberships, ID-cards, even purchasing records. Anything a person might need to prove something about themselves can be a verifiable credential they can store on their phone.

Press enter or click to view image in full size
The holder is created, we’re using auto accept to make this example as simple as possible.

We now need a second party, the gym itself, this will be our second Agent. They will be the ones that issues the membership credential to your holder agent. In classic terms where you (the member) are the ‘holder’, the gym will be the ‘issuer’.

Press enter or click to view image in full size
The issuer agent is created in the exact same way.

Our two Agents need to have a connection to exchange information. To create a connection between them, the issuer Agent will send an invitation to connect to the holder Agent.

Press enter or click to view image in full size
The issuer is creating the connection in this case.

The holder Agent will need to receive and accept this invitation to establish the connection. Once our two parties are connected, they can use that connection for different purposes like communicating, requesting and sending proofs and (of course) issuing credentials.

Press enter or click to view image in full size
Here’s where auto accept is making our code nice and short. The holder receives and accepts the connection.

Now we’re getting to the exciting stuff. The gym will need to define what attributes are a part of their membership, they need to create a schema for the credential they are going to issue. An ID credential might contain your first name, last name, citizen number, nationality etc. This gym membership only contains a starting date and a tier, so we’ll create a schema with those values.

Get Animo Solutions’s stories in your inbox

Join Medium for free to get updates from this writer.

While the schema defines the attributes of the credential (‘Start date’ and ‘Tier’), the credential definition links the schema to the issuers DID (Decentralized Identifier). Now the holder will always be able to prove that the gym issued the credential, as it is connected to their organizational DID

Press enter or click to view image in full size
Creating the schema and registering it.

The credential definition has been created and registered. To give you the credential, the issuer Agent will offer it to your holder Agent, who will then decide whether to accept. On your phone this could be in the form of a popup or notification in your personal digital wallet app. To show the holder Agent what they are accepting/rejecting, the issuer will create a preview of the credential and send it along with the credential offer.

Press enter or click to view image in full size
Creating the preview and sending it along with the credential offer.

The holder Agent is listening for change, and can accept the credential when it is offered. After this they are now the owner of the verifiable credential. The holder Agent can use it to prove to anyone asking that they are a member of this particular gym.

Press enter or click to view image in full size
The holder listens for a changed state and accepts the offer of a credential.

Great job! We’ve seen two Agents establishing a connection, one of them offering a credential and the other accepting it. All in 7 easy steps.

To run this code yourself, check out this repo. It contains some additional config, setup and logging so you can run it all in one go, but you’ll see that the code is largely the same as the steps above.

Aries Framework JavaScript is a great framework for those starting with development around verifiable credentials. The framework is constantly being improved with accessibility and ease of use in mind, so make sure to keep an eye on it.

--

--