> ## 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.

# Credentials

> Attestation authorities in the Solana Attestation System

A credential represents an attestation authority in the Solana Attestation
System. Credentials define who can issue attestations and what types of
attestations they can issue. Each credential has a set of authorized signers who
can create attestations under its authority.

## Structure

The Credential struct represents a credential in the Solana Attestation System.
Each credential defines an authority that can issue attestations and the signers
authorized to do so.

## Type Definitions

### Credential

```typescript
export type Credential = {
  discriminator: number; // Internal discriminator
  authority: Address; // Authority public key
  name: ReadonlyUint8Array; // Credential name
  authorizedSigners: Array<Address>; // List of authorized signers
};
```

## Methods

### Fetching Credentials

| Method                    | Description                                            | Parameters                                                                              | Returns                               |
| ------------------------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------- | ------------------------------------- |
| `fetchCredential`         | Fetches a single credential by its address             | `rpc`: RPC context, `address`: Credential's address, `config?`: Fetch config            | `Promise<Account<Credential>>`        |
| `fetchMaybeCredential`    | Safely fetches a credential, returns null if not found | `rpc`: RPC context, `address`: Credential's address, `config?`: Fetch config            | `Promise<MaybeAccount<Credential>>`   |
| `fetchAllCredential`      | Fetches multiple credentials by their addresses        | `rpc`: RPC context, `addresses`: Array of credential addresses, `config?`: Fetch config | `Promise<Account<Credential>[]>`      |
| `fetchAllMaybeCredential` | Safely fetches multiple credentials, skips not found   | `rpc`: RPC context, `addresses`: Array of credential addresses, `config?`: Fetch config | `Promise<MaybeAccount<Credential>[]>` |

### Serialization

| Method                 | Description                          | Parameters | Returns                             |
| ---------------------- | ------------------------------------ | ---------- | ----------------------------------- |
| `getCredentialEncoder` | Gets the encoder for credential data | None       | `Encoder<CredentialArgs>`           |
| `getCredentialDecoder` | Gets the decoder for credential data | None       | `Decoder<Credential>`               |
| `getCredentialCodec`   | Gets the codec for credential data   | None       | `Codec<CredentialArgs, Credential>` |

## Usage Examples

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

### Fetching a Single Credential

```typescript
import { getUtf8Decoder } from "@solana/kit";
import { fetchCredential } from "sas-lib";

const credential = await fetchCredential(rpc, credentialAddress);
// Fields live under `.data`; `name` is a Uint8Array of UTF-8 bytes
console.log("Credential name:", getUtf8Decoder().decode(credential.data.name));
```

### Fetching Multiple Credentials

```typescript
import { getUtf8Decoder } from "@solana/kit";
import { fetchAllCredential } from "sas-lib";

const credentials = await fetchAllCredential(rpc, [
  credential1Address,
  credential2Address
]);
credentials.forEach((credential) =>
  console.log("Credential:", getUtf8Decoder().decode(credential.data.name))
);
```

### Safe Fetching

```typescript
import { getUtf8Decoder } from "@solana/kit";
import { fetchMaybeCredential } from "sas-lib";

const credential = await fetchMaybeCredential(rpc, credentialAddress);
if (credential.exists) {
  console.log(
    "Credential found:",
    getUtf8Decoder().decode(credential.data.name)
  );
} else {
  console.log("Credential not found");
}
```

## Important Notes

- The `discriminator` field is used internally and should not be modified
- The `authority` field determines who has control over the credential
- `authorizedSigners` is an array of addresses that are allowed to create
  attestations under this credential
- The `name` field is stored as a byte array and should be properly
  encoded/decoded according to your application's needs
- Only authorized signers can create attestations under a credential
- The authority can modify the list of authorized signers
