Skip to main content
Client for interacting with the Schema Registry contract The Schema Registry contract is used to register and manage the schemas for digital asset attestations. It provides a method to register a new schema or get the hash of an existing schema.

new SchemaRegistryClient()

new SchemaRegistryClient(publicClient, walletClient, contractAddress): SchemaRegistryClient

Parameters

publicClient
walletClient
contractAddress
`0x${string}`

Returns

SchemaRegistryClient

Methods

register()

register(schema, revocable): Promise<`0x${string}`>
Register a new schema

Parameters

schema
string The schema string to register
revocable
boolean Whether attestations using this schema can be revoked

Returns

Promise<`0x${string}`> The schema UID (hash)

getSchema()

getSchema(uid): Promise<{ uid: `0x${string}`; revocable: boolean; schema: string; }>
Get schema by UID

Parameters

uid
`0x${string}` The unique identifier (hash) of the schema

Returns

Promise<{ uid: `0x${string}`; revocable: boolean; schema: string; }> The schema data including the schema string and revocable flag

isRevocable()

isRevocable(uid): Promise<boolean>
Check if a schema is revocable

Parameters

uid
`0x${string}` The unique identifier (hash) of the schema

Returns

Promise<boolean> Boolean indicating if attestations using this schema can be revoked

getOrRegisterSchema()

getOrRegisterSchema(schema, revocable): Promise<`0x${string}`>
Register a new schema or get existing schema hash

Parameters

schema
string The schema string to register
revocable
boolean Whether the schema is revocable

Returns

Promise<`0x${string}`> The schema hash

Remarks

This function is fundamental to the attestation process as it:
  1. Defines the data structure for digital asset attestations
  2. Ensures consistency in how digital asset data is stored and verified
  3. Controls whether attestations can be revoked
Schema Structure: The schema string follows Solidity’s parameter encoding format and typically includes:
  • digitalAssetName: Name of the digital asset
  • digitalAssetDescription: Detailed description of the digital asset
  • grade: Numerical grade/rating of the digital asset

Example

// Define a schema for digital asset attestations
const schemaStr = 'string digitalAssetName, string digitalAssetDescription, uint256 grade';
const isRevocable = true;

// Register or get the schema
const schemaHash = await sdk.schemaRegistry.getOrRegisterSchema(schemaStr, isRevocable);