Skip to content

Validation and roundtrip testing

View as Markdown

Use this page when the ABI file exists and you need to prove it actually matches the bytes your program expects.

The highest-value local loop is:

write ABI -> analyze -> codegen TypeScript -> build instruction data -> reflect it back

That loop catches the most common handwritten-ABI failures before you deploy anything.

  1. Analyze the schema

    Run ABI Analyze first to resolve imports, validate layout rules, and inspect IR if needed.

  2. Generate TypeScript

    Run ABI Codegen and use the generated TypeScript types/helpers to build real instruction data.

  3. Reflect the bytes back

    Use ABI Reflect on the resulting binary payload. If the reflected values do not match what you intended to send, the ABI is not ready yet.

  4. Only then move to deployment

    Once the payload roundtrip is correct, move to Publishing and Iteration.

ABIs are handwritten, so “looks right” is not good enough. The roundtrip loop proves:

  • the schema resolves cleanly
  • codegen can consume it
  • the produced bytes match the schema when decoded back out
GoalBest tool
Resolve imports and type graphABI Analyze
Inspect layout IR or helper previewsABI Analyze with --print-ir, --print-footprint, or --print-validate
Generate TS for payload buildingABI Codegen
Decode or validate a captured payloadABI Reflect
Normalize imports before publish or browser useABI Flatten, ABI Prep for Publish, or ABI Bundle

A practical testing stack today often looks like:

  • use ABI codegen to generate TypeScript
  • use @thru/sdk to submit the transaction
  • use ABI reflection tooling or the explorer to decode instruction, account, or transaction data afterward

That reflection step is still somewhat fragmented. In some flows, CLI or explorer tooling is the cleanest way to decode payloads even if you used @thru/sdk to send the transaction.

  • A schema can pass analyze and still be wrong for the actual bytes you are building.
  • Generated code can expose awkward package or type structure that is hard to notice from YAML alone.
  • Dynamic layouts need special attention; always prefer a real reflection roundtrip over eyeballing the schema.
  • If context is tight, analyze plus reflect --validate-only is the fastest high-signal check.