Create a Credential Schema
Make sure you've read the Learn section.
Message Parameters
Name | Description | Mandatory |
---|---|---|
trust-registry-id | Numeric ID of the trust registry | Yes |
json-schema | JSON schema (inline string or loaded from file) | Yes |
issuer-grantor-validity | Validity period for issuer grantor (in days) | Yes |
verifier-grantor-validity | Validity period for verifier grantor (in days) | Yes |
issuer-validity | Validity period for issuer (in days) | Yes |
verifier-validity | Validity period for verifier (in days) | Yes |
holder-validity | Validity period for holder (in days) | Yes |
issuer-perm-mode | Permission mode for issuer (integer) | Yes |
verifier-perm-mode | Permission mode for verifier (integer) | Yes |
You must specify the name, version, and JSON schema definition. Refer to the specification for required attributes.
Post the Message
- CLI
- Frontend
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
Value | Mode Name | Description |
---|---|---|
1 | OPEN | Anyone can self-create the permission without validation. |
2 | GRANTOR_VALIDATION | Requires validation by a Grantor permission holder (Issuer or Verifier). |
3 | ECOSYSTEM | Requires 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:mainnet/cs/v1/js/VPR_CREDENTIAL_SCHEMA_ID","title": "ExampleCredential","description": "ExampleCredential using JsonSchema","type":"object","properties":{"name":{"type":"string"}},"required":["name"],"additionalProperties":false}' 365 365 180 180 180 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:mainnet/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)" 365 365 180 180 180 1 1 --from $USER_ACC --chain-id $CHAIN_ID --keyring-backend test --fees 600000uvna --node $NODE_RPC
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
replace with the correct transaction hash.
You can also use the testnet frontend to create a credential schema using a simple web interface.
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.