> ## 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: Opening routes and chain globals

> Opening routes and chain globals: 18 exports of the routes module of @eco-incorp/sauce, including pascalOfSlug, PascalOf, createChainGlobals, makeChainGlobal, ChainGlobal, ChainGlobals.

The `routes` namespace packages a Sauce program as an Eco intent. `Base(body, options)` and the other chain globals (installed by importing the root package) forward to `routes.openRoute(destination, body, options)`, which returns a `PendingSauceRoute`; `.nest(...)` adds child intents and `.reward(...)` returns a `BuiltIntent`.

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

This page covers `sdk/dist/routes/builder.d.ts`, `sdk/dist/routes/intent-dsl.d.ts`, `sdk/dist/routes/globals.d.ts`.

<Note>
  Generated from the type declarations shipped in `@eco-incorp/sauce` 0.99.4. Each entry shows the package authors' JSDoc and declaration for this SDK version. For runtime compatibility and deployed addresses, see [architecture and deployments](/programmable-transactions/sauce/architecture-and-deployments).
</Note>

### `routes.pascalOfSlug`

*Function* · `sdk/dist/routes/builder.d.ts`

`PascalOf`'s runtime mirror: split on `-`, upper-case each segment's first
character, join. Agrees with the type-level `PascalOf` by construction
(both reduce to `Capitalize<S>` per `-`-separated segment) as long as a
slug matches `^[a-z0-9]+(-[a-z0-9]+)*$` -- pinned by
`chains-canonical.test.ts`.

```typescript theme={null}
export declare function pascalOfSlug(slug: string): string;
```

### `routes.PascalOf`

*Type* · `sdk/dist/routes/builder.d.ts`

`PascalOf<"bnb-chain">` = `"BnbChain"`. Matches the runtime `pascal()`
derivation in `accessors.ts` by construction (both reduce to
`Capitalize<S>` composed across `-`-separated segments) -- re-exported from
`accessors.ts` so callers only need one import site.

```typescript theme={null}
export type PascalOf<S extends string> = S extends `${infer H}-${infer T}` ? `${Capitalize<H>}${PascalOf<T>}` : Capitalize<S>;
```

### `routes.createChainGlobals`

*Function* · `sdk/dist/routes/builder.d.ts`

Generates the top-level chain globals from `../chains/canonical.js` --
adding a chain to `CANONICAL_CHAINS` adds a global here with zero code
changes; a duplicate PascalCase key (two slugs colliding after casing)
throws at module-eval time rather than silently overwriting one with
another.

```typescript theme={null}
export declare function createChainGlobals(): ChainGlobals;
```

### `routes.makeChainGlobal`

*Function* · `sdk/dist/routes/builder.d.ts`

Builds the callable `ChainGlobal` for `chain` -- what a generated global
(`Base`) or `chain(ref)` returns. An ARROW function (no own `prototype` to
collide with) forwarding to `openRoute`, with `chain`/`route` defined onto
it as enumerable so `Object.keys(chainAccessors.Base)` stays exactly
`["chain","route"]`.

```typescript theme={null}
export declare function makeChainGlobal(chain: CanonicalChain): ChainGlobal;
```

### `routes.ChainGlobal`

*Interface* · `sdk/dist/routes/builder.d.ts`

A chain global: callable (the SAME behavior as `.route`), plus `.chain`/`.route`.

```typescript theme={null}
export interface ChainGlobal extends ChainRoute {
    readonly chain: CanonicalChain;
    readonly route: ChainRoute;
}
```

### `routes.ChainGlobals`

*Type* · `sdk/dist/routes/builder.d.ts`

One generated `ChainGlobal` per canonical chain slug, PascalCase-keyed.

```typescript theme={null}
export type ChainGlobals = {
    readonly [S in ChainSlug as PascalOf<S>]: ChainGlobal;
};
```

### `routes.ChainRoute`

*Interface* · `sdk/dist/routes/builder.d.ts`

The call signature: `Chain(sauce, options)` -> a pending route awaiting `.reward(...)`.

```typescript theme={null}
export interface ChainRoute {
    (sauce: SauceBody, options?: IntentOptions): PendingSauceRoute;
}
```

### `routes.openRoute`

*Function* · `sdk/dist/routes/intent-dsl.d.ts`

Opens a route on `chain` (the DESTINATION) - what every chain global's callable AND `.route`
forward to, so `Base(sauce, opts)` and `Base.route(sauce, opts)` are behaviorally identical by
construction (both call this exact function).

```typescript theme={null}
export declare function openRoute(chain: ChainRef, sauce: SauceBody, options?: IntentOptions): PendingSauceRoute;
```

### `routes.BuiltIntent`

*Interface* · `sdk/dist/routes/intent-dsl.d.ts`

