Skip to main content
Use the TypeScript library when your application needs to compile Sauce programs, encode their inputs or build transactions for a wallet to sign. It exposes the same core functions used by the CLI and MCP server. Application code and SauceScript play different roles: your TypeScript application calls the SDK; a .sauce.ts program describes the operations that run onchain. See Program layout for the language’s supported syntax. The library has no built-in RPC endpoint and reads no environment variables. Supply a viem client or endpoint URL to functions that read a chain. Compilation and argument encoding do not require a network connection.

Prerequisites

  • Node.js 24 or newer for Node-based applications.
  • The SDK and viem installed in your project. Follow Installation. The library’s EVM interfaces use viem types such as Address, Hex and PublicClient.
  • ES modules. Set "type": "module" in your project’s package.json and use import.
The package includes the SauceScript compiler and the @sauce/* libraries that programs import. Local testing has additional dependencies; see Testing.

Build your first integration

Follow these pages in order for an EVM integration:
  1. Compile a program for your chain and inspect its inputs.
  2. Encode entry arguments for the program’s main function.
  3. Build a cook transaction, including Pot deployment and fees, then simulate it before signing.
  4. Test the integration on a local or forked chain.
For Solana, use the Solana guide, which covers its account model and Kitchen client.

Import paths

Import from the package name or from one of its subpaths. In the table, . is @eco-incorp/sauce itself. There is no /routes, /token, /deposit or /contracts subpath: routes, token, deposit and contracts are namespaces of the root, as in import { routes } from "@eco-incorp/sauce". The generated API reference lists every export of every subpath.

In a browser

The library supports browser use except for two Node-only subpaths: /svm/engine-artifacts, which returns filesystem paths, and /testing, which starts local chains. A browser loads the compiler’s WebAssembly asynchronously. Call ready() once before the first compile; until it resolves, every compile throws. In Node, ready() resolves at once and no compile needs it, so code shared by both can always call it.
browser.ts
Compiling gives the signature of ready and what it accepts.

Compiling

compileSauceProgram, compileSauceRoute and the raw compile(), their options, results and errors.

Entry arguments

Encode and decode main’s ABI-v1 arguments, and append them to the bytecode.

Cook transactions

Predict and deploy a Pot, read the Kitchen fee, build the cook and simulate it with viem.

Chains and registries

Chains, tokens and the protocol registry from TypeScript.

Actions

Compile JSON action programs with /actions.

Solana

Compile for Solana and cook through the Kitchen client.

Verification

Check a settle payload against the settle program the package ships.

Testing

Run programs as cooks on a local or forked chain from your tests.

Next steps