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

# PSR API

> OpaqueClient methods for schema registry and attestation lifecycle.

All PSR admin methods take `chain: "ethereum" | "solana"` as the first argument and return chain-neutral types.

## Types

### `CreateSchemaParams`

```ts theme={"dark"}
{
  name: string;
  fieldDefinitions: string | FieldDef[];
  revocable: boolean;
  resolver?: string;           // EVM address or Solana program pubkey
  schemaExpiry?: PsrExpiryInput;
}
```

### `IssueAttestationParams`

```ts theme={"dark"}
{
  schemaId: string;            // 0x bytes32 hex
  recipient: string;           // meta-address, stealth address, or hash
  fieldValues: Record<string, string>;
  expiration?: PsrExpiryInput;
  refUid?: string;
  announce?: boolean;          // default true for meta-address recipients
}
```

### `PsrExpiryInput`

```ts theme={"dark"}
{ slotOrBlock?: number } | { dateTime?: string }  // ISO datetime
```

***

## Schema lifecycle

### `createSchema(chain, params)`

Register a new schema. Returns tx hash and derived `schemaId`.

```ts theme={"dark"}
const { txHash, schemaId } = await client.createSchema("ethereum", {
  name: "kyc-v1",
  fieldDefinitions: "bool passed, u64 score",
  revocable: true,
});
```

**Signers:** EVM wallet or Solana wallet per chain.

***

### `getMySchemas(chain)`

List schemas where this wallet is authority or delegate.

```ts theme={"dark"}
const schemas: SchemaV2[] = await client.getMySchemas("ethereum");
```

Read-only; no signer required beyond RPC / Solana connection.

***

### `deprecateSchema(chain, schemaId)`

Authority-only. Irreversibly blocks new attestations.

```ts theme={"dark"}
await client.deprecateSchema("ethereum", schemaId);
```

***

### `addSchemaDelegate(chain, schemaId, delegate)`

Authorize another address to issue under this schema (max 10).

```ts theme={"dark"}
await client.addSchemaDelegate("ethereum", schemaId, delegateAddress);
```

***

### `removeSchemaDelegate(chain, schemaId, delegate)`

Revoke delegate issuance rights.

```ts theme={"dark"}
await client.removeSchemaDelegate("solana", schemaId, delegatePubkey);
```

***

## Attestations

### `issueAttestation(chain, params)`

Issue a schema-bound V2 attestation to a stealth identity. Resolves the recipient,
encodes fields, submits `attest`, and optionally announces with V2 `0xB2` metadata so
the recipient can discover it with `discoverTraitsV2`.

```ts theme={"dark"}
const { txHash, uid, stealthAddressHash } = await client.issueAttestation("ethereum", {
  schemaId,
  recipient: client.getMetaAddressHex(),
  fieldValues: { passed: "true", score: "100" },
});
```

***

### `getMyIssuedAttestations(chain)`

List attestations issued by this wallet.

```ts theme={"dark"}
const list: AttestationV2[] = await client.getMyIssuedAttestations("ethereum");
```

***

## Legacy V1 issuer helpers

### `encodeReputationMetadata(viewTag, attestationId)`

Encode legacy V1 PSR metadata bytes for `announce` (`viewTag || 0xA7 || attestationId`).
New schema-bound attestations issued by `issueAttestation` use V2 metadata instead.

```ts theme={"dark"}
const metadata = client.encodeReputationMetadata(viewTag, 42n);
```

***

### `prepareReputationAssignment(recipientMetaAddressHex, attestationId)`

Derive stealth send material with legacy V1 PSR metadata embedded.

```ts theme={"dark"}
const prep = client.prepareReputationAssignment(metaHex, attestationId);
```

***

### `buildAssignReputationTransaction(recipientMetaAddressHex, attestationId)`

Calldata for a legacy V1 announce-with-PSR-metadata transaction (no asset transfer).

```ts theme={"dark"}
const req = client.buildAssignReputationTransaction(metaHex, attestationId);
```

***

## Full issuer E2E (Ethereum)

```ts theme={"dark"}
const { schemaId } = await client.createSchema("ethereum", {
  name: `demo-${Date.now()}`,
  fieldDefinitions: "bool passed, string note",
  revocable: true,
});

await client.issueAttestation("ethereum", {
  schemaId,
  recipient: client.getMetaAddressHex(),
  fieldValues: { passed: "true", note: "hello" },
});

const issued = await client.getMyIssuedAttestations("ethereum");
```

See [Create a schema](/guides/create-schema) and [Issue an attestation](/guides/issue-attestation) for step-by-step guides.
