> ## 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.

# routes: Cooks and Sauce calls

> Cooks and Sauce calls: the declaration and description of each of the 18 exports of @eco-incorp/sauce.

The `routes` namespace compiles a SauceScript program for one chain by name and builds the calls that run it. `routes.compileSauceProgram(chain, source, options?)` compiles with the chain's token symbols, protocol namespaces and `@sauce/token` in scope; `routes.encodeEntryArguments(program, values)` encodes `main`'s run-time arguments; `routes.buildSauceEvmCall(params)` builds one `cook(engine, program)` call on a Pot. The chain exports (`Base`, `Solana`, ...), `chain` and `Token` are named exports of the root, and importing the package puts nothing on `globalThis`.

```typescript theme={null}
import { routes, Base } from "@eco-incorp/sauce";
```

Generated from the type declarations of `@eco-incorp/sauce`.

### `routes.buildSauceCall`

*Function* · `@eco-incorp/sauce`

Forks on `kindOf(chain)` (bigint-aware; throws for an unregistered chain id rather than
defaulting to evm) to build one Sauce-executing `Call` for either engine.

```typescript theme={null}
export declare function buildSauceCall(chain: ChainKindRef, params: SauceEvmCallParams | SauceSvmCallParams): CallInput;
```

### `routes.buildSauceCalls`

*Function* · `@eco-incorp/sauce`

Plural fork of `buildSauceCall`.

```typescript theme={null}
export declare function buildSauceCalls(chain: ChainKindRef, params: SauceEvmCallsParams | SauceSvmCallsParams): CallInput[];
```

### `routes.buildSauceEvmCall`

*Function* · `@eco-incorp/sauce`

One `cook(engine, program)` call on `pot`. `data` is produced by `v12Pot.encodeCook` - the exact
EVM engine encoder, not re-implemented here.

```typescript theme={null}
export declare function buildSauceEvmCall(params: SauceEvmCallParams): SauceEvmCall;
```

### `routes.buildSauceEvmCalls`

*Function* · `@eco-incorp/sauce`

One `Call` per element of `cooks`, in the given order, all targeting the same `pot`.

```typescript theme={null}
export declare function buildSauceEvmCalls(params: SauceEvmCallsParams): SauceEvmCall[];
```

### `routes.buildSauceSvmCall`

*Function* · `@eco-incorp/sauce`

Builds ONE staged SVM route call. Merges account flags within its own instruction only - use
`buildSauceSvmCalls` for the cross-call merge over a whole leg.

```typescript theme={null}
export declare function buildSauceSvmCall(params: SauceSvmCallParams): CallInput;
```

### `routes.buildSauceSvmCalls`

*Function* · `@eco-incorp/sauce`

RECOMMENDED entry point: builds one staged route call per `executions` element, with account
flags OR-merged across the whole leg by default.

```typescript theme={null}
export declare function buildSauceSvmCalls(params: SauceSvmCallsParams): CallInput[];
```

### `routes.mergeSvmAccountFlags`

*Function* · `@eco-incorp/sauce`

Cross-call OR-merge of `isSigner`/`isWritable` per pubkey across every given instruction's
accounts - the Solana runtime dedupes a repeated pubkey in one transaction to the union of its
flags, so a leg's own two staged calls (e.g. swap half + settle half) sharing an account must
agree on the more-permissive flags before either is built, not just within itself.

```typescript theme={null}
export declare function mergeSvmAccountFlags(instructions: readonly {
    accounts: readonly SauceSvmAccountMeta[];
}[]): Map<string, {
    isSigner: boolean;
    isWritable: boolean;
}>;
```

### `routes.sauceEvmDeployPotCall`

*Function* · `@eco-incorp/sauce`

Builds the Kitchen's `deployPot(owner, salt)` call, which creates the Pot at its CREATE2 address: send it before the first `cook()` on a Pot that may not exist yet. `kitchen` defaults to the pinned release's Kitchen (`v12KitchenAddress()`). It reads no chain, so it does not know whether that Kitchen has code where the call is sent: check the chain first. Returns a `SauceEvmCall`, `{ to, data, value }` with `value` 0.

