Skip to main content

Create and Register a Schema

Before issuing attestations, you need a registered schema or a schema that already exists in the target Verax deployment.

Onchain interface​

Schemas are created in SchemaRegistry:

function createSchema(
string calldata name,
string calldata description,
string calldata context,
string calldata schemaString
) public;

Protocol checks:

  • name must be non-empty;
  • schemaString must be non-empty;
  • the schema ID must not already be registered.
ParameterTypeMeaning
namestringHuman-readable schema name
descriptionstringLink or text describing intended use
contextstringSemantic context hint or vocabulary pointer
schemaStringstringABI-like schema definition
warning

On mainnets, schema creation is gated by issuer allowlisting. On testnets, the deployment is permissionless.

  1. Compute the schema ID first.
  2. Check whether it is already registered.
  3. Create it only if needed.
info

Because schema IDs are deterministic, recomputing the ID locally is usually easier and more reliable than scraping it from explorer logs.

SDK​

const schemaString = "(bool isExample, uint16 score)";
const schemaId = await veraxSdk.schema.getIdFromSchemaString(schemaString);
const exists = await veraxSdk.schema.isRegistered(schemaId);

if (!exists) {
await veraxSdk.schema.create(
"Example Schema",
"Example schema used in documentation",
"https://schema.org/Thing",
schemaString,
{ waitForConfirmation: true },
);
}

Explorer or manual contract call​

Example explorer form for calling createSchema on SchemaRegistry.

  1. Find the SchemaRegistry address for your network in Networks and Addresses.
  2. Open the contract page in your network explorer.
  3. Go to the contract write interface.
  4. Call createSchema(name, description, context, schemaString).
  5. Read the emitted SchemaCreated event or recompute the ID locally with getIdFromSchemaString(schemaString).

Using the deterministic ID is usually easier than scraping explorer logs.

Updating the context later​

The schema creator can later update context with:

function updateContext(bytes32 schemaId, string calldata context) public;

The caller must be the assigned issuer for that schema.