# Schema Registry

## Hypersign Schema Registry

The Hypersign Schema comply [Verifiable Credentials JSON Schema 2022 data model](https://w3c-ccg.github.io/vc-json-schemas/#data_model) specification and is stored on [Hypersign Identity Blockchain Network](https://explorer.hypersign.id/hypersign-testnet) as it is [adviced to store](https://w3c-ccg.github.io/vc-json-schemas/#storage) schema documents and made available as immutable objects.

## Syntax of Hypersign Schema ID

The syntax of Schema ID is as follows:

```
sch:hid:<chain-namespace>:<method-specific-id>:<version-number>
```

* `sch:hid` - Schema Method, where `sch` is the document identifier and `hid` is the method name
* `<chain-namespace>` - *(Optional)* Name of the blockchain where the schema document is registered. It is omitted for the document registered on mainnet chain
* `<method-specific-id>` - Alpha-numeric string of minimum 32 character length
* `<version-number>` - Model version of schema. For instance, `1.0`, `1.1` and `2.1`

## Schema Operations

* **Transaction Based**
  * Register/Update a Schema Document
* **Query Based**
  * Query Schema Document(s)

## Usage

### Register/Update Schema

Both registration and update of Schema happens through the RPC `CreateSchema`

**CLI Signature**

```
Usage:
  hid-noded tx ssi create-schema [schema-doc] [schema-proof] [flags]

Params:
 - schema-doc : Schema Document
 - schema-proof : Schema Proof
```

**Example**

```
hid-noded tx ssi create-schema '{"type":"https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json","modelVersion":"v1.0","id":"sch:hid:<chain-namespace>:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf:1.0","name":"HS credential template","author":"did:hid:devnet:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf","authored":"2022-04-10T04:07:12Z","schema":{"schema":"https://json-schema.org/draft-07/schema#","description":"test","type":"object","properties":"{myString:{type:string},myNumner:{type:number},myBool:{type:boolean}}","required":["myString","myNumner","myBool"],"additionalProperties":false}}' '{"type":"Ed25519VerificationKey2020","created":"2022-04-10T04:07:12Z","verificationMethod":"did:hid:devnet:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf#key-1","proofValue":"gLFhwYfObNJEOjNDaeYjprv7FpK0lIhZnFwgOsdRqRHOjQswfm3Hk9EehcYGePrFFwgy4lna73iA5J0BtjfCAw==","proofPurpose":"assertionMethod"}' --from <key-name-or-address> --chain-id <Chain ID> --yes
```

### Register/Update Schema

**CLI Signature**

```
Usage:
  hid-noded query ssi schema [schema-id]

Params:
 - schema-id : Schema ID
```

**Example**

```
hid-noded query ssi schema sch:hid:<chain-namespace>:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf:1.0
```

**REST**

1. Query a specific version of schema document for given schema id:

```
http://<REST-URL>/hypersign-protocol/hidnode/ssi/schema/sch:hid:<chain-namespace>:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf:1.0
```

1. Query all versions of a schema document:

```
http://<REST-URL>/hypersign-protocol/hidnode/ssi/schema/sch:hid:<chain-namespace>:zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf
```

1. Query a list of registered schema documents:

```
http://<REST-URL>/hypersign-protocol/hidnode/ssi/schema
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypersign.id/core-concepts/schema/schema-registry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
