> ## 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: Portal transactions and vaults

> Portal transactions and vaults: 14 exports of the routes module of @eco-incorp/sauce, including predictVaultAddress, vaultInitCodeHash, VaultConfig, approvalTxs, fundTx, intentHashCall.

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/vault.d.ts`, `sdk/dist/routes/portal.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.predictVaultAddress`

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

The off-chain twin of `IntentSource._getVault(intentHash)` -> `Clones.predict(intentHash,
CREATE2_PREFIX)`. Throws (rather than silently computing against a missing/malformed
`vaultInitCodeHash`) since there is no safe baked default - see the module doc.

```typescript theme={null}
export declare function predictVaultAddress(intentHash: Hex, config: VaultConfig): Hex;
```

### `routes.vaultInitCodeHash`

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

`keccak256(proxyCreationCode ++ abi.encode(implementation))` - the `initCodeHash` half of the
`Clones.predict` formula, for a caller who has the real `type(Proxy).creationCode` bytes (e.g.
pulled from a deployment artifact) and only needs the implementation-address encoding step done
correctly.

```typescript theme={null}
export declare function vaultInitCodeHash(proxyCreationCode: Hex, implementation: AddressInput): Hex;
```

### `routes.VaultConfig`

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

```typescript theme={null}
export interface VaultConfig {
    readonly portal: AddressInput;
    readonly vaultInitCodeHash: Hex;
    readonly prefix?: Hex;
}
```

### `routes.approvalTxs`

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

One `approve(portal, amount)` per DISTINCT reward token, in first-seen order - see the module
doc's funding-mechanics table: the allowance is to the PORTAL, never the vault. Several reward
entries naming the same token collapse into ONE approve for the LARGEST of their amounts, never
their sum: `IntentSource._fundToken` compares each leg against the vault's TOTAL balance and
short-circuits, so the largest leg is the binding allowance. Emits nothing for
`reward.nativeAmount` (that needs `value`, not an approval); a token whose largest entry is zero
is emitted as `approve(portal, 0)` rather than filtered. Does NOT emit `allowance`/`balanceOf`
read-calls to let a caller skip a redundant approve - see `isIntentFundedCall` for the "is this
already funded?" question.

```typescript theme={null}
export declare function approvalTxs(intent: Intent, target: PortalTarget): readonly PortalTx[];
```

### `routes.fundTx`

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

`Portal.fund(destination, routeHash, reward, allowPartial)`. `value = reward.nativeAmount`.

```typescript theme={null}
export declare function fundTx(intent: Intent, allowPartial: boolean, target: PortalTarget): PortalTx;
```

### `routes.intentHashCall`

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

`Portal.getIntentHash(destination, routeBytes, reward)` - the on-chain cross-check for our
off-chain `hashIntent`.

```typescript theme={null}
export declare function intentHashCall(intent: Intent, target: PortalTarget): PortalReadCall<IntentHashes>;
```

### `routes.intentVaultAddressCall`

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

`Portal.intentVaultAddress(destination, routeBytes, reward)` - the PRIMARY vault path (an `eth_call`
the caller performs; see `vault.ts#predictVaultAddress` for the zero-RPC offline option).

```typescript theme={null}
export declare function intentVaultAddressCall(intent: Intent, target: PortalTarget): PortalReadCall<Hex>;
```

### `routes.isIntentFundedCall`

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

`Portal.isIntentFunded(destination, routeBytes, reward)`.

```typescript theme={null}
export declare function isIntentFundedCall(intent: Intent, target: PortalTarget): PortalReadCall<boolean>;
```

### `routes.publishAndFundTx`

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

`Portal.publishAndFund(destination, routeBytes, reward, allowPartial)`. `value = reward.nativeAmount`.

```typescript theme={null}
export declare function publishAndFundTx(intent: Intent, allowPartial: boolean, target: PortalTarget): PortalTx;
```

### `routes.publishTx`

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

`Portal.publish(destination, routeBytes, reward)`. `value` is always `0n`.

```typescript theme={null}
export declare function publishTx(intent: Intent, target: PortalTarget): PortalTx;
```

### `routes.PORTAL_ABI`

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

The `bytes`-route overload only - see the module doc for why. One overload per name, so
`encodeFunctionData({ abi: PORTAL_ABI, functionName })` can never pick the wrong signature.

