Skip to main content
Use thru-cli abi codegen when you already have ABI YAML and want generated client-side or runtime-facing code, not an on-chain ABI account.

Use This When

  • you want generated C headers and helpers from ABI type definitions
  • you want Rust or TypeScript types organized by package
  • you have one or more ABI files plus imported dependencies on disk
Choose another ABI command when:
  • you want to inspect type resolution or IR before generating code: Analyze
  • you want to publish an ABI on-chain: Account
  • you need a flattened or publish-ready YAML artifact instead of generated source: Flatten or Prep for Publish

Syntax

thru-cli abi codegen \
  --files <FILE>... \
  --language c|rust|typescript \
  [--include-dir <DIR>...] \
  [--output <DIR>] \
  [--verbose]

Required Inputs

InputWhat it does
—files <FILE>…One or more root ABI YAML files to load.
`—language crusttypescript`Chooses the generator backend.
—include-dir <DIR>…Adds search roots for imported ABI files.
—output <DIR>Output directory for generated code. Defaults to generated.

Output Shape

The generator resolves imports, groups types by package, and writes package directories underneath the output directory.

C

Emits package directories containing types.h and functions.c.

Rust

Emits package directories with types.rs, helper modules, and mod.rs scaffolding.

TypeScript

Emits package directories with types.ts.
LanguageTypical output
cPackage directories with types.h and functions.c.
rustPackage directories with types.rs, helper modules, and mod.rs scaffolding.
typescriptPackage directories with types.ts.

Minimal Patterns

thru-cli abi codegen \
  --files ./program.abi.yaml \
  --language c \
  --output ./generated/c

Notes

  • --files can be repeated so one run can generate code for multiple root packages.
  • The command creates the output directory if it does not already exist.
  • --verbose is useful when import resolution is the risky part of the task because it prints loaded files, packages, and output locations.
  • Use Analyze first if you want to inspect layout or validation helpers before you commit to generated output.