> For the complete documentation index, see [llms.txt](https://totochain.gitbook.io/totochain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://totochain.gitbook.io/totochain/knowledge-base/adding-a-new-ctype.md).

# Adding a New cType

The Toto Chain's reputation system is designed to be flexible and evolve over time. While it launches with a core set of Credential Types (cTypes), its true power lies in the ability for the community to add new types of credentials.

This guide outlines the process for adding a new cType to the Toto Chain, from initial definition to on-chain registration.

### Step 1: Define the cType Schema (Off-Chain)

Before anything happens on-chain, a developer or service provider must first define the structure of the new credential. This is done by creating a JSON schema that outlines all the necessary fields and their corresponding data types.

While many cTypes may use simple `string` fields, the schema supports a variety of types to accurately model different kinds of credentials. For example, let's define a cType for a **Digital Driver's License**, which requires strings, numbers, and boolean (true/false) values.

Using a compatible library (like the Kilt SDK), the definition would look something like this:

```
const driversLicenseCType = Kilt.CType.fromProperties('Digital Driver\'s License', {
  licenseNumber: { type: 'string' },
  familyName: { type: 'string' },
  givenName: { type: 'string' },
  dateOfBirth: { type: 'string', format: 'date' },
  issueDate: { type: 'string', format: 'date' },
  expiryDate: { type: 'string', format: 'date' },
  issuingCountry: { type: 'string' },
  heightCm: { type: 'integer' },
  organDonor: { type: 'boolean' }
});

```

**Supported Schema Types**

The cType schema is based on the JSON Schema standard and supports the following primitive types:

| **Type**  | **Description**                                                    | **Example Value** |
| --------- | ------------------------------------------------------------------ | ----------------- |
| `string`  | A sequence of characters. Can also specify a `format` like `date`. | `"John Doe"`      |
| `integer` | A whole number (no decimals).                                      | `180`             |
| `number`  | Any number, including decimals.                                    | `65.5`            |
| `boolean` | A true or false value.                                             | `true`            |

### Step 2: Calculate the `ctypeHash`

The full JSON schema is not stored directly on the blockchain for efficiency. Instead, a unique cryptographic hash of the schema is generated. This hash becomes the cType's on-chain identifier, known as the **`ctypeHash`**.

This hashing process is typically handled by the same software development kit used to define the cType. The resulting `ctypeHash` is a long hexadecimal string that uniquely represents our "Digital Driver's License" schema.

### Step 3: Propose the New cType via Governance

With the `ctypeHash` generated, the next step is to register it on the Toto Chain. This is a privileged action that can only be performed by the **Technical Committee** through a formal governance proposal.

A member of the committee must submit a proposal using the `attestation.addCtypeWithWeight` extrinsic.

This proposal requires two key parameters:

1. **`ctypeHash`**: The unique hash of the new cType schema that was calculated in Step 2.
2. **`ctypeWeight`**: The amount of reputation a user will gain when an attestation of this new type is added to their DID. The committee must propose a weight that reflects the value of the credential. For a high-trust credential like a driver's license, this weight would likely be significant.

### Step 4: Committee Voting and Execution

Once the proposal is submitted, it becomes visible to all members of the Technical Committee, who then vote on whether to approve it.

* If the proposal receives enough "Aye" votes to meet the required threshold, it is approved.
* Upon approval, the chain's runtime automatically executes the proposal, officially registering the new `ctypeHash` and its associated `ctypeWeight`.

From that moment on, the "Digital Driver's License" cType is an official part of the Toto Chain's identity system. Approved Attestation Providers can now begin to issue verifiable credentials using this new type, and users who receive them will see their reputation increase accordingly.
