Attestations

Creating Attestations

Creating an Attestation

async function createAttestation(
  attestation: Attestation,
  options?: {
    delegationSignature?: string;
    getTxHash?: (txHash: `0x${string}`) => void;
  }
): Promise<AttestationResult>;

Parameters

NameTypeDescription

attestation

Attestation

An attestation object.

delegationSignature?

string

The attester's delegate signature when creating an attestation on their behalf.

getTxHash?

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

An optional callback that immediately returns the transaction hash.

Example

const res = await client.createAttestation({
  schemaId: '0x3e',
  data: { name: 'a' },
  indexingValue: 'xxx',
});

Delegating On-chain Attestation via ECDSA

async function delegateSignAttestation(
  attestation: Attestation,
  options: {
    chain: EvmChains;
    delegationAccount?: PrivateKeyAccount;
  }
): Promise<AttestationDelegationSignature>;

Parameters

NameTypeDescription

attestation

Attestation

An attestation object.

chain

EvmChains

The EVM chain we are targeting.

delegationAccount?

PrivateKeyAccount

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

Example

const { privateKeyToAccount } = require('viem/accounts');
const delegationPrivateKey = '0x...';
const delegationResult = await delegateSignAttestation(
  { schemaId: '0x3e', data: { name: 'a' }, indexingValue: 'xxx' },
  {
    chain: EvmChains.baseSepolia,
    delegationAccount: privateKeyToAccount(delegationPrivateKey),
  }
);
const res = await client.createAttestation(delegationResult.attestation, {
  delegationSignature: delegationResult.delegationSignature,
});

Retrieving an Attestation

async function getAttestation(attestationId: string): Promise<Attestation>;

Parameters

NameTypeDescription

attestationId

string

The ID of the attestation we are trying to retrieve.

Example

const res = await client.getAttestation('0x44');

Revoking Attestations

Revoke an Attestation

async function revokeAttestation(
  attestationId: string,
  options?: {
    reason?: string;
    delegationSignature?: string;
    getTxHash?: (txHash: `0x${string}`) => void;
  }
): Promise<RevokeAttestationResult>;

Parameters

NameTypeDescription

attestationId

string

The ID of the attestation we are revoking.

reason

string

Reason for the revocation.

delegateSignature

string

The attester's delegate signature when revoking an attestation on their behalf.

getTxHash?

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

An optional callback that immediately returns the transaction hash.

Example

const res = await client.revokeAttestation('0x44');

Delegating On-chain Revocation via ECDSA

async function delegateSignRevokeAttestation(
  attestationId: string,
  options: {
    chain: EvmChains;
    delegationAccount?: PrivateKeyAccount;
    reason?: string;
  }
): Promise<RevokeDelegationSignature>;

Parameters

NameTypeDescription

attestationId

string

The ID of the attestation we are revoking.

chain

EvmChains

The EVM chain we are targeting.

delegationAccount?

PrivateKeyAccount

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

reason

string

Reason for the revocation.

Example

const { privateKeyToAccount } = require('viem/accounts');
const delegationPrivateKey = '0x...';
const delegationResult = await delegateSignRevokeAttestation('0x46', {
  chain: EvmChains.baseSepolia,
  reason: 'revoke reason',
  delegationAccount: privateKeyToAccount(delegationPrivateKey),
});
const res = await client.revokeAttestation(delegationResult.attestationId, {
  reason: delegationResult.reason,
  delegationSignature: delegationResult.delegationSignature,
});

Last updated