# 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

{% hint style="warning" %}
NOTE: You must provide an API key when initializing your SignClient to create offchain attestations. You can generate a key [here](https://developer.sign.global/). For more information, see [Installation](/for-builders/index-1/npm-sdk/installation.md).
{% endhint %}

### Creating an Attestation

```ts
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

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

### Delegating On-chain Attestation via ECDSA

```ts
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

```typescript
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

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

#### Parameters

| Name          | Type     | Description                                          |
| ------------- | -------- | ---------------------------------------------------- |
| attestationId | `string` | The ID of the attestation we are trying to retrieve. |

#### Example

```typescript
const res = await client.getAttestation("0x44");
```

## Revoking Attestations

### Revoke an Attestation

```ts
async function revokeAttestation(
  attestationId: string,
  options?: RevokeAttestationOptions
): Promise<RevokeAttestationResult>;
```

#### Parameters

<table><thead><tr><th width="219">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>attestationId</td><td><code>string</code></td><td>The ID of the attestation we are revoking.</td></tr><tr><td>options?</td><td><code>RevokeAttestationOptions</code></td><td>Options for revoking an attestation.</td></tr></tbody></table>

#### RevokeAttestationOptions

<table><thead><tr><th width="219">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>reason?</td><td><code>string</code></td><td>Reason for the revocation.</td></tr><tr><td>delegateSignature?</td><td><code>string</code></td><td>The user's delegate signature when revoking an attestation on their behalf.</td></tr><tr><td>getTxHash?</td><td><code>(txHash: `0x${string}`) => void</code></td><td>An optional callback that immediately returns the transaction hash.</td></tr></tbody></table>

#### Example

```typescript
const res = await client.revokeAttestation("0x44");
```

### Delegating On-chain Revocation via ECDSA

```ts
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

```typescript
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,
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sign.global/for-builders/index-1/npm-sdk/usage/attestations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
