Create a Credential Schema
MOD-CS-MSG-1
Make sure you've read the Learn section.
Post a message that creates a new credential schema attached to an Ecosystem, on behalf of a Corporation. This operation is delegable.
This is a delegable transaction executed on behalf of a Corporation. Before running it you need:
- A Corporation (
policy_address) — see Create a Corporation. - The policy funded with
uvnafor fees. - An existing Ecosystem controlled by that Corporation — see Create an Ecosystem. Its numeric
idis the[ecosystem-id]argument. - An operator granted authorization for
/verana.cs.v1.MsgCreateCredentialSchemavia Grant Operator Authorization.
Sign with --from <operator> and pass the corporation's policy_address with the --corporation flag.
Message Parameters
The command signature is:
veranad tx cs create-credential-schema [ecosystem-id] [json-schema] [issuer-mode] [verifier-mode] [holder-onboarding-mode] [pricing-asset-type] [pricing-asset] [digest-algorithm]
| Positional | Description | Mandatory |
|---|---|---|
ecosystem-id | Numeric ID of the Ecosystem that will own the schema (must be controlled by your Corporation) | yes |
json-schema | JSON schema — inline string or path to a file | yes |
issuer-mode | Issuer onboarding mode (integer, see table below) | yes |
verifier-mode | Verifier onboarding mode (integer, see table below) | yes |
holder-onboarding-mode | Holder onboarding mode (integer, see table below) | yes |
pricing-asset-type | Pricing asset type (integer: 1=TU, 2=COIN, 3=FIAT) | yes |
pricing-asset | Pricing asset identifier (tu for TU, denom for COIN, ISO-4217 code for FIAT) | yes |
digest-algorithm | Digest algorithm for credential integrity (sha256, sha384, sha512) | yes |
Validity periods are supplied as flags (each defaults to 0, meaning never expires):
| Flag | Description |
|---|---|
--issuer-grantor-validation-validity-period | Days an issuer-grantor validation remains valid |
--verifier-grantor-validation-validity-period | Days a verifier-grantor validation remains valid |
--issuer-validation-validity-period | Days an issuer validation remains valid |
--verifier-validation-validity-period | Days a verifier validation remains valid |
--holder-validation-validity-period | Days a holder validation remains valid |
Each flag takes the wrapped-integer form '{"value":N}'.
Issuer / Verifier onboarding modes
| Value | Mode | Description |
|---|---|---|
1 | OPEN | Anyone can self-create the permission without validation. |
2 | ECOSYSTEM_VALIDATION_PROCESS | Requires an onboarding process validated by the Ecosystem. |
3 | GRANTOR_VALIDATION_PROCESS | Requires an onboarding process validated by a Grantor. |
Holder onboarding modes
| Value | Mode | Description |
|---|---|---|
1 | ISSUER_VALIDATION_PROCESS | Holders onboard through the issuer's validation process. |
2 | PERMISSIONLESS | Anyone can self-create a holder permission without validation. |
The inline --help text for create-credential-schema still shows the pre-v4 issuer/verifier mode legend (2=GRANTOR_VALIDATION, 3=ECOSYSTEM) and omits holder-onboarding-mode. The values above are the ones the node actually stores — verify against veranad query cs get-schema [id], whose issuer_onboarding_mode / verifier_onboarding_mode / holder_onboarding_mode fields report the enum names.
Pricing asset types
| Value | Type | pricing-asset value | Description |
|---|---|---|---|
1 | TU | tu | Trust Unit (non-transferable token) |
2 | COIN | denom (e.g., uvna) | Native blockchain token or IBC asset |
3 | FIAT | ISO-4217 code (e.g., USD) | Fiat currency (off-chain settlement) |
The json-schema supports placeholder replacement performed at creation time:
VPR_CREDENTIAL_SCHEMA_ID— replaced with the generated schema ID.VPR_CHAIN_ID— replaced with the current chain ID.
Refer to the specification for the required attributes.
Required Environment Variables
CORPORATION=verana1f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esdak22l
OPERATOR=verana1qrdyvgf74jpu5kxufg0gczz5rfv0ws646t3kw4
ECOSYSTEM_ID=3
CHAIN_ID=vna-testnet-1
NODE_RPC=https://rpc.testnet.verana.network
Post the Message
- CLI
- Frontend
Usage
veranad tx cs create-credential-schema [ecosystem-id] [json-schema] [issuer-mode] [verifier-mode] [holder-onboarding-mode] [pricing-asset-type] [pricing-asset] [digest-algorithm] \
--corporation <policy_address> \
[--issuer-grantor-validation-validity-period '{"value":N}'] \
[--verifier-grantor-validation-validity-period '{"value":N}'] \
[--issuer-validation-validity-period '{"value":N}'] \
[--verifier-validation-validity-period '{"value":N}'] \
[--holder-validation-validity-period '{"value":N}'] \
--from <operator> --chain-id <chain-id> --keyring-backend test --fees <amount> --gas auto --node $NODE_RPC
The --from flag is the operator (transaction signer); --corporation is the policy_address of the Corporation that controls the ecosystem.
Example (using a JSON file)
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
veranad tx cs create-credential-schema \
$ECOSYSTEM_ID "$(cat schema.json)" \
1 1 2 1 tu sha256 \
--corporation $CORPORATION \
--issuer-grantor-validation-validity-period '{"value":365}' \
--verifier-grantor-validation-validity-period '{"value":365}' \
--issuer-validation-validity-period '{"value":180}' \
--verifier-validation-validity-period '{"value":180}' \
--holder-validation-validity-period '{"value":90}' \
--from $OPERATOR --chain-id $CHAIN_ID --keyring-backend test --fees 750000uvna --gas auto --node $NODE_RPC
The positional modes above are: issuer-mode=1 (OPEN), verifier-mode=1 (OPEN), holder-onboarding-mode=2 (PERMISSIONLESS), pricing-asset-type=1 (TU), pricing-asset=tu, digest-algorithm=sha256.
Example response
The transaction emits a create_credential_schema event carrying the new credential_schema_id:
code: 0
events:
- type: message
attributes:
- key: action
value: /verana.cs.v1.MsgCreateCredentialSchema
- key: module
value: cs
- type: create_credential_schema
attributes:
- key: credential_schema_id
value: "1"
- key: ecosystem_id
value: "3"
- key: corporation
value: verana1f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esdak22l
- key: operator
value: verana1qrdyvgf74jpu5kxufg0gczz5rfv0ws646t3kw4
gas_used: "104298"
txhash: 3C5B0630497AB26A3034E2A69EB784074331F1F4F90E02D2FF1C05737DE9BCB5
Read the create_credential_schema event from the transaction:
TX_HASH=3C5B0630497AB26A3034E2A69EB784074331F1F4F90E02D2FF1C05737DE9BCB5
veranad query tx $TX_HASH --node $NODE_RPC --output json \
| jq '.events[] | select(.type == "create_credential_schema") | .attributes | map({(.key): .value}) | add'
If the operator is not authorized for this corporation, the transaction is rejected:
authorization check failed: operator authorization does not include requested message type: /verana.cs.v1.MsgCreateCredentialSchema
You can also use the testnet frontend to create a credential schema using the web interface.
Publish your Credential Schema
When the credential schema has been created, you now self-issue a Verifiable Trust JSON Schema Credential with the DID of your ecosystem, as specified in the verifiable trust spec.
Create and publish the JSON Schema Credential
Self-issue your credential and publish it at 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 reference it in your DID Document as a linked-vp.