Skip to main content

Create a draft

The VcDecorator represents the entry point for the UDT model and the lifecycle of the credential (Create → Update → Issue → Present). This page covers the first step of the credential lifecycle - creating a draft resource.

Example: Create a draft with basic claims

The example below takes the previously defined basic credential schema, creates the VcDecorator instance and adds claims to the Draft resource:

const vcDecoratorInstance = await client.createVcDecorator(ClaimsModelExample); // VcDecorator

const createdDraft = await vcDecoratorInstance.create({ // Draft<ClaimsModelExample>
claims: {
name: "Alice",
age: 30
}
});
important

The createVcDecorator method creates a new draft using the API and returns its representation (the Draft instance). This returns a draft instance with the assigned claims model passed to the VcDecorator. In the example above, it is the ClaimsModelExample.

Once created, you can update the draft as needed or issue a verifiable credential (VC).

Example: Create a draft with date and date-time claims

The example below shows how to add date-based claims values the previously defined credential schema with dates:

const vcDecoratorInstance = await client.createVcDecorator(ClaimsModelExample); // VcDecorator

const createdDraft = await vcDecoratorInstance.create({
claims: {
field1: new Rfc3339Date(1992, 10, 15),
field2: new Rfc3339DateTime(), // Current date and time
}
});
important

Remember these key points about working with Rfc3339DateTime when passing it as a string:

  1. Always use UTC times (indicated by the Z at the end of the string representation).
  2. Use the following format: YYYY-MM-DDTHH:mm:ss.sssZ.

Further reading