@thru/abi when you need to turn ABI YAML plus raw bytes into structured reflection output, especially for explorers, debuggers, or test harnesses that need human-readable decoded values.
Install
When to use it
Choose this package when you need one of these workflows:- Decode a flat ABI YAML definition into a type-specific reflection result.
- Decode instruction, account, or event payloads with the ABI root type already implied.
- Resolve ABI imports into a manifest before reflection.
- Format reflection JSON into a compact tree for UI display.
Entry point
The package exposes a single public entry point at@thru/abi.
Common workflows
| Task | Function |
|---|---|
| Decode a specific ABI type | reflect |
| Decode an instruction payload | reflectInstruction |
| Decode an account payload | reflectAccount |
| Decode an event payload | reflectEvent |
| Resolve imports first | resolveImports, createManifest |
| Format decoded output | formatReflection |
Decode a raw instruction
Decode flattened ABI YAML
Usereflect when your ABI YAML is already flattened and you want to decode a specific type.
Decode common ABI payloads
UsereflectInstruction, reflectAccount, and reflectEvent when the ABI root type is already implied by the payload.
Work with ABI imports
UseresolveImports and createManifest when your ABI uses imports and you want a manifest-based workflow.
The manifest-aware helpers mirror the flat-ABI API:
reflectWithManifestreflectInstructionWithManifestreflectAccountWithManifestreflectEventWithManifestbuildLayoutIrWithManifest
resolveImports currently supports on-chain imports in browser environments. Path, git, and HTTP imports are handled by the CLI bundle flow instead.
Formatting
formatReflection turns the raw reflection JSON into the compact tree used by the docs and CLI-style output. Call ensureWasmLoaded() first if you want to preload the WASM module, or use any reflection function before formatting.
If you are running in an environment that cannot load the WASM bundle automatically, call configureWasm("/wasm/abi_reflect_wasm_bg.wasm") before the first reflection call.
Related types
The package also exports the main data shapes used by the formatter and import resolver:FormattedReflectionFormattedValueFormattedValueWithByteRangeByteRangeManifestManifestPackageInfoResolverConfigResolutionResultResolutionError