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 this attestation is revoked. |
| recipients? |
string[] |
List of recipient addresses. |
| indexingValue |
string |
Indexing value used to filter queries in 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 |
The data object if dataLocation is ONCHAIN; otherwise, the storage provider's CID as a string. |
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 this attestation is revoked. |
| recipients? |
string[] |
List of recipient addresses. |
| indexingValue |
string |
Indexing value used to filter queries in 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 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 |
Callback that immediately returns the transaction hash. |
| recipientEncodingType? |
RecipientEncodingType |
Recipient encoding type: address or string. |
| extraData? |
0x${string} |
Extra data passed to the schema hook. 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
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 delegateSignAttestation(
attestation: Attestation,
options: DelegateSignAttestationOptions
): Promise<AttestationDelegationSignature>;
Parameters
| Name |
Type |
Description |
| attestation |
Attestation |
An attestation object. |
| options |
DelegateSignAttestationOptions |
Delegate signing options. |
DelegateSignAttestationOptions
| Name |
Type |
Description |
| 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. |
| recipientEncodingType? |
RecipientEncodingType |
Recipient encoding type: 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 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 to revoke. |
| 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 | Callback that immediately returns the transaction hash. |
Example
const res = await client.revokeAttestation("0x44");
Delegating on-chain revocation 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 delegateSignRevokeAttestation(
attestationId: string,
options: {
chain: EvmChains;
delegationAccount?: PrivateKeyAccount;
reason?: string;
}
): Promise<RevokeDelegationSignature>;
Parameters
| Name |
Type |
Description |
| attestationId |
string |
The ID of the attestation to revoke. |
| options |
DelegateSignRevokeAttestationOptions |
Delegate revocation options. |
DelegateSignRevokeAttestationOptions
| Name |
Type |
Description |
| 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. |
| 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,
});