> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Attestations

> Verified claims or statements in the Solana Attestation System

An attestation represents a verified claim or statement in the Solana
Attestation System. Attestations are created by authorized signers under a
credential and follow a specific schema. Each attestation contains the actual
data of the claim and metadata about its creation and validity.

## Structure

The Attestation struct represents an attestation in the Solana Attestation
System. Each attestation links to a credential, schema, and contains the
attested data along with metadata about its creation and validity period.

## Type Definitions

### Attestation

```typescript
export type Attestation = {
  discriminator: number; // Internal discriminator
  nonce: Address; // Unique identifier for the attestation
  credential: Address; // Associated credential address
  schema: Address; // Associated schema address
  data: ReadonlyUint8Array; // Attestation data
  signer: Address; // Address of the signer who created the attestation
  expiry: bigint; // Expiration timestamp
  tokenAccount: Address; // Associated token account
};
```

### AttestationArgs

```typescript
export type AttestationArgs = {
  discriminator: number;
  nonce: Address;
  credential: Address;
  schema: Address;
  data: ReadonlyUint8Array;
  signer: Address;
  expiry: number | bigint; // Can be either number or bigint
  tokenAccount: Address;
};
```

## Methods

### Fetching Attestations

| Method                     | Description                                              | Parameters                                                                               | Returns                                |
| -------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------- |
| `fetchAttestation`         | Fetches a single attestation by its address              | `rpc`: RPC context, `address`: Attestation's address, `config?`: Fetch config            | `Promise<Account<Attestation>>`        |
| `fetchMaybeAttestation`    | Safely fetches an attestation, returns null if not found | `rpc`: RPC context, `address`: Attestation's address, `config?`: Fetch config            | `Promise<MaybeAccount<Attestation>>`   |
| `fetchAllAttestation`      | Fetches multiple attestations by their addresses         | `rpc`: RPC context, `addresses`: Array of attestation addresses, `config?`: Fetch config | `Promise<Account<Attestation>[]>`      |
| `fetchAllMaybeAttestation` | Safely fetches multiple attestations, skips not found    | `rpc`: RPC context, `addresses`: Array of attestation addresses, `config?`: Fetch config | `Promise<MaybeAccount<Attestation>[]>` |

### Serialization

| Method                  | Description                           | Parameters | Returns                               |
| ----------------------- | ------------------------------------- | ---------- | ------------------------------------- |
| `getAttestationEncoder` | Gets the encoder for attestation data | None       | `Encoder<AttestationArgs>`            |
| `getAttestationDecoder` | Gets the decoder for attestation data | None       | `Decoder<Attestation>`                |
| `getAttestationCodec`   | Gets the codec for attestation data   | None       | `Codec<AttestationArgs, Attestation>` |

## Usage Examples

The examples use the `rpc` from [Create a Client](/developers/docs/tools/attestations/quickstart/installation#create-a-client).

### Fetching a Single Attestation

```typescript
import { fetchAttestation } from "sas-lib";

const attestation = await fetchAttestation(rpc, attestationAddress);
// Fields live under `.data`
console.log("Attestation nonce:", attestation.data.nonce);
```

### Fetching Multiple Attestations

```typescript
import { fetchAllAttestation } from "sas-lib";

const attestations = await fetchAllAttestation(rpc, [
  attestation1Address,
  attestation2Address
]);
attestations.forEach((attestation) =>
  console.log("Attestation:", attestation.data.nonce)
);
```

### Safe Fetching

```typescript
import { fetchMaybeAttestation } from "sas-lib";

const attestation = await fetchMaybeAttestation(rpc, attestationAddress);
if (attestation.exists) {
  console.log("Attestation found:", attestation.data.nonce);
} else {
  console.log("Attestation not found");
}
```

## Important Notes

- The `discriminator` field is used internally and should not be modified
- The `nonce` provides a unique identifier for each attestation
- `credential` and `schema` fields link the attestation to its associated
  credential and schema
- The `data` field contains the actual attestation data and should be properly
  encoded/decoded according to the schema
- `signer` must be one of the authorized signers of the associated credential
- `expiry` determines when the attestation becomes invalid
- `tokenAccount` links the attestation to a specific token account
- Attestations can only be created by authorized signers of the associated
  credential
- The attestation data must conform to the structure defined by the associated
  schema
