Attestations

Types

Attestation (Onchain)

Name
Type
Description

schemaId

string

Schema ID for this attestation.

linkedAttestationId?

string, null

The ID of the attestation that this attestation references.

validUntil?

number

Timestamp that this attestation is valid until.

revoked?

boolean, null

Whether or not this attestation is revoked.

recipients?

string[]

List of recipient addresses.

indexingValue

string

The indexing value of this attestation. Can be used for filtering while querying using the indexing service.

attester?

address

The attester's address.

attestTimestamp?

number

Timestamp that the attestation was created.

revokeTimestamp?

number

Timestamp that the attestation was revoked.

dataLocation?

DataLocationOnchain

Where Attestation.data is stored. See DataLocation.DataLocation.

data

{ [key: string]: any }, string

If dataLocation is ONCHAIN, data is the data object. Otherwise, data is a string of the CID from the storage provider.

Attestation (Offchain)

Name
Type
Description

schemaId

string

Schema ID for this attestation.

linkedAttestationId?

string, null

The ID of the attestation that this attestation references.

validUntil?

number

Timestamp that this attestation is valid until.

revoked?

boolean, null

Whether or not this attestation is revoked.

recipients?

string[]

List of recipient addresses.

indexingValue

string

The indexing value of this attestation. Can be used for filtering while querying using the indexing service.

attester?

address

The attester's address.

dataLocation?

DataLocationOffchain

Where Attestation.data is stored. See DataLocation.DataLocation.

data

{ [key: string]: any }

The data object to be stored with this attestation.

Creating Attestations

Creating an Attestation

async function createAttestation(
  attestation: Attestation,
  options?: CreateAttestationOnChainOptions
): Promise<AttestationResult>;

Parameters

Name
Type
Description

attestation

Attestation

An attestation object.

options?

CreateAttestationOnChainOptions

Options for creating an attestation.

CreateAttestationOnChainOptions

Name
Type
Description

resolverFeesETH?

BigInt

ETH fees to be sent to the schema hook, in wei.

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.

recipientEncodingType?

RecipientEncodingType

Defines the attestation's recipient encoding type as either an address or string.

extraData?

0x${string}

Extra data that is passed to the schema hook. This data is not stored by the Sign Protocol contract.

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: DelegateSignAttestationOptions
): Promise<AttestationDelegationSignature>;

Parameters

Name
Type
Description

attestation

Attestation

An attestation object.

options

DelegateSignAttestationOptions

Options for delegate attestation signature.

DelegateSignAttestationOptions

Name
Type
Description

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.

recipientEncodingType?

RecipientEncodingType

Defines the attestation's recipient encoding type as either an address or string.

rpcUrl?

string

Optional RPC URL.

walletClient?

WalletClient

Optional WalletClient from viem to use for transactions.

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

Name
Type
Description

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?: RevokeAttestationOptions
): Promise<RevokeAttestationResult>;

Parameters

Name
Type
Description

attestationId

string

The ID of the attestation we are revoking.

options?

RevokeAttestationOptions

Options for revoking an attestation.

RevokeAttestationOptions

Name
Type
Description

reason?

string

Reason for the revocation.

delegateSignature?

string

The user'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

Name
Type
Description

attestationId

string

The ID of the attestation we are revoking.

options

DelegateSignRevokeAttestationOptions

Options for delegate revoking an attestation.

DelegateSignRevokeAttestationOptions

Name
Type
Description

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.

rpcUrl?

string

Optional RPC URL.

walletClient?

WalletClient

Optional WalletClient from viem to use for transactions.

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

Logo

Copyright Sign 2021-2024