> For the complete documentation index, see [llms.txt](https://docs.sign.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sign.global/for-builders/index/index/indexing-service.md).

# Usage & Examples

## Schemas

### Querying Schemas

```typescript
async function querySchemaList(query: {
  id?: string;
  registrant?: string;
  mode?: "offchain" | "onchain";
  page: number;
  size?: number;
}): Promise<
  PageInfo & {
    rows: SchemaInfo[];
  }
>;
```

#### Parameters

| Name        | Type / Value          | Description                                                      |
| ----------- | --------------------- | ---------------------------------------------------------------- |
| id?         | `string`              | The schema ID you are querying for.                              |
| registrant? | `string`              | Find schemas that were created by a specific registrant address. |
| mode?       | `offchain`, `onchain` | The schema's location.                                           |
| page        | `number`              | The page to fetch.                                               |
| size?       | `number`              | The number of results to return.                                 |

#### Example

```typescript
const res = await indexService.querySchemaList({
  id: "onchain_evm_11155111_0xd",
  registrant: "0x526dDf0Cc975E0b5B039c85b5cD7ba1e1300500e",
  mode: "onchain",
  page: 1,
  size: 2,
});
```

### Getting a Schema By ID

```typescript
async function querySchema(schemaId: string): Promise<SchemaInfo | null>;
```

#### Parameters

| Name     | Type     | Description                       |
| -------- | -------- | --------------------------------- |
| schemaId | `string` | The ID of the schema to retrieve. |

#### Example

```typescript
const res = await indexService.querySchema("onchain_evm_11155111_0xd");
```

## Attestations

### Querying Attestations

```typescript
async function queryAttestationList(query: {
  id?: string;
  schemaId?: string;
  attester?: string;
  page: number;
  mode?: "offchain" | "onchain";
  indexingValue?: string;
}): Promise<
  PageInfo & {
    rows: AttestationInfo[];
  }
>;
```

#### Parameters

| Name           | Type / Value          | Description                                            |
| -------------- | --------------------- | ------------------------------------------------------ |
| id?            | `string`              | The attestation ID you are querying for.               |
| schemaId?      | `string`              | Find attestations that belong to a specific schema ID. |
| attester?      | `string`              | Find attestations that a specific attester created.    |
| page           | `number`              | The page to fetch.                                     |
| mode?          | `offchain`, `onchain` | The attestation's location.                            |
| indexingValue? | `string`              | Find attestations with a specific indexing value.      |

#### Example

```typescript
const res = await indexService.queryAttestationList({
  id: "",
  schemaId: "",
  attester: "",
  page: 1,
  mode: "onchain",
  indexingValue: "",
});
```

### Getting an Attestation By ID

```typescript
async function queryAttestation(
  attestationId: string
): Promise<AttestationInfo | null>;
```

#### Parameters

| Name          | Type     | Description                       |
| ------------- | -------- | --------------------------------- |
| attestationId | `string` | The ID of the schema to retrieve. |

#### Example

```typescript
const res = await indexService.queryAttestation("onchain_evm_11155111_0x5");
```

## Utils

### Decoding Attestation Data

```typescript
function decodeOnChainData(
  data: any,
  dataLocation: DataLocationOnChain,
  schemaData: SchemaItem[]
): any;
```

#### Parameters

| Name                | Type / Value          | Description                                                     |
| ------------------- | --------------------- | --------------------------------------------------------------- |
| data                | `string`              | The hex string retrieved from an onchain attestation object.    |
| DataLocationOnChain | `DataLocationOnChain` | Location of the data. Either `ONCHAIN`, `ARWEAVE`, or `IPFS`.   |
| schemaData          | `string`              | The data string of the schema that this attestation belongs to. |

#### Example

<pre class="language-typescript"><code class="lang-typescript">const { decodeOnChainData } from "@ethsign/sp-sdk";

const attestationData = "0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b1987e041b79727cd2a190b53d86c2d1cd2869ef0000000000000000000000000000000000000000000000000000000000000012486f6d65776f726b2f446166742050756e6b0000000000000000000000000000";
<strong>const schemaData = `[{"name":"contractDetails","type":"string"},{"name":"signer","type":"address"}]`;
</strong>const res = decodeOnChainData(
  attestationData,
  DataLocationOnChain.ONCHAIN,
  JSON.parse(schemaData)
);
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sign.global/for-builders/index/index/indexing-service.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
