> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pods.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Executing Bytecode

> How to sign and broadcast Pods transaction bundles atomically, and which output format to use for your wallet stack

Strategy deposits, withdrawals, and swaps return one or more transaction legs in `bytecode[]` (or
`transactionData[]` for swaps). **These legs are a single logical operation** — not independent
transactions you can pick and choose.

<Warning>
  **Do not send each item in `bytecode[]` as a separate wallet transaction.**

  Partial execution can move funds into Pods escrow while the action stays `PENDING` indefinitely
  (until SLA refund or support). This is especially common on cross-chain flows (e.g. Ondo Stocks)
  where the origin chain bundle may include approve + bridge legs.

  Execute every leg that shares the same `chainId` in **one atomic transaction**.
</Warning>

## Atomic execution

Filter legs by `chainId` (or `chainIdIn` on strategy responses), then batch them:

| Wallet setup                                          | How to batch                                                                               |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| **EOA** (MetaMask, wagmi, viem)                       | [EIP-7702 `executeBatch`](/examples/javascript/using-eip7702) — one type-4 tx from the EOA |
| **ERC-4337 smart account** (Privy, Alchemy AA, Notus) | One user operation with internal batch — use `output=userOperation`                        |
| **Gnosis Safe / Fireblocks smart wallet**             | Safe `execTransaction` with MultiSend, or `output=fireblocks`                              |
| **Custom executor**                                   | Your own multicall / account-abstraction batch over the returned calldata                  |

All legs in the batch succeed or all revert — no half-executed funding.

<Tip>
  Cross-chain strategy flows may require signatures on **more than one chain** (e.g. fund on Base,
  sell on BSC). Each chain's legs are still one atomic bundle per chain — never split legs within
  the same `chainId`.
</Tip>

## Choosing `output`

Bytecode endpoints accept `output` to match your signing infrastructure:

| `output`             | When to use                                                       | Response field                       | Signing flow                                   |
| -------------------- | ----------------------------------------------------------------- | ------------------------------------ | ---------------------------------------------- |
| `bytecode` (default) | EOA with EIP-7702, or you batch calldata yourself                 | `bytecode[]` / `transactionData[]`   | Batch all same-chain legs → one tx             |
| `userOperation`      | ERC-4337 smart account (Privy embedded wallet, Alchemy AA, Notus) | `userOperation`                      | Submit one userOp via your bundler             |
| `fireblocks`         | Fireblocks custody + smart wallet                                 | `transactionData` (Fireblocks shape) | `POST /v1/transactions` with vault `accountId` |
| `instructions`       | Debugging / inspection only                                       | Human-readable steps                 | Not for production signing                     |

### `output=bytecode` (default)

Use when the **signer is an EOA** or you control a contract that batches calls.

```http theme={null}
GET /strategies/:id/bytecode?action=lend&amount=...&wallet=0x...
```

Recommended path for EOAs: [EIP-7702 batch deposit](/examples/javascript/using-eip7702).

### `output=userOperation`

Use when the **`wallet` param is a smart account** and you submit via EntryPoint / bundler.

```http theme={null}
GET /strategies/:id/bytecode?action=lend&amount=...&wallet=0xSafe...&output=userOperation
```

<Warning>
  `output=userOperation` targets an **already-deployed** smart account at `wallet`. If the account
  is not on-chain yet, building the userOp fails with
  `Could not create a new SmartAccount without an owner`. Provision the account first — see
  [Smart Account Deposit](/examples/javascript/smart-account-deposit) or your AA provider's deploy
  flow.
</Warning>

Pods does **not** auto-provision a smart account for a plain EOA address. Use `output=bytecode` and
batch with EIP-7702, or create the smart account explicitly before requesting `userOperation`.

### `output=fireblocks`

Use with Fireblocks custody. Requires `accountId` (vault account ID) and a smart wallet previously
provisioned via `POST /fireblocks-smart-account`.

```http theme={null}
GET /strategies/:id/bytecode?action=lend&amount=...&wallet=0xSafe...&output=fireblocks&accountId=12
```

See [Fireblocks Integration](/external-integrations/fireblocks-integration).

## Decision tree

```
What signs the transaction?
│
├─ Plain EOA (browser wallet, server key)
│   └─ output=bytecode  →  EIP-7702 executeBatch (recommended)
│
├─ ERC-4337 smart account (Privy, Dynamic, Notus, …)
│   └─ output=userOperation  →  submit via bundler
│
├─ Fireblocks smart wallet
│   └─ output=fireblocks + accountId  →  Fireblocks Transactions API
│
└─ Custom / iframe widget
    └─ output=bytecode  →  your batch executor (must be atomic)
```

## After execution

1. Save the `id` from the bytecode response for tracking.
2. Poll `GET /actions/{id}`, WebSocket `/updates`, or customer webhooks for `ACTION_UPDATE`.
3. For async strategies (Ondo `request-lend` / `request-withdraw`), also poll position or
   `GET /strategies/:id/status?wallet=` until pending arrays clear.

## Common mistakes

| Mistake                                    | Symptom                                                | Fix                                                                   |
| ------------------------------------------ | ------------------------------------------------------ | --------------------------------------------------------------------- |
| `for (tx of bytecode) sendTransaction(tx)` | Funds stuck, `PENDING` forever                         | Batch into one tx (7702 / userOp / Safe)                              |
| `output=userOperation` with EOA `wallet`   | `Could not create a new SmartAccount without an owner` | Use `bytecode` + 7702, or deploy smart account first                  |
| Sell before forward completes (Ondo)       | On-chain `transfer amount exceeds balance`             | Gate on `suw.phase !== 'awaiting_forward'` and wallet position        |
| Wrong `chainId` filter                     | Tx reverts or wrong network                            | Sign only legs where `chainId === chainIdIn` (buy) or BSC (Ondo sell) |

## Next steps

<CardGroup cols={2}>
  <Card title="EIP-7702 Example" icon="bolt" href="/examples/javascript/using-eip7702">
    Atomic EOA batching with viem
  </Card>

  <Card title="Smart Account Deposit" icon="wallet" href="/examples/javascript/smart-account-deposit">
    ERC-4337 flow with output=userOperation
  </Card>

  <Card title="Fireblocks" icon="shield" href="/external-integrations/fireblocks-integration">
    Custody integration with output=fireblocks
  </Card>

  <Card title="Ondo Global Markets" icon="chart-line" href="/guides/ondoglobal-markets">
    Cross-chain stocks — high-risk partial-execution flow
  </Card>
</CardGroup>