```typescript theme={null}
export declare function sauceEvmDeployPotCall(params: SauceEvmDeployPotCallParams): SauceEvmCall;
```

### `routes.SauceEvmCall`

*Interface* · `@eco-incorp/sauce`

An EVM call these builders return, in both of the shapes it is used in:

* a transaction or `eth_call`, `{ to, data, value }` - the shape every other request the SDK builds
  has (`kitchenExecutionFee()`), and what a wallet or `client.call` takes as it is;
* a call record, `{ target, data, value }`.

`to` and `target` name the same contract: `to` as its checksummed 20-byte address, `target` as
the route records it. `target` stays for route calls and every caller that already reads it.

```typescript theme={null}
export interface SauceEvmCall extends CallInput {
    readonly to: Hex;
    readonly data: Hex;
    readonly value: bigint;
}
```

### `routes.SauceEvmCallParams`

*Interface* · `@eco-incorp/sauce`

The input of `buildSauceEvmCall`: the Pot to `cook()` on, the engine that runs the program (named per cook, since a Pot holds no engine), one compiled program, and an optional native `value` to send with the call (0 when left out).

```typescript theme={null}
export interface SauceEvmCallParams {
    pot: AddressInput;
    engine: AddressInput;
    program: Hex;
    value?: bigint | number | string;
}
```

### `routes.SauceEvmCallsParams`

*Interface* · `@eco-incorp/sauce`

```typescript theme={null}
export interface SauceEvmCallsParams {
    pot: AddressInput;
    engine: AddressInput;
    cooks: readonly Hex[];
    value?: bigint | number | string;
}
```

### `routes.SauceEvmDeployPotCallParams`

*Interface* · `@eco-incorp/sauce`

```typescript theme={null}
export interface SauceEvmDeployPotCallParams {
    owner: AddressInput;
    salt: Hex;
    kitchen?: AddressInput;
}
```

### `routes.SauceSvmAccountMeta`

*Interface* · `@eco-incorp/sauce`

One account meta as the caller supplies it - pre-merge, pre-executor-flattening.

```typescript theme={null}
export interface SauceSvmAccountMeta {
    pubkey: SvmAddressInput;
    isSigner: boolean;
    isWritable: boolean;
}
```

### `routes.SauceSvmCallParams`

*Interface* · `@eco-incorp/sauce`

```typescript theme={null}
export interface SauceSvmCallParams extends SauceSvmExecution {
    programId?: SvmAddressInput;
    executor?: SvmAddressInput;
}
```

### `routes.SauceSvmCallsParams`

*Interface* · `@eco-incorp/sauce`

```typescript theme={null}
export interface SauceSvmCallsParams {
    programId?: SvmAddressInput;
    executions: readonly SauceSvmExecution[];
    executor?: SvmAddressInput;
    mergeAccountFlags?: boolean;
}
```

### `routes.SauceSvmExecution`

*Interface* · `@eco-incorp/sauce`

```typescript theme={null}
export interface SauceSvmExecution extends StagedBufferRef {
    accounts: readonly SauceSvmAccountMeta[];
    value?: bigint | number | string;
}
```

### `routes.StagedBufferRef`

*Interface* · `@eco-incorp/sauce`

A buffer this module did NOT stage - only the RESOLVED facts about it. Deliberately carries no
`bytecode`/`seed`/`authority`/`payer`: see the module doc's "SVM STAGING IS A PREREQUISITE"
section for why, and where those pieces actually come from.

```typescript theme={null}
export interface StagedBufferRef {
    code: SvmAddressInput;
    expectedSha256?: Uint8Array;
}
```

### `routes.SvmAddressInput`

*Type* · `@eco-incorp/sauce`

A base58 string, a kit `Address`, or anything duck-typed like a web3.js `PublicKey` - see the
module doc's "WHY THIS FILE ... NEVER `@solana/web3.js`" note.

```typescript theme={null}
export type SvmAddressInput = string | Address | {
    toBase58(): string;
};
```


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