Skip to main content

Create a Credential Schema

Make sure you've read the Learn section.

Message Parameters

NameDescriptionMandatory
trust-registry-idNumeric ID of the trust registryYes
json-schemaJSON schema (inline string or loaded from file)Yes
issuer-grantor-validityValidity period for issuer grantor (in days)No
verifier-grantor-validityValidity period for verifier grantor (in days)No
issuer-validityValidity period for issuer (in days)No
verifier-validityValidity period for verifier (in days)No
holder-validityValidity period for holder (in days)No
issuer-perm-modePermission mode for issuer (integer)Yes
verifier-perm-modePermission mode for verifier (integer)Yes
tip

You must specify the name, version, and JSON schema definition. Refer to the specification for required attributes.

Post the Message

Usage

veranad tx cs create-schema <trust-registry-id> <json-schema> <issuer-grantor-validity> <verifier-grantor-validity> <issuer-validity> <verifier-validity> <holder-validity> <issuer-perm-mode> <verifier-perm-mode> --from <user> --chain-id <chain-id> --keyring-backend test --fees <amount>

Permission Management Modes for Issuer and Verifier

ValueMode NameDescription
1OPENAnyone can self-create the permission without validation.
2GRANTOR_VALIDATIONRequires validation by a Grantor permission holder (Issuer or Verifier).
3ECOSYSTEMRequires validation by the Ecosystem controller (Trust Registry owner).

Example (inline JSON schema):

veranad tx cs create-credential-schema ${TRUST_REG_ID} '{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"vpr:verana:VPR_CHAIN_ID/cs/v1/js/VPR_CREDENTIAL_SCHEMA_ID","title": "ExampleCredential","description": "ExampleCredential using JsonSchema","type":"object","properties":{"name":{"type":"string"}},"required":["name"],"additionalProperties":false}' \
--issuer-grantor-validation-validity-period 365 \
--verifier-grantor-validation-validity-period 365 \
--issuer-validation-validity-period 180 \
--verifier-validation-validity-period 180 \
--holder-validation-validity-period 90 \
1 1 --from $USER_ACC --chain-id $CHAIN_ID --keyring-backend test --fees 600000uvna --node $NODE_RPC

Example (using JSON file):**

# Save schema to file first
cat > schema.json << 'EOF'
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "vpr:verana:VPR_CHAIN_ID/cs/v1/js/VPR_CREDENTIAL_SCHEMA_ID",
"title": "ExampleCredential",
"description": "ExampleCredential using JsonSchema",
"type": "object",
"$defs": {},
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
}
},
"required": ["name"],
"additionalProperties": false
}
EOF

# Use in command (you'll need to escape or quote properly)
veranad tx cs create-credential-schema ${TRUST_REG_ID} "$(cat schema.json)" \
--issuer-grantor-validity 365 \
--verifier-grantor-validity 365 \
--issuer-validity 180 \
--verifier-validity 180 \
--holder-validity 90 \
1 1 --from $USER_ACC --chain-id $CHAIN_ID --keyring-backend test --fees 600000uvna --node $NODE_RPC
tip

How to find the id of the credential schema that was just created?

TX_HASH=4E7DEE1DFDE24A804E8BD020657EB22B07D54CBA695788ACB59D873B827F3CA6
veranad q tx $TX_HASH --node $NODE_RPC --output json
tip

Make sure you are pointing towards your own Trust Registry (ID) before you run the above example!

Remember to List Trust Registries to find the relevant ID.

TRUST_REG_ID=5

replace with the correct transaction hash.

Publish your Credential Schema

When the credential schema has been created, you now need to self-issue a Verifiable Trust Json Schema Credential with the DID of your trust registry, as specified in the verifiable trust spec.

Create and publish the Json Schema Credential

Self issue your credential and publish the credential in a publicly accessible URL.

Add the Json Schema Credential as a Linked-VP in your DID Document

Create and sign a presentation of your self-issued Verifiable Trust Json Schema Credential with your DID and present it in your DID Document as a linked-vp.