Schemas
Types
Schema (Onchain)
| Name |
Type |
Description |
| name |
string |
Schema name. |
| description? |
string |
Schema description. |
| revocable? |
boolean |
Whether Attestations that adopt this Schema can be revoked. |
| maxValidFor? |
number |
Maximum number of seconds an Attestation can remain valid. 0 means forever. Enforced through Attestation.validUntil. |
| hook? |
address |
Contract address of this schema's hook. |
| registrant |
address |
Wallet address that registered this schema. |
| dataLocation? |
DataLocationOnChain |
Where Schema.data is stored. See DataLocation.DataLocation. |
| data |
SchemaItem[] or string |
This schema's data structure. SchemaItem[] when dataLocation=ONCHAIN; the ID of the data when dataLocation=ARWEAVE or IPFS. |
Schema (Offchain)
| Name |
Type |
Description |
| name |
string |
Schema name. |
| description? |
string |
Schema description. |
| revocable? |
boolean |
Whether Attestations that adopt this Schema can be revoked. |
| maxValidFor? |
number |
Maximum number of seconds an Attestation can remain valid. 0 means forever. Enforced through Attestation.validUntil. |
| dataLocation? |
DataLocationOffChain |
Where Schema.data is stored. See DataLocation.DataLocation. |
| data |
SchemaItem[] |
This schema's data structure. |
Usage
Registering a schema
async function createSchema(
schema: Schema,
options?: { getTxHash?: (txHash: `0x${string}`) => void }
): Promise<SchemaResult>;
Parameters
| Name |
Type |
Description |
| schema |
Schema |
The schema being registered. |
| options? |
CreateSchemaOptions |
Options for creating a schema. |
CreateSchemaOptions
| Name |
Type |
Description |
| delegationSignature? |
string |
The user's delegate signature for creating a schema on their behalf. Get it from delegateSignSchema. |
| getTxHash? |
(txHash: `0x${string}`) => void |
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
| Name |
Type |
Description |
| schemaId |
string |
The ID of the schema to retrieve. |
Example
const res = await client.getSchema("0x3e");
Delegating on-chain schema registration via ECDSA
Warning
This helper signs in the pre-1.1.4 format. Sign Protocol contracts at version 1.1.4, the version on all maintained deployments, reject those signatures with InvalidDelegateSignature. Until the SDK is updated, build the signature as described in Delegated signatures.
async function delegateSignSchema(
schema: OnChainSchema,
options: DelegateSignSchemaOptions
): Promise<SchemaDelegationSignature>;
Parameters
| Name |
Type |
Description |
| schema |
OnChainSchema |
An on-chain schema. |
| options |
DelegateSignSchemaOptions |
Delegate signing options. |
DelegateSignSchemaOptions
| Name |
Type |
|
| chain |
EvmChains |
The target EVM chain. |
| delegationAccount? |
PrivateKeyAccount |
The account that signs the message. See viem/accounts. If null, a signer from window.ethereum is used. |
| rpcUrl? |
string |
Optional RPC URL. |
| walletClient? |
WalletClient |
Optional WalletClient from viem to use for transactions. |