From a Schema to an Attestation
This walkthrough mirrors the tutorial app that lives in tutorial/ in this monorepo.
Goal
Create:
- a schema;
- a default portal;
- an attestation;
- a UI readback of the issued attestation.
1. Install and run the tutorial app
From the monorepo root:
pnpm install
pnpm --filter @verax-attestation-registry/verax-tutorial dev
2. Instantiate the SDK
The tutorial app picks the frontend SDK config from the connected chain:
import { VeraxSdk } from "@verax-attestation-registry/verax-sdk";
let sdkConf;
switch (chain.id) {
case 84532:
sdkConf = VeraxSdk.DEFAULT_BASE_SEPOLIA_FRONTEND;
break;
case 59141:
sdkConf = VeraxSdk.DEFAULT_LINEA_SEPOLIA_FRONTEND;
break;
case 421614:
sdkConf = VeraxSdk.DEFAULT_ARBITRUM_SEPOLIA_FRONTEND;
break;
case 97:
sdkConf = VeraxSdk.DEFAULT_BSC_TESTNET_FRONTEND;
break;
default:
sdkConf = VeraxSdk.DEFAULT_LINEA_SEPOLIA_FRONTEND;
break;
}
const veraxSdk = new VeraxSdk(sdkConf, address);
3. Compute or create the schema
Use the schema string:
const schemaString = "(bool hasCompletedTutorial)";
const schemaId = await veraxSdk.schema.getIdFromSchemaString(schemaString);
const exists = await veraxSdk.schema.isRegistered(schemaId);
If it does not exist:
await veraxSdk.schema.create(
"Tutorial Schema",
"This Schema is used for the tutorial",
"https://ver.ax/#/tutorials",
schemaString,
{ waitForConfirmation: true },
);
4. Deploy a default portal
const receipt = await veraxSdk.portal.deployDefaultPortal(
[],
"Tutorial Portal",
"This Portal is used for the tutorial",
true,
"Verax Tutorial",
{ waitForConfirmation: true },
);
The emitted PortalRegistered event gives you the new portal address.
5. Issue the attestation
const receipt = await veraxSdk.portal.attest(
portalId,
{
schemaId,
expirationDate: Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60,
subject: address,
attestationData: [{ hasCompletedTutorial: true }],
},
[],
{ waitForConfirmation: true },
);
The emitted AttestationRegistered event gives you the new attestation ID.
6. Read it back
const attestation = await veraxSdk.attestation.getAttestation(attestationId);
The tutorial app reads the attestation onchain with getAttestation. For richer explorer-like reads from the subgraph,
you can also use findOneById(...), findBy(...), or findByMultiChain(...).
Important correction
If you build your own version of this tutorial, prefer schema.isRegistered(schemaId) to test existence. The tutorial
app calls getSchema(schemaId) instead, which reverts onchain with SchemaNotRegistered on a missing schema.
Next steps
- add a module to the portal;
- replace or revoke the attestation;
- switch to the canonical
Offchainschema if the payload should live on IPFS; - query the result through the subgraph.