generate

Generate artifacts from the IDL.

sunscreen generate <ARTIFACT> [FLAGS]

generate clients is implicitly called by chain build and chain serve. Use these subcommands directly when you want to regenerate without rebuilding the program.

clients

sunscreen generate clients [--program <NAME>]

Run Codama against the workspace IDL and write a JavaScript/TypeScript client.

FlagDefaultDescription
--program <NAME>first IDLprogram to regenerate clients for

Requires: pnpm on PATH (sunscreen drives Codama via pnpm exec codama).

idl

sunscreen generate idl [--program <NAME>] [--out-dir <DIR>]

Export a deterministic IDL into the workspace.

FlagDefaultDescription
--program <NAME>all built IDLs in target/idlprogram to export
--out-dir <DIR>clients/idloutput directory relative to the workspace root

The exported IDL is byte-stable between runs as long as the source hasn't changed.

frontend-hooks

sunscreen generate frontend-hooks [FLAGS]

Generate TanStack Query hooks from exported IDLs.

FlagDefaultDescription
--program <NAME>all built IDLsprogram to generate hooks for
--frontend-path <DIR>from sunscreen.ymlrequired when the workspace was scaffolded with --frontend none
--target <NAME>from project configreact, solid, or all (React Query + Solid Query wrappers)

For each instruction in the IDL, generates a hook (useCreatePost, useReadPost, …) wrapping the Codama client. Hooks handle transaction building, signing, and refetching account queries on mutation success.

Exit codes

CodeWhen
0success
2pnpm or another required dependency missing
3sunscreen.yml invalid
5not in a workspace

Tips

  • chain build calls generate clients automatically. Run generate directly when you've touched the IDL by hand or need clients without rebuilding the .so.
  • Re-runs are idempotent. Codama overwrites only files it owns.