Skip to main content
The Grat core engine is published as a Rust crate and a WASM package.

Rust Usage

Add grat-core to your Cargo.toml:

WASM Usage

Embed Grat into your JavaScript/TypeScript applications:

Public API Highlights

  • decode_error: Returns a structured diagnostic report.
  • resolve_contract_error: Decodes custom error codes via WASM.
  • replay_transaction: Runs a full Tier 2/3 simulation.

HostError API

The HostError enum is the central type the decode engine works with. It covers every Soroban host error category, contract-specific errors, and an Unknown variant for forward compatibility.

summary() -> String

Returns a one-line plain-English sentence explaining what went wrong. This is the headline shown by grat decode — the first thing a developer reads when diagnosing a failed transaction.
Behaviour guarantees:
  • Every variant returns a non-empty string — no error is ever silent.
  • Known code 0 summaries are under 120 characters.
  • Unknown codes within known categories fall back to a formatted message including the code number.
  • ContractSpecific always mentions --resolve to guide the developer to the next step.
  • Unknown always includes both type_code and sub_code for diagnostic purposes.

category_name() -> &str

Returns the human-readable category name for the error variant, e.g. "Budget", "Auth", "ContractSpecific".