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

# token: Token API

> Token API: 6 exports of the token module of @eco-incorp/sauce, including TokenSauceScript, TokenCall, TokenBinding, TokenFactory, TokenApi, Token.

The `token` namespace emits SauceScript for token operations: ERC-20 on an EVM compile target, SPL Token on `svm`. `token.Token` is also installed as the default global `Token`.

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

This page covers `sdk/dist/token/api.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>

### `token.TokenSauceScript`

*Interface* · `sdk/dist/token/api.d.ts`

```typescript theme={null}
export interface TokenSauceScript {
    readonly imports: readonly string[];
    readonly statement: string;
    readonly source: string;
    readonly baseDirs: readonly string[];
    readonly accountRefs?: readonly string[];
}
```

### `token.TokenCall`

*Interface* · `sdk/dist/token/api.d.ts`

```typescript theme={null}
export interface TokenCall {
    readonly spec: TokenSpec;
    source(target: TokenTarget): string;
    statement(target: TokenTarget): string;
    expression(target: TokenTarget): string;
    toSauceScript(target: TokenTarget): TokenSauceScript;
    toCall(): {
        readonly target: `0x${string}`;
        readonly data: Hex;
        readonly value: bigint;
    };
    accountRefs(): readonly string[];
}
```

### `token.TokenBinding`

*Interface* · `sdk/dist/token/api.d.ts`

What `Token(<addr>)` yields **inside a route body** - the wrapper form, not the runtime API.

Route-body calls are positional (`Token(a).approve(spender, amt)`) where the runtime
\[`TokenApi`] takes a spec object, because the body is compiled to Sauce bytecode rather than
executed: `token-rewrite.ts#rewriteTokenFactory` replaces the callee with `IERC20.at` before the
compiler sees it, and these signatures are what let a **typed closure** body typecheck on the way
there. Nothing calls these at run time, which is why they live here rather than on `TokenApi`.

```typescript theme={null}
export interface TokenBinding {
    transfer(to: AddressInput, amount: bigint): void;
    approve(spender: AddressInput, amount: bigint): void;
    balanceOf(owner: AddressInput): bigint;
}
```

### `token.TokenFactory`

*Interface* · `sdk/dist/token/api.d.ts`

The call signature the **ambient** `Token` global carries, intersected onto \[`TokenApi`] by
`gen-route-globals.mjs` - the same way each chain global is `ChainGlobals[...] & ChainContracts`.

Deliberately NOT on `TokenApi` itself: the runtime `Token` export is a frozen object and is not
callable, so typing it as callable would promise something that throws. The ambient declaration
describes what is legal in a route body, where the call never survives to run.

```typescript theme={null}
export interface TokenFactory {
    (address: AddressInput): TokenBinding;
}
```

### `token.TokenApi`

*Interface* · `sdk/dist/token/api.d.ts`

```typescript theme={null}
export interface TokenApi {
    transfer(spec: TokenTransferSpec): TokenCall;
    approve(spec: TokenApproveSpec): TokenCall;
    balanceOf(spec: TokenBalanceSpec): TokenCall;
    program(specs: readonly TokenSpec[], opts: {
        target: TokenTarget;
    }): string;
    readonly ata: typeof ata;
    readonly TOKEN_PROGRAM: bigint;
    readonly TOKEN_2022_PROGRAM: bigint;
    readonly ERC20ABI: typeof ERC20ABI;
    readonly SPL_TRANSFER_CHECKED: number;
    readonly SPL_APPROVE_CHECKED: number;
    readonly SPL_AMOUNT_OFFSET: number;
    readonly MINT_DECIMALS_OFFSET: number;
}
```

### `token.Token`

*Variable* · `sdk/dist/token/api.d.ts`

The universal token interface - ERC20 on an EVM compile target, SPL Token on `svm`. See
`sdk/src/token/index.ts` for the module overview. Installed as the DEFAULT GLOBAL `Token` (zero
import) by `sdk/src/routes/globals.ts`; also available as the named export `token.Token`.

```typescript theme={null}
Token: TokenApi
```
