Skip to main content
The package carries the registries a program’s names resolve against: 46 chains, each chain’s tokens, and 133 protocols with their deployments. The exports on this page read those registries. None of them reads a chain or takes an RPC endpoint, and they cover preview chains as well as the chains that send. The data itself is listed in Chains, Tokens and Protocols. A bare name in a program, such as USDC or UniswapV3.Factory, is SauceScript syntax that routes.compileSauceProgram, the sauce command, the MCP server and actions documents resolve for the chain they compile for, before the compiler runs; routes.compileSauceRoute adds neither the chain id nor the token functions, and the compiler alone knows none of these names (Names, Compiler or SDK). The TypeScript spelling of the same registry entry hangs off a chain export: Base.USDC, Base.UniswapV3.Factory.

Chain exports

One named export per canonical chain, each carrying the chain’s record, its registry tokens and the protocol contract tree.

Import

The export name is the chain’s slug in PascalCase: Base, Arbitrum, Bsc, Zksync, Solana.

Usage

cr-chain-exports.mts

Type

Properties

A chain export’s tokens are exactly that chain’s registry rows: Base.USDT is a type error and undefined at run time. Every chain export carries every protocol namespace, so use .available to ask whether the chain has a deployment.

Contract calls

A contract’s method builds a ContractCall synchronously, typed from the registry ABI.
cr-contract-call.mts
UniswapV3.QuoterV2 is a name on every chain the registry records a Uniswap V3 factory on, Base among them. read, simulate and write first check that the client is on the call’s chain, and refuse a client on another chain. method.returns names the registry contract an address output is, where the registry knows it. Calling a method of a contract with no deployment on the chain throws, naming the chains that have one. An interface such as Base.Erc4626.Vault has methods only after .at(address).

chain

Resolves a chain chosen at run time to its record.

Import

Usage

cr-chain.mts

Signature

Parameters

  • ref: a chain id (8453, 8453n), a slug, name or alias ("eth", "BNB Chain"), or a CanonicalChain. Strings match without regard to case and punctuation.

Returns

ChainGlobal: an object with .chain alone. It is not the composed chain export, so it has no tokens or contract tree. Use contracts.on(ref) and routes.registryTokens(chain) for those.

Throws

When ref names no chain, with the list of known slugs: Unknown chain 'nope' (known slugs: ethereum, optimism, bsc, …).

contracts.on

The protocol contract tree of a chain chosen at run time: the same tree a chain export carries.

Import

Usage

contracts.on(picked.chain) in the chain example above.

Signature

Parameters

  • chainRef: a chain id, slug, alias or CanonicalChain.

Returns

ChainContracts: every protocol and family namespace, each contract with address, available and its methods. contracts.listContracts(slug), contracts.contractsOnChain(chain) and contracts.describeContract(chain, protocol, contract) query the same descriptors.

Token

The host builder for one ERC-20 or SPL token operation: it returns the call or the program text, and sends nothing.

Import

Usage

cr-token.mts

Signature

Parameters

  • spec.token: on EVM, the ERC-20’s address.
  • spec.to (transfer) or spec.spender (approve): on EVM, the recipient or the spender.
  • spec.amount: a bigint, a safe-integer number, or "balance" to read the live balance when the program runs.
  • spec.svm, spec.tokenProgram: on Solana, the account references the operation uses and "spl" (the default) or "token-2022".

Returns

TokenCall. toCall() is the plain ERC-20 call, for a fixed amount on EVM. source(target) is a complete one-operation program whose writes follow OpenZeppelin SafeERC20; compile it like any other program. Token.program(specs, { target }) puts several operations in one program.

Throws

toCall() throws for an SVM spec; statement() throws for balanceOf; expression() throws for a write. In a program, Token(address) is program syntax and not this builder: see Names.

The /chains subpath

The canonical chain records and the EVM chain metadata. The package root re-exports every one of these.

Import

Usage

cr-chains-subpath.mts

Signature

Returns

  • A CanonicalChain is identity only: id, slug, name, kind, aliases. Solana’s id is 1399811149.
  • A Chain from getChain is EVM metadata: nativeCurrency, blockExplorerUrls, testnet, and minBaseFeePerGas where the chain enforces a floor (20 gwei on Arc and Arc Testnet). It carries no RPC URL. chains covers 37 of the 43 EVM chains; getChain returns undefined for the rest.
  • nativeErc20(chainId) is the ERC-20 that is the chain’s native coin, or undefined where the native coin is separate from every token. On Arc it is USDC: one balance, 18 decimals natively and 6 through the ERC-20.
  • nativeToErc20Amount(chainId, wei) converts a native amount to the ERC-20’s units, rounding down as balanceOf reads it.

Throws

requireChain throws for an unknown chain, naming the known slugs. nativeToErc20Amount throws on a chain whose native coin is not an ERC-20.

routes.TOKEN_REGISTRY

The EVM token table, keyed by chain id: every token symbol a program on that chain can name, tokenized stocks included.

Import

Usage