```typescript theme={null}
PORTAL_ABI: readonly [
    {
        readonly type: "function";
        readonly name: "publish";
        readonly stateMutability: "nonpayable";
        readonly inputs: readonly [
            {
                readonly name: "destination";
                readonly type: "uint64";
            },
            {
                readonly name: "route";
                readonly type: "bytes";
            },
            {
                readonly name: "reward";
                readonly type: "tuple";
                readonly components: readonly [
                    {
                        readonly name: "deadline";
                        readonly type: "uint64";
                    },
                    {
                        readonly name: "creator";
                        readonly type: "address";
                    },
                    {
                        readonly name: "prover";
                        readonly type: "address";
                    },
                    {
                        readonly name: "nativeAmount";
                        readonly type: "uint256";
                    },
                    {
                        readonly name: "tokens";
                        readonly type: "tuple[]";
                        readonly components: readonly [
                            {
                                readonly name: "token";
                                readonly type: "address";
                            },
                            {
                                readonly name: "amount";
                                readonly type: "uint256";
                            }
                        ];
                    }
                ];
            }
        ];
        readonly outputs: readonly [
            {
                readonly name: "intentHash";
                readonly type: "bytes32";
            },
            {
                readonly name: "vault";
                readonly type: "address";
            }
        ];
    },
    {
        readonly type: "function";
        readonly name: "publishAndFund";
        readonly stateMutability: "payable";
        readonly inputs: readonly [
            {
                readonly name: "destination";
                readonly type: "uint64";
            },
            {
                readonly name: "route";
                readonly type: "bytes";
            },
            {
                readonly name: "reward";
                readonly type: "tuple";
                readonly components: readonly [
                    {
                        readonly name: "deadline";
                        readonly type: "uint64";
                    },
                    {
                        readonly name: "creator";
                        readonly type: "address";
                    },
                    {
                        readonly name: "prover";
                        readonly type: "address";
                    },
                    {
                        readonly name: "nativeAmount";
                        readonly type: "uint256";
                    },
                    {
                        readonly name: "tokens";
                        readonly type: "tuple[]";
                        readonly components: readonly [
                            {
                                readonly name: "token";
                                readonly type: "address";
                            },
                            {
                                readonly name: "amount";
                                readonly type: "uint256";
                            }
                        ];
                    }
                ];
            },
            {
                readonly name: "allowPartial";
                readonly type: "bool";
            }
        ];
        readonly outputs: readonly [
            {
                readonly name: "intentHash";
                readonly type: "bytes32";
            },
            {
                readonly name: "vault";
                readonly type: "address";
            }
        ];
    },
    {
        readonly type: "function";
        readonly name: "fund";
        readonly stateMutability: "payable";
        readonly inputs: readonly [
            {
                readonly name: "destination";
                readonly type: "uint64";
            },
            {
                readonly name: "routeHash";
                readonly type: "bytes32";
            },
            {
                readonly name: "reward";
                readonly type: "tuple";
                readonly components: readonly [
                    {
                        readonly name: "deadline";
                        readonly type: "uint64";
                    },
                    {
                        readonly name: "creator";
                        readonly type: "address";
                    },
                    {
                        readonly name: "prover";
                        readonly type: "address";
                    },
                    {
                        readonly name: "nativeAmount";
                        readonly type: "uint256";
                    },
                    {
                        readonly name: "tokens";
                        readonly type: "tuple[]";
                        readonly components: readonly [
                            {
                                readonly name: "token";
                                readonly type: "address";
                            },
                            {
                                readonly name: "amount";
                                readonly type: "uint256";
                            }
                        ];
                    }
                ];
            },
            {
                readonly name: "allowPartial";
                readonly type: "bool";
            }
/* …truncated… */
```

### `routes.PortalReadCall`

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

An `eth_call` request plus its own decoder - the caller performs the RPC, this module never does.

```typescript theme={null}
export interface PortalReadCall<T> {
    readonly to: Hex;
    readonly data: Hex;
    decode(result: Hex): T;
}
```

### `routes.PortalTarget`

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

Where to submit. `portal` is the SOURCE-chain Portal - never defaulted, never invented.

```typescript theme={null}
export interface PortalTarget {
    readonly portal: AddressInput;
}
```

### `routes.PortalTx`

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

A submittable transaction request. `value` is always explicit, never omitted.

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