> For the complete documentation index, see [llms.txt](https://andrewkimjoseph.gitbook.io/celina-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andrewkimjoseph.gitbook.io/celina-sdk/concepts/prepared-flows.md).

# Prepared flows

Methods named `prepare*` return a **serialized prepared flow** — an ordered list of unsigned transactions for the user's wallet to sign.

## Supported prepare methods

| Method               | Service       | Typical steps                                        |
| -------------------- | ------------- | ---------------------------------------------------- |
| `prepareSend`        | `transaction` | 1 (ERC-20 transfer; CELO uses GoldToken)             |
| `prepareFx`          | `mentoFx`     | 1–2 (optional approve + swap)                        |
| `prepareSwap`        | `uniswap`     | 1–3 (optional ERC-20 + Permit2 approve + swap)       |
| `prepareSupply`      | `aave`        | 1–2 (optional approve + supply)                      |
| `prepareWithdraw`    | `aave`        | 1 (withdraw)                                         |
| `prepareClaimUbi`    | `gooddollar`  | 1 (UBI claim)                                        |
| `prepareReserveSwap` | `gooddollar`  | 1–2 (optional ERC-20 approve + MentoBroker `swapIn`) |

## SerializedPreparedFlow shape

```ts
{
  preparedFlow: true,
  steps: PreparedTx[],
  summary: string,       // human-readable label for UI
  from: `0x${string}`,
  network: "mainnet",
}
```

The `preparedFlow: true` discriminator makes it easy to detect prepared flows in chat APIs or JSON responses.

## PreparedTx fields

| Field         | Type                                | Description                              |
| ------------- | ----------------------------------- | ---------------------------------------- |
| `kind`        | `"native" \| "erc20" \| "contract"` | Transaction category                     |
| `to`          | `` `0x${string}` ``                 | Target contract or recipient             |
| `data`        | `` `0x${string}` `` (optional)      | Calldata for contract calls              |
| `value`       | `string` (optional)                 | Wei amount as decimal string (JSON-safe) |
| `description` | `string`                            | Human-readable step label for UI         |

### kind values

* **`native`** — Native-value transfer (`to` is recipient, `value` is wei); rare in Celina prepare flows
* **`erc20`** — ERC-20 call (`to` is token contract, `data` is encoded function). CELO sends use GoldToken (`0x471E…`) via token duality.
* **`contract`** — Generic contract call (Aave pool, Mento router, Universal Router, etc.)

## Multi-step flows

When an ERC-20 approval is required before a swap or supply, the SDK returns multiple steps in order:

```ts
const flow = await celina.mentoFx.prepareFx(from, "USDm", "EURm", "100");

// flow.steps might be:
// [0] Approve USDm for Mento FX
// [1] Swap 100 USDm → ~92 EURm
```

Sign and confirm each step sequentially. Do not skip or reorder steps.

## Sign-time simulation

Call `simulatePreparedStep` from `@andrewkimjoseph/celina-sdk/simulation` **per step, immediately before** `sendTransactionAsync` — after any prior step is mined. Simulation uses current chain state; simulating step 2 before step 1 confirms falsely fails with insufficient allowance.

Local stdio MCP **`execute_*`** tools use the same helper internally before signing with `CELO_PRIVATE_KEY`.

See [Prepared-step simulation](/celina-sdk/guides/prepared-step-simulation.md).

Those MCP tools sign and broadcast with `CELO_PRIVATE_KEY` instead of returning unsigned flows to the user.

## JSON serialization

`value` fields are decimal strings (not BigInt) so flows serialize cleanly over JSON APIs:

```ts
import { serializePreparedFlow } from "@andrewkimjoseph/celina-sdk";

// prepare* methods already return serialized flows
const flow = await celina.transaction.prepareSend(from, to, "CELO", "1");
// flow.steps[0].value === "0" (amount is in transfer calldata)
```

When calling wagmi, convert back to BigInt:

```ts
value: step.value ? BigInt(step.value) : undefined
```

## Celina data suffix

Prepared calldata is tagged with a Celina attribution suffix (`appendCelinaCalldataTag`) for on-chain identification — sends, Mento FX, Uniswap, Aave, and GoodDollar. You do not need to modify `data` before passing it to wagmi.

## Related

* [Prepared-step simulation](/celina-sdk/guides/prepared-step-simulation.md)
* [wagmi integration](/celina-sdk/guides/wagmi-integration.md)
* [Send tokens](/celina-sdk/guides/send-tokens.md)
* [Mento FX](/celina-sdk/guides/mento-fx.md)
* [Uniswap v4](/celina-sdk/guides/uniswap.md)
* [Aave](/celina-sdk/guides/aave.md)
* [GoodDollar](/celina-sdk/guides/gooddollar.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andrewkimjoseph.gitbook.io/celina-sdk/concepts/prepared-flows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
