---
title: Create Schema
description: Creates a new schema that defines the structure for attestations
---

Creates a new schema that defines the structure and validation rules for
attestations. This instruction allows credential authorities to create schemas
that specify what fields an attestation should contain and how they should be
formatted.

## Parameters

| Parameter       | Type                 | Description                                                                 |
| --------------- | -------------------- | --------------------------------------------------------------------------- |
| `payer`         | `Signer`             | The account that will pay for the transaction                               |
| `authority`     | `Signer`             | The authority of the credential                                             |
| `credential`    | `PublicKey \| Pda`   | The credential account this schema will be associated with                  |
| `schema`        | `PublicKey \| Pda`   | The schema account to create                                                |
| `systemProgram` | `PublicKey \| Pda`   | The System Program account (defaults to '11111111111111111111111111111111') |
| `name`          | `string`             | The name of the schema                                                      |
| `description`   | `string`             | A detailed description of the schema's purpose                              |
| `layout`        | `ReadonlyUint8Array` | The binary layout definition of the schema                                  |
| `fieldNames`    | `string[]`           | The names of fields in the schema                                           |

## Returns

Returns a `TransactionBuilder` that can be used to build and send the
transaction.

## Example

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

const transaction = getCreateSchemaInstruction({
  payer: payerSigner,
  authority: authoritySigner,
  credential: credentialPublicKey,
  schema: schemaPublicKey,
  systemProgram: systemProgramPublicKey,
  name: "Identity Verification",
  description: "Schema for verifying user identity information",
  layout: schemaLayoutBytes,
  fieldNames: ["fullName", "dateOfBirth", "nationality"]
});

// Send the transaction
await transaction.sendAndConfirm();
```

## Important Notes

- The payer must be a signer of the transaction
- The authority must be a signer of the transaction and must be the authority of
  the credential
- The schema account must be writable
- The credential account must be readable
- This operation requires the System Program for rent exemption calculations
- The schema name should be descriptive and unique within the credential
- The description should provide clear information about the schema's purpose
  and usage
- The layout must be a valid binary format that defines the structure of
  attestation data
- The fieldNames array must match the fields defined in the layout
- The schema can be paused later if needed
- The schema can be versioned to support evolution of the data structure
- All attestations created under this schema must conform to its structure
