Quickstart ⚡
Issue and verify a verifiable credential in under 5 minutes
This quickstart will demonstrate the process of defining, issuing, verifying, and revoking a credential. For this exercise, we will issue a credential from Satoshi University for students who complete the Blockchain 101 course.
1. Create a Developer Account
To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.
2. Get an API key
Once you log in to the console, the next step is to create an .
Click the "Developers" tab to expand a list and click the "API Keys" option.
Within the Server-side keys section, click the “Create new key” button in the top right. Then, select the scopes credentials:template.create
, credentials.read
, and credentials.create
under the Minting API category and create your key. Save this key for the next step.
3. Create a VC Template
Every credentials must belong to a credential template: a set of credentials that share the same schema, configuration and public metadata. (Each template is equivalent to a nft collection)
For the purpose of this quickstart, we will create a template with the following parameters:
-
Type:
courseCompletionExample
. This is an example schema, you can define your own. -
Encryption:
none
. This means the credential data will be stored in plain text. To encrypt the data, read about encrption modalities. -
Storage:
crossmint
. This means the credential data will be stored in Crossmint’s infrastructure. To store the data in decentralized storage, or your own, read about storage modalities.
You also will choose a blockchain in which the revocation state of the credentials will be stored, alongside some public (non confidential) metadata for your template.
To get started, copy the createVCtemplate.js
file in the tab below, fill in your API key, and run it in your
terminal.
node createVCtemplate.js
4. Issue a Credential
With a template created, we can start issuing credentials to our users. To do this, you need to determine the recipient (which can be an email address, or a wallet address if the user had one), and then specify the private data that goes inside the credential — such as the course name, the grade, etc.
To issue our first credential, copy the issueCredential.js
file below, add your API key, and templateId (that was
returned in previous step). Then run the file from your terminal.
node issueCredential.js
Congrats 🎉 you have issued your first credential.
The credential subject must respect the schema of the chosen type. For example, you cannot add additional fields to
the credential.subject
nor exclude any that were previously set.
You can set up a webhook to know when the VC NFT minting is completed, or call the
action status API with the returned actionId
.
5. Retrieve a Verifiable Credential
You can retrieve a credential using different identifiers associated with credential itself or the associated NFT.
- Get VC by ID uses the format:
urn:uuid:<UUID>
- Get VC by NFT Locator uses the format:
<chain>:<contractAddress>:<tokenId>
- Get VC by NFT uses crossmint’s internal NFT ID
IMPORTANT: There is not access control on credential retrieval, credential data is public and can be retrieved by anyone, use encrypted credentials if you need to protect the data.
Here is an example of retrieving a credential using the credentialId
:
node retrieveCredential.js
6. Verify a Credential
Verifying a credential can be done in different ways, the easiest one is to call the verify-credential API. You can also accomplish this with the SDK.
node verifyCredential.js
7. Revoke a Credential
To revoke a credential, you simply burn the associated NFT. You can use the burn-nft API to accomplish this or directly the revoke credential API.
const options = {
method: "DELETE",
headers: {
"X-API-KEY": "YOUR_API_KEY",
},
};
fetch(`https://staging.crossmint.com/api/unstable/credentials/${credentialId}`, options)
.then((response) => response.json())
.then((response) => console.log(JSON.stringify(response)))
.catch((err) => console.error(err));
node revokeCredential.js