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

# Introduction to Sauce

> Learn how Sauce combines onchain actions and checks in one transaction, and choose a path from first concepts to working programs.

Sauce lets you combine several onchain actions into one transaction. For example, you can compare two swap quotes, exchange tokens on the pool with the higher quote, and deposit the result into a lending protocol. You write the actions and the conditions they must satisfy in a **Sauce program**.

A program runs on one chain. If a failure is not handled by the program, the transaction reverts: its transfers and other state changes are undone. This is transaction-level atomicity. It does not undo earlier transactions or guarantee that a later transaction on another chain succeeds.

## When to use Sauce

Use Sauce when an action depends on a balance, a price, or the result of an earlier action in the same transaction. Common examples include:

* **Payments:** distribute tokens to several recipients or swap tokens before paying an invoice.
* **Swaps:** compare pools, enforce a minimum output, or try a second pool when the first attempt fails.
* **Lending:** swap into a token, supply it to a protocol, and check the resulting position.

## The main concepts

You write a program in **SauceScript**, a language based on a subset of TypeScript. SauceScript compiles to instructions for Sauce's engine; you do not run it with Node.js or deploy a new contract for each program.

| Term | Meaning |
| - | - |
| **Program** | Your actions and checks, written in a `.sauce.ts` file. |
| **Pot** | The account that holds tokens and executes your program. On an EVM chain, it is a contract controlled by its owner. |
| **Cook** | A transaction that runs a program through a Pot. |
| **Kitchen** | The contract or Solana program that creates Pots and sets the execution fee. |
| **V12 engine** | The interpreter that executes a compiled Sauce program. |

Start with the program and the Pot. The [runtime reference](https://docs.eco.com/sauce/pot.md) explains the contract details, and the [glossary](https://docs.eco.com/sauce/glossary.md) defines the terms used throughout the docs.

## A first program

This example pays USDC from the Pot to a recipient. It first checks that the Pot holds enough USDC. SauceScript provides `USDC`, `pot`, `Address` and `Uint256`, so this program needs no imports.

```ts pay.sauce.ts theme={null}
// Pays `amount` of the chain's USDC from the Pot to `to`.
//
//   sauce run pay.sauce.ts --chain base --wallet <name> --args <to> <amount>
//
//   to: Address       the recipient
//   amount: Uint256   in USDC's smallest unit (6 decimals): 5000000 is 5 USDC
function main(to: Address, amount: Uint256) {
  require(pot.USDC >= amount, "not enough USDC");
  USDC.transfer(to, amount);
}
```

* `main` defines the inputs: the recipient and the amount to pay.
* `USDC` resolves to the token address for the chain you compile for.
* `pot.USDC` reads the Pot's USDC balance when the program executes.
* `require` stops this program if the balance is too low.
* `USDC.transfer` transfers tokens from the Pot and checks the token's response.

Token amounts use integers in the token's smallest unit. USDC has 6 decimals, so `5000000` means 5 USDC. `Uint256` is an unsigned 256-bit integer; its arithmetic checks for overflow and underflow.

To install the tools and run a simulation, follow the [Sauce SDK quickstart](https://docs.eco.com/quickstarts/sauce/first-program.md). The [payment recipe](https://docs.eco.com/quickstarts/sauce/pay.md) adds recipient checks and verifies the amount received.

## How a program runs

**1. Compile for a chain**

The compiler checks the program and resolves names such as `USDC` to addresses for the selected chain. It produces bytecode and the information needed to encode `main`'s arguments.

**2. Build the transaction**

The SDK combines the program, its arguments and the transaction settings. On EVM chains, the transaction calls the Pot's `cook(engine, program)` function. Its value covers the Kitchen fee and any native coin the program needs.

**3. Simulate the result**

Simulation runs the transaction against chain state without signing or sending it. You can inspect transfers, the return value, estimated gas and any failure. State can change before you send the transaction.

**4. Authorize and send**

The owner sends the transaction or, on supported EVM Pots, signs an authorization for another account to submit. The Pot executes the program. On EVM chains, calls made by the program come from the Pot.

On Solana, the Kitchen and Pot use Solana's account model, and the cook is an instruction signed by the owner. Protocol calls and account setup differ between targets; see [EVM and Solana](https://docs.eco.com/sauce/targets.md).

## Chain support and execution boundaries

The CLI can build and send transactions for Ethereum, Base, Arc and Solana, and for the testnets Arc Testnet, Base Sepolia, Ethereum Sepolia, Solana Devnet and Solana Testnet. The registry also includes preview chains with more limited support. A registry entry or successful compile does not establish that the required contracts are deployed. Check the [chain reference](https://docs.eco.com/sauce-sdk/reference/chains.md) and [deployment reference](https://docs.eco.com/sauce-sdk/reference/deployments.md) for your target.

A program can call a bridge contract, but the destination-chain transaction happens separately. Within a cook, an unhandled failure undoes that transaction's state changes. Earlier approvals, earlier transfers and network fees are outside that rollback. See [security considerations](https://docs.eco.com/sauce/security-considerations.md) before sending a program with real funds.

## Next steps

> **[Run your first simulation](https://docs.eco.com/quickstarts/sauce/first-program.md)**
>
> Install the tools, compile a program and inspect its result.

> **[Learn SauceScript by example](https://docs.eco.com/sauce/by-example.md)**
>
> Build from payments to quotes, swaps and lending in five annotated examples.

> **[Choose a recipe](https://docs.eco.com/quickstarts/sauce/overview.md)**
>
> Find a complete program for a payment, swap, lending action or portfolio check.

> **[Look up a term](https://docs.eco.com/sauce/glossary.md)**
>
> Find definitions for Sauce, EVM and Solana terminology.


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