cr-tokens.mts

Type

A row’s address is EIP-55 checksummed, and source records where the row was verified: an in-repository pin, a probe:<chain>@<date> read, or a stock issuer’s published list. decimals is metadata: the compiler applies no decimal scaling, so amounts in a program are integers in the token’s smallest unit. A chain with no row has no token symbols.

routes.SVM_TOKEN_REGISTRY

Solana’s registered mints, per cluster. A program compiled for solana resolves its symbols against mainnet-beta.

Type

tokenProgram is the program that owns the mint: SPL Token (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA) for USDC and USDT, Token-2022 (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb) for PYUSD and every tokenized stock. address is the mint’s 32-byte key as hex, the value a program compares an account’s mint against. The example under routes.TOKEN_REGISTRY above reads it.

Token lookups

Per-chain views of both tables, as a compiled program resolves them.

Usage

The example under routes.TOKEN_REGISTRY above calls each one.

Signature

Parameters

  • chain: a CanonicalChain, from requireChain(ref) or a chain export’s .chain.
  • symbol: a registry symbol, matched exactly.

Returns

  • registryTokens: every registry token on the chain by symbol, the same frozen objects a chain export carries (routes.registryTokens(base).USDC === Base.USDC). Empty for a chain with no rows.
  • knownTokenSymbols: every symbol on the chain, sorted.
  • registryTokenAddress: the value the symbol resolves to in a program, as a bigint: the token’s address on an EVM chain, the mint’s 32-byte key on Solana. undefined when the chain does not register the symbol.
  • svmTokenRows: the mints a program compiled for the chain resolves; empty off Solana.
To give a token a symbol for one compile, pass tokens: { SYMBOL: address } in routes.compileSauceProgram’s options; it merges per symbol with the registry (Compiling).

Tokenized stocks

Ethereum, Base and Solana register tokenized stocks as ordinary rows with a stock field. Each list is copied from its issuer’s own published list.

Signature

Returns

  • STOCK_ISSUERS: each issuer’s name, the list its rows come from, and transferFee where its Solana mints charge a Token-2022 transfer fee.
  • stockSymbol(symbol): the registry symbol for an issuer’s ticker, with . written as _ (BRK.Bx is BRK_Bx), so that every symbol is an identifier a program can write.
Stock symbols are not all uppercase (TSLAx, SPCXc, bTSLA); the registry keeps each chain’s symbols unique without regard to case. Tokenized stocks lists what differs about each issuer’s tokens.

Protocol registry

The protocol catalogue: each protocol’s metadata and per-chain deployments.

Import

Usage

cr-protocols.mts

Signature

Returns

A ProtocolInfo carries name, slug, description, website, category and chains, one { chainId, chainName, addresses } per chain, its addresses keyed by role (factory, quoterV2). ProtocolCategory is one of dex, lending, bridge, yield, derivatives, staking, oracle, cdp, aggregator, liquid-staking, restaking and the other values in its type. An address in the catalogue is recorded, not proof of live code: read the chain before you rely on it. Whether a program can call a contract by name is a separate question that .available on a chain export, or routes.sourceGlobals, answers.

/protocols/*

One module per protocol slug.

Import

Exports

The usage is in the protocol registry example. Every registry ABI declares the deployed contract’s own types, so the selectors it computes are the ones the deployment dispatches. Protocols lists each protocol’s contracts on every chain.

routes.sourceGlobals

Every name a program compiled for a chain may use without declaring it: what sauce globals --chain <chain> prints.

Import

Usage

cr-source-globals.mts

Signature

Parameters

  • chain: a chain id, slug, alias or CanonicalChain.

Returns

A name listed here is one the compile accepts on that chain, resolved to the value the program gets. sauce globals --chain base --json prints the same object, except that its tokens leave out the tokenized stocks, which the text output counts (sauce globals).

installRouteGlobals

Importing the package defines nothing on globalThis. installRouteGlobals() is the opt-in for a host that wants the chain exports, chain and Token as run-time globals.

Import

Usage

cr-globals.mts

Signature

Parameters

  • opts.target: the object to define the names on. Default globalThis.
  • opts.includeChain: also define chain. Default true.
  • opts.includeToken: also define Token. Default true.
  • target (uninstallRouteGlobals): the object to remove them from. Default globalThis.

Returns

RouteGlobalsReport: the names this call defined, and the names it skipped because the target already had them. A name already present, inherited or getter-only included, is never overwritten. Each installed property is non-enumerable, and its value is the same object the named export holds. routeGlobals is a live view of the last install, empty until one happens. uninstallRouteGlobals() removes every name the module installed. installRouteGlobals() installs values only. The TypeScript declarations for bare names in a program (USDC, Uniswap) are type-only and come with the package’s root types; no run-time USDC object exists.

Next steps

  • Chains, Tokens and Protocols: the registries’ contents.
  • Names: how a program uses token symbols, namespaces and Token(address).
  • sauce globals: the same names from the command line.
  • Compiling: routes.compileSauceProgram and its tokens option.