> 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/getting-started/tutorials/building-a-simple-notary-platform/querying-attestations.md).

# Querying Attestations

So now, how can you verify if Alice attested to Bob's signature? We will be using Sign Protocol's Indexing Service to do exactly that!

## Querying for an Attestation

You can query for an attestation using our NPM SDK or by making requests to our REST API.

### NPM SDK

Our [NPM SDK](#npm-sdk) includes an `IndexService` that you can use to query schemas and attestations.

```typescript
import { IndexService } from "@ethsign/sp-sdk";

async function queryAttestations() {
  const indexService = new IndexService("testnet");
    
  const attId = `onchain_evm_${chainId}_${attestationId}`;
  const res = await indexService.queryAttestationList({
    schemaId: "onchain_evm_84532_0x34", // Your full schema's ID
    attester: "0x...", // Alice's address
    page: 1,
    mode: "onchain", // Data storage location
    indexingValue: "0x...".toLowerCase(), // Bob's address
  });
  
  return {
    success: true,
    attestations: response.rows,
  };
}
```

### REST API

Alternatively, we will create a helper function that we can reuse to make requests to the Sign Protocol Indexing Service.

```typescript
import axios from "axios";

// Generate a function for making requests to the Sign Protocol Indexing Service
async function makeAttestationRequest(endpoint: string, options: any) {
  const url = `https://testnet-rpc.sign.global/api/${endpoint}`;
  const res = await axios.request({
    url,
    headers: {
      "Content-Type": "application/json; charset=UTF-8",
    },
    ...options,
  });
  // Throw API errors
  if (res.status !== 200) {
    throw new Error(JSON.stringify(res));
  }
  // Return original response
  return res.data;
}
```

Next, we will use this function to query for Alice's attestation of Bob's signature.

```typescript
async function queryAttestations() {
  const response = await makeAttestationRequest("index/attestations", {
    method: "GET",
    params: {
      mode: "onchain", // Data storage location
      schemaId: "onchain_evm_84532_0x34", // Your full schema's ID
      attester: "0x...", // Alice's address
      indexingValue: "0x...".toLowerCase(), // Bob's address
    },
  });

  // Make sure the request was successfully processed.
  if (!response.success) {
    return {
      success: false,
      message: response?.message ?? "Attestation query failed.",
    };
  }

  // Return a message if no attestations are found.
  if (response.data?.total === 0) {
    return {
      success: false,
      message: "No attestation for this address found.",
    };
  }

  // Return all attestations that match our query.
  return {
    success: true,
    attestations: response.data.rows,
  };
}
```

Great! So now, we have a list of available attestations that Alice has made, of Bob's signature. If we only need to check for the existence of at least one attestation that matches our criteria, we could stop here. But what if we wanted to validate the message that Alice was attesting? Perhaps there are several different contracts that Alice has notarized for Bob and we are looking for a specific one. When you are ready, move on to the next page where we will parse the attestation data.


---

# 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/getting-started/tutorials/building-a-simple-notary-platform/querying-attestations.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.
