# Reference: @chainrender/client

> **Verify signatures against the shipped types.** Code examples in these docs illustrate usage and intent. The
> authoritative signatures are the TypeScript types shipped with `@chainrender/client` — your editor's
> autocomplete and the package's `.d.ts` files are the source of truth. Where an example and the shipped type
> differ, the shipped type wins.


The SDK is the headless, framework-agnostic core for authoring, grading, and rendering ChainRender apps. Install:

```bash
npm install @chainrender/client viem
```

## Exports

| Import | Purpose |
|---|---|
| `@chainrender/client` | Authoring core: `compose`, `compileComponent`, `grade`, `vocabulary`, IR builders |
| `@chainrender/client/runtime` | Rendering + actions: `renderComponent`, `buildActionRequest`, `describeAction`, wallet |
| `@chainrender/client/react` | React components + hooks (`ChainRenderView`, live-grade badge) |
| `@chainrender/client/miniapp` | Farcaster Mini App manifest + embed builders |

## Core functions

- **`compose.*`** — build a component from the closed vocabulary (box, heading, text, button, image, chart, table,
  controls, …). Constrained by construction: you can't express outside the vocabulary.
- **`compileComponent(node)`** → `{ hash, hex, … }` — the content-addressed artifact. The hash is the app identity.
- **`grade(node, opts?)`** → `{ letter, word, locks, envelope, deviations }` — the trust grade, drift-locked with the chain. `opts.pinnedDep` (a raw-CIDv1 IPFS dependency, `{ protocol:"ipfs", cid }`) grades **B (Pinned)**, fail-closed to A if unverifiable; also read from a `pinnedDep` on the node. Helpers: `isVerifiablePinnedDep`, `pinnedDependencyLevel`, `pinnedCid`, `RAW_CIDV1`, type `PinnedDep`.
- **`vocabulary()`** — the machine-readable schema (node types, a11y and behaviour fields, enums, capabilities,
  resolver kinds), derived from the real constants, so tooling never hardcodes them. See
  **[The Vocabulary](./vocabulary.md)**.
- **`checkNode(tree, opts?)`** → `{ ok, issues, nodeCount, depth }` *(0.10.0)* — checks a tree against everything
  `compile()` reads and reports what it would silently drop (unknown fields, bad enum values, a11y on images, `args`
  on batch members) plus the node/depth/size limits. Each issue has a `path`, a `code` (`unknown-field`,
  `ignored-field`, `authoring-field`, `required`, `type`, `enum`, `format`, `limit`) and a message.
  `{ authoring: true }` accepts the builder-only fields — `argValues` on slots and images, `image.scene`, a root
  `pinnedDep`, and `_`-prefixed design-time keys (0.10.1).
- **`nodeJsonSchema(opts?)`** *(0.10.0)* — the same rules as a strict JSON Schema (draft 2020-12), to hand to an AI
  tool or validator. Also exported: `fieldsOf`, `NODE_TYPES`, `NODE_ENUMS`, `TYPE_FIELDS`, `A11Y_FIELDS`,
  `BEHAVIOR_FIELDS`, `AUTHORING_FIELDS`, `IGNORED_BY_COMPILE`, `IGNORED_NESTED`, `NODE_LIMITS`. Every field is listed on
  **[Node Fields](./node-fields.md)**.
- **`kinds` / `RESOLVER_KINDS`** — every first-party resolver kind with its args, data edge and capability, plus the
  per-family encoders (for example `kinds.ens.encodeNameArgs(address)`, `kinds.ens.encodeV2Args(resolver, inner,
  isText)`). A descriptor with `argsEncoding: "packed"` takes raw bytes, not `abi.encode`. The full list:
  **[All Resolver Kinds](./resolver-kinds.md)**.

`peerDependencies`: `viem` (required); `react` + the Farcaster miniapp SDK (optional, for those subpaths).

## App metadata

The app-metadata seam (see [App Metadata](../concepts/app-metadata.md)) is exposed through the SDK so authoring tools can read and write an app's on-chain descriptive info:

- **`encodeAppMeta(obj)`** → compact JSON string for the scene binding's `meta` field. Strips empties, size-capped.
- **`decodeAppMeta(str)`** → `AppMeta` object; never throws, returns `{ v: 1 }` on any malformed input.
- **`getAppTitle` / `getAppAuthor` / `getAppDescription` / `getAppKind` / `getAppIcon` / `getAppCategory` / `getAppGrade` / `getAppGradeWord` / `getAppTags`** — safe accessors, each takes `(meta, fallback?)` and never throws.
- **`gradeLocks(meta)`** → the lock string for a grade letter. **`hasAppMeta(meta)`** → whether any field beyond the version marker is set.
- **`APP_META_VERSION`** — the current metadata schema version (readers are forward-compatible: a v1 reader still reads a future field's neighbours).

All are re-exported from [`chainc/appmeta.ts`](../concepts/app-metadata.md), the single source of truth. Adding a field there makes it available everywhere in one edit.
