> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript library

> Add Sauce to your application: compile programs, encode inputs, build transactions and test execution.

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](https://docs.eco.com/sauce/program-layout.md) 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](https://docs.eco.com/sauce-sdk/installation.md#install-it-in-a-project). 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](https://docs.eco.com/sauce-libraries/overview) that programs import. Local testing has additional dependencies; see [Testing](https://docs.eco.com/sauce-sdk/typescript/testing.md).

## Build your first integration

Follow these pages in order for an EVM integration:

1. [Compile a program](https://docs.eco.com/sauce-sdk/typescript/compiling.md) for your chain and inspect its inputs.
2. [Encode entry arguments](https://docs.eco.com/sauce-sdk/typescript/entry-arguments.md) for the program's `main` function.
3. [Build a cook transaction](https://docs.eco.com/sauce-sdk/typescript/cook-transactions.md), including Pot deployment and fees, then simulate it before signing.
4. [Test the integration](https://docs.eco.com/sauce-sdk/typescript/testing.md) on a local or forked chain.

For Solana, use the [Solana guide](https://docs.eco.com/sauce-sdk/typescript/solana.md), 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"`.

| Subpath | What it holds |
| - | - |
| `.` | One named export per chain (`Base`, `Ethereum`, `Solana`, …), `chain` and `Token`; the namespaces `routes` (compile, encode arguments, build cooks), `token`, `deposit`, `contracts` and `svmVenues`; protocol and chain queries (`getProtocol`, `listProtocols`, `chainBySlug`, `requireChain`); the Pot helpers `v12PredictPot`, `potSalt`, `DEFAULT_POT_SALT` and `kitchenExecutionFee`; `sqrtPriceX96FromPrice` and `priceFromSqrtPriceX96`; `ready` |
| `/compiler` | The raw compiler: `compile`, `ready`, `resolveSdkModule` and `resolveSdkPackage`, and the compiler's types |
| `/actions` | JSON action programs: `parseProgram`, `serializeProgram`, `programSchema`, `compileProgram`, `quoteAction`, `compileSplitSwap`, `ProgramError` |
| `/actions/action-program.schema.json` | The JSON Schema of an action program |
| `/testing` | Node only. The testing kit: `fork`, `local`, `TestChain`, `SolanaTestChain`, `CookReverted`, `DEFAULT_POT_SALT` |
| `/protocols/*` | One protocol per slug, such as `/protocols/uniswap-v3`: `protocolInfo`, `deployments`, its ABIs (`UniswapV3PoolABI`) and its SauceScript templates (`swap`, `addLiquidity`) |
| `/chains` | Chain records and lookups (`CANONICAL_CHAINS`, `chainBySlug`, `chainById`, `requireChain`, `isEvm`), EVM chain metadata (`chains`, `getChain`) and native-coin helpers (`nativeCoinSymbol`, `nativeErc20`) |
| `/recipes` | `settleSource`, the source of the EVM settle program the package ships |
| `/recipes/settle.sauce.ts` | The same EVM settle program as a file |
| `/deployments` | The V12 release: engine, Router and Kitchen addresses, the Pot derivation, and which compiler's programs each engine runs (`v12EngineAddress`, `v12RouterAddress`, `v12KitchenAddress`, `v12PotDerivation`, `V12_RELEASE_SETS`, `assertEngineRunsCompiler`) |
| `/skills` | The per-protocol documents as Markdown text: `getProtocolIndex`, `getProtocolSkill`, `listSkillSlugs` |
| `/svm` | Solana: the Kitchen client (`createSauceSvmClient`), clusters (`SOLANA_CLUSTERS`), program-derived addresses (`derivePotPda`), account resolution (`resolveAccounts`), transactions (`buildExecuteTransaction`), token accounts (`svmTokenAccount`, `resolveSvmToken`) and venue accessors (`venue`, `venues`) |
| `/svm/engine` | The Solana engine's instruction builders and constants (`buildExecuteInstruction`, `buildCookAndPayInstruction`, `engineFaultName`) |
| `/svm/engine-artifacts` | Node only. File paths to the packaged Solana engine and Kitchen programs and the Kitchen IDL (`svmEnginePath`, `svmKitchenPath`, `svmKitchenIdlPath`, `svmEngineArtifacts`), for a local LiteSVM harness |
| `/evm/engine` | The Pot and Kitchen ABIs and calldata encoders: `v12Pot`, `v12Kitchen`, `v12PotAbi`, `v12KitchenAbi`, and `potRouterUpdate`; and the signed-cook helpers: `signedCookTypedData`, `encodeCookSigned`, `encodeInvalidateNonces`, `verifySignedCook`, `checkSignedCookPot` and the nonce helpers ([Signed cooks](https://docs.eco.com/sauce-sdk/typescript/cook-transactions.md#signed-cooks)) |
| `/svm/verify` | Solana settle verification: `verifySvmSettleProgram`, `decodeSvmSettleExecution`, `verifySvmSettleExecution` |
| `/svm/recipes/settle.sauce.ts` | The Solana settle program as a file |
| `/verify` | EVM settle payloads: `encodeSettleProgram`, `decodeSettleCall`, `validateSettleProgram` and related exports |
| `/sauce-script` | Types only: SauceScript's builtins, chain names and ABI modules, for an editor checking `*.sauce.ts` files |

The generated [API reference](https://docs.eco.com/sauce-sdk/api/overview.md) 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.

```ts browser.ts theme={null}
import { ready, routes } from "@eco-incorp/sauce";

// With no argument, ready() fetches the wasm from beside the compiler's module.
// Pass a URL or the bytes when your bundler does not copy that file.
try {
  await ready(new URL("/assets/sauce_wasm_bg.wasm", location.href));

  const program = routes.compileSauceProgram("base", "function main(): Uint256 {\n  return pot.USDC;\n}\n");
  console.log(program.bytecode.length);
} catch (error) {
  console.error("Could not load the compiler or compile the program:", error);
}
```

[Compiling](https://docs.eco.com/sauce-sdk/typescript/compiling.md#ready) gives the signature of `ready` and what it accepts.

## Related guides

> **[Compiling](https://docs.eco.com/sauce-sdk/typescript/compiling.md)**
>
> `compileSauceProgram`, `compileSauceRoute` and the raw `compile()`, their options, results and errors.

> **[Entry arguments](https://docs.eco.com/sauce-sdk/typescript/entry-arguments.md)**
>
> Encode and decode `main`'s ABI-v1 arguments, and append them to the bytecode.

> **[Cook transactions](https://docs.eco.com/sauce-sdk/typescript/cook-transactions.md)**
>
> Predict and deploy a Pot, read the Kitchen fee, build the cook and simulate it with viem.

> **[Chains and registries](https://docs.eco.com/sauce-sdk/typescript/chains-and-registries.md)**
>
> Chains, tokens and the protocol registry from TypeScript.

> **[Actions](https://docs.eco.com/sauce-sdk/typescript/actions.md)**
>
> Compile JSON action programs with `/actions`.

> **[Solana](https://docs.eco.com/sauce-sdk/typescript/solana.md)**
>
> Compile for Solana and cook through the Kitchen client.

> **[Verification](https://docs.eco.com/sauce-sdk/typescript/verification.md)**
>
> Check a settle payload against the settle program the package ships.

> **[Testing](https://docs.eco.com/sauce-sdk/typescript/testing.md)**
>
> Run programs as cooks on a local or forked chain from your tests.

## Next steps

* [@eco-incorp/sauce API reference](https://docs.eco.com/sauce-sdk/api/overview.md): every export, generated from the package's types.
* [CLI overview](https://docs.eco.com/sauce-sdk/cli/overview.md): the same steps from a terminal.
* [Pot](https://docs.eco.com/sauce/pot.md) and [cook](https://docs.eco.com/sauce/cook.md): what the transactions on these pages do.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.