```typescript theme={null}
export interface BuiltIntent {
    readonly intent: Intent;
    readonly destination: CanonicalChain;
    readonly source: CanonicalChain;
    readonly compiled: CompileResult;
    readonly children: readonly BuiltIntent[];
    root(): Intent;
    intents(): readonly Intent[];
    hash(): IntentHashes;
    encodeEVM(): {
        readonly route: Hex;
        readonly reward: Hex;
    };
    encodeSVM(): {
        readonly route: Hex;
        readonly reward: Hex;
    };
    publishCalldata(target?: Partial<PortalTarget>): PortalTx;
    publishAndFundCalldata(allowPartial: boolean, target?: Partial<PortalTarget>): PortalTx;
    fundCalldata(allowPartial: boolean, target?: Partial<PortalTarget>): PortalTx;
    approvals(target?: Partial<PortalTarget>): readonly PortalTx[];
    vaultCall(target?: Partial<PortalTarget>): PortalReadCall<Hex>;
    predictVault(config: VaultConfig): Hex;
    vault(config: VaultConfig): Hex;
    hashCall(target?: Partial<PortalTarget>): PortalReadCall<IntentHashes>;
    fundedCall(target?: Partial<PortalTarget>): PortalReadCall<boolean>;
}
```

### `routes.IntentOptions`

*Type* · `sdk/dist/routes/intent-dsl.d.ts`

Everything a route needs beyond the Sauce program body itself. Supply an explicit destination
execution, or both `pot` and `engine` as the EVM shorthand. When `execution` is supplied it takes
precedence over any redundant shorthand fields, matching `openRoute`'s runtime behavior.

```typescript theme={null}
export type IntentOptions = IntentOptionsCommon & ({
    execution: SauceEvmExecutionInput | SauceSvmExecutionInput;
    pot?: AddressInput;
    engine?: AddressInput;
} | {
    execution?: undefined;
    pot: AddressInput;
    engine: AddressInput;
});
```

### `routes.NestChildOrThunk`

*Type* · `sdk/dist/routes/intent-dsl.d.ts`

`.nest(childOrThunk, opts?)`'s first argument: either an already-built child `BuiltIntent`
(checked against `child.source.id === parent.destination.id`, so a mismatched leg is rejected
rather than silently accepted), or - the documented PREFERRED form - a thunk receiving the
parent's own destination chain (which IS the child's source, by construction, so there is
nothing to get wrong).

```typescript theme={null}
export type NestChildOrThunk = BuiltIntent | ((parentChain: CanonicalChain) => BuiltIntent);
```

### `routes.NestOptions`

*Interface* · `sdk/dist/routes/intent-dsl.d.ts`

```typescript theme={null}
export interface NestOptions {
    via?: NestVia;
    position?: "before" | "after";
    portal?: AddressInput;
    allowPartial?: boolean;
    fundedByBody?: boolean;
    vault?: AddressInput;
    vaultConfig?: NestVaultConfigInput;
    clamp?: boolean;
    requireCap?: boolean;
    native?: "balance" | "skip";
    fundNativeFromRoute?: boolean;
    executionFee?: bigint | number | string;
    pot?: AddressInput;
    engine?: AddressInput;
    compile?: SauceCompileOptions;
}
```

### `routes.PendingSauceRoute`

*Interface* · `sdk/dist/routes/intent-dsl.d.ts`

```typescript theme={null}
export interface PendingSauceRoute {
    reward(rewardArg: RewardArg): BuiltIntent;
    nest(childOrThunk: NestChildOrThunk, opts?: NestOptions): PendingSauceRoute;
}
```

### `routes.RewardArg`

*Type* · `sdk/dist/routes/intent-dsl.d.ts`

`.reward(...)`'s argument: the full object form, a bare `bigint` (the single unambiguous
reading - NATIVE amount only; a token reward must name its token), or a bare token-amount array
(`reward.tokens`).

```typescript theme={null}
export type RewardArg = SauceRewardSpec | bigint | readonly TokenAmountInput[];
```

### `routes.SauceRewardSpec`

*Interface* · `sdk/dist/routes/intent-dsl.d.ts`

The object form of a reward argument - every field optional, since a missing one falls back to
the matching `IntentOptions` field (and a STILL-missing required field throws, naming exactly
which one).

```typescript theme={null}
export interface SauceRewardSpec {
    readonly source?: ChainRef;
    readonly deadline?: bigint | number | string;
    readonly creator?: AddressInput;
    readonly prover?: AddressInput;
    readonly nativeAmount?: bigint | number | string;
    readonly tokens?: readonly TokenAmountInput[];
}
```

### `installRouteGlobals`

*Function* · `sdk/dist/routes/globals.d.ts`

```typescript theme={null}
export declare function installRouteGlobals(opts?: InstallRouteGlobalsOptions): RouteGlobalsReport;
```

### `uninstallRouteGlobals`

*Function* · `sdk/dist/routes/globals.d.ts`

Removes every name this module has installed (across all calls) from
`target` (default `globalThis`) and clears the internal bookkeeping, so a
later `installRouteGlobals()` reinstalls cleanly rather than skipping.

```typescript theme={null}
export declare function uninstallRouteGlobals(target?: object): void;
```

### `routeGlobals`

*Variable* · `sdk/dist/routes/globals.d.ts`

Install-on-import result -- this IS the default-globals behavior. A host
that must not have `globalThis` mutated can opt out before the SDK is
ever imported: `globalThis.__ECO_ROUTES_NO_GLOBALS__ = true`.

```typescript theme={null}
routeGlobals: RouteGlobalsReport
```
