Skip to main content

Create a CType

Every KILT credential has to conform to a CType. A CType describes which properties a credential has and what type these properties have. CTypes must be registered on the Spiritnet blockchain. To learn more about CTypes, see the CType concept section.

The creation of a CType in KILT involves two steps: the definition of a CType and the anchoring of its hash on the KILT blockchain.

DID required

The creator of a CType is required to have a full DID with an attestation key. To see how to manage DIDs, please refer to the DID section.

CTypes are unique

The creation of a new CType requires the CType hash to be unique. Before writing a new CType, Attesters should check whether there is already an existing CType which matches their requirements.

Visit our CType index repository for a non-exhaustive list of existing CTypes.

The following snippets show how to create a CType:

import * as Kilt from '@kiltprotocol/sdk-js'

export async function createDriversLicenseCType(
creator: Kilt.DidUri,
submitterAccount: Kilt.KiltKeyringPair,
signCallback: Kilt.SignExtrinsicCallback
): Promise<Kilt.ICType> {
const api = Kilt.ConfigService.get('api')

// Create a new CType definition.
const ctype = Kilt.CType.fromProperties(`Drivers License by ${creator}`, {
name: {
type: 'string'
age: {
type: 'integer'
id: {
type: 'string'

// Generate a creation tx.
const encodedCtype = Kilt.CType.toChain(ctype)
const ctypeCreationTx = api.tx.ctype.add(encodedCtype)
// Sign it with the right DID key.
const authorizedCtypeCreationTx = await Kilt.Did.authorizeTx(
// Submit the creation tx to the KILT blockchain
// using the KILT account specified in the creation operation.
await Kilt.Blockchain.signAndSubmitTx(

return ctype

Retrieve a CType from its ID

CTypes can be queried directly from any KILT archive nodes. The following example shows how to query a CType using the SDK:

import * as Kilt from '@kiltprotocol/sdk-js'

export async function fetchCType(
ctypeId: Kilt.ICType['$id']
): Promise<Kilt.CType.ICTypeDetails> {
// Example CType ID: kilt:ctype:0x329a2a5861ea63c250763e5e4c4d4a18fe4470a31e541365c7fb831e5432b940
return Kilt.CType.fetchFromChain(ctypeId)