Schemas

Types

Schema (Onchain)

NameTypeDescription

name

string

Schema name.

description?

string

Schema description.

revocable?

boolean

Whether Attestations that adopt this Schema can be revoked.

maxValidFor?

number

The maximum number of seconds that an Attestation can remain valid. 0 means Attestations can be valid forever. This is enforced through Attestation.validUntil.

hook?

address

The contract address of the hook for this schema.

registrant

address

The wallet address of the user that registered this schema.

dataLocation?

DataLocationOnChain

Where Schema.data is stored. See DataLocation.DataLocation.

data

SchemaItem[] or string

The data format defining this schema's data structure. When dataLocation=ONCHAIN, data is SchemaItem[], when dataLocation=ARWEAVE or IPFS, data is id of the data.

Schema (Offchain)

NameTypeDescription

name

string

Schema name.

description?

string

Schema description.

revocable?

boolean

Whether Attestations that adopt this Schema can be revoked.

maxValidFor?

number

The maximum number of seconds that an Attestation can remain valid. 0 means Attestations can be valid forever. This is enforced through Attestation.validUntil.

dataLocation?

DataLocationOffChain

Where Schema.data is stored. See DataLocation.DataLocation.

data

SchemaItem[]

The data format defining this schema's data structure.

Usage

Registering a Schema

async function createSchema(
  schema: Schema,
  options?: { getTxHash?: (txHash: `0x${string}`) => void }
): Promise<SchemaResult>;

Parameters

NameTypeDescription

schema

Schema

The schema being registered.

options?

CreateSchemaOptions

Options for creating a schema.

CreateSchemaOptions

NameTypeDescription

delegationSignature?

string

The user's delegate signature for creating a schema on their behalf. Call delegateSignSchema to get this signature.

getTxHash?

(txHash: `0x${string}`) => void

An optional callback that immediately returns the transaction hash.

Example

const res = await client.createSchema({
  name: "Example",
  data: [{ name: "name", type: "string" }],
});

Retrieving a Schema

async function getSchema(schemaId: string): Promise<Schema>;

Parameters

NameTypeDescription

schemaId

string

The ID of the schema we are trying to retrieve.

Example

const res = await client.getSchema("0x3e");

Delegating On-chain Schema Registration via ECDSA

async function delegateSignSchema(
  schema: OnChainSchema,
  options: DelegateSignSchemaOptions
): Promise<SchemaDelegationSignature>;

Parameters

NameTypeDescription

schema

OnChainSchema

An on-chain schema.

options

DelegateSignSchemaOptions

Options for delegate signing the schema.

DelegateSignSchemaOptions

NameType

chain

EvmChains

The EVM chain you are targetting.

delegationAccount?

PrivateKeyAccount

The signer account that signs the message. See viem/accounts. If this is null, a signer from window.ethereum will be used.

rpcUrl?

string

Optional RPC URL.

walletClient?

WalletClient

Optional WalletClient from viem to use for transactions.

Last updated

Logo

Copyright Sign 2021-2024