# plan.send

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

Sends any plan: one prepared by a write's .prepare, or several combined with Plan.merge. Options, result, errors and examples for plan.send.

Source: https://ensforge.com/docs/reference/sdk/plan/send

<ApiMeta kind="Write" stability="stable" since="1.0.0" source="packages/sdk/src/actions/plan/send/index.ts#L60" />

Sends any plan: one prepared by a write's `.prepare`, or several combined with `Plan.merge`. Resolves once the transaction is submitted.

## When to use [#when-to-use]

Use to review a plan before sending it, or to send several writes as one flow. Use [`sendSync`](/docs/reference/sdk/plan/send#wait-for-the-receipt-with-sendsync) to wait for the receipt.

## Details [#details]

- The plan is simulated, then sent step by step; consecutive steps share one wallet bundle
  when the wallet supports atomic batches (`maxBundleCalls`), never across a chain-time wait.
- Progress is saved to the client's `storage`, so a failed or interrupted plan continues
  with [`plan.resume`](/docs/reference/sdk/plan/resume); failures carry `context.planId`.
- `onStep` reports each step as it waits, is submitted, confirmed or fails.
- A plan for one of the client's `chains` (an L2 primary name) is simulated and sent there.

## Signature [#signature]

```ts
function send(
  client: Like,
  options: send.Options & Write.Options,
): Promise<send.ReturnType>
```

Call it as `ens.plan.send(options)` on a client, or `Actions.plan.send(client, options)`.

## Parameters [#parameters]

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `plan` (required) | `Plan` |  | The plan to send, for this client's chain and signer. |

Also takes the [write options](/docs/reference/sdk/client#write-options).

## Returns [#returns]

Resolves to `Write.Result`. Submitted transaction hashes and the plan that produced them.

| Field | Type | Description |
| --- | --- | --- |
| `hash` | `Hex` | Hash of the last transaction. |
| `hashes` | `readonly Hex[]` | Every submitted transaction, in order. |
| `id` | `string` | EIP-5792 bundle id when the calls were sent as one batch. |
| `plan` | `Plan` | The plan the write executed: its steps, in order, as they were submitted. |

## Errors [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`PlanError`](/docs/reference/errors/plan-error) | [`PLAN_CHAIN_MISMATCH`](/docs/reference/errors/PLAN_CHAIN_MISMATCH), [`PLAN_ACCOUNT_MISMATCH`](/docs/reference/errors/PLAN_ACCOUNT_MISMATCH) | a plan prepared elsewhere. |
| [`PlanError`](/docs/reference/errors/plan-error) | [`PLAN_STALE`](/docs/reference/errors/PLAN_STALE) | a token it transfers was reissued since it was prepared. |
| [`ContractRevertError`](/docs/reference/errors/contract-revert-error) | [`CONTRACT_REVERTED`](/docs/reference/errors/CONTRACT_REVERTED) | , or the failing step's own error (`Errors.AnyError`: a plan can hold any step), with `context.planId` and `context.step`. |
| [`UserRejectedError`](/docs/reference/errors/user-rejected-error) | [`USER_REJECTED`](/docs/reference/errors/USER_REJECTED) | the user rejects the request. |
| [`WalletError`](/docs/reference/errors/wallet-error) | [`CHAIN_MISMATCH`](/docs/reference/errors/CHAIN_MISMATCH), [`ACCOUNT_NOT_FOUND`](/docs/reference/errors/ACCOUNT_NOT_FOUND) | the wallet is on another chain or has no account to sign with. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`WALLET_BATCH_UNSUPPORTED`](/docs/reference/errors/WALLET_BATCH_UNSUPPORTED) | with `mode: "batch"` or a paymaster when the wallet cannot send calls as one batch. |

It can also fail with the errors every write can (`Errors.WriteError`: the common errors plus `InsufficientFundsError`, `TransactionError`, `UnsupportedError`, `UserRejectedError`, `WalletError`).

See [How errors work](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Sending a merged plan"
import { Plan } from "@ensforge/sdk"

const { hash } = await ens.plan.send({ plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>

<Tab>
```ts title="Sending a merged plan with a standalone call"
import { Actions, Plan } from "@ensforge/sdk"

await Actions.plan.send(ens, { plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>

<Tab>
```ts title="Sending a merged plan in an Effect program"
import { Actions, Plan } from "@ensforge/sdk/effect"

yield* Actions.plan.send(ens, { plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>
</Tabs>

## Plan methods [#plan-methods]

Each method takes the same options as `plan.send` and sends nothing. See [Preview before sending](/docs/sdk/preview-before-sending).

| Method | Description |
| --- | --- |
| `plan.send.prepare(options)` | Builds the plan without sending anything. |
| `plan.send.simulate(options)` | Simulates the plan with `eth_call`, reporting each step. |
| `plan.send.estimateGas(options)` | Estimates the gas and ETH the plan needs. |

## Wait for the receipt with `sendSync` [#wait-for-the-receipt-with-sendsync]

Sends any plan: one prepared by a write's `.prepare`, or several combined with `Plan.merge`. Resolves once the receipt is in.

Use when the next step depends on the change being on-chain.

`plan.sendSync` takes the same options plus [`confirmations` and `timeout`](/docs/reference/sdk/client#sync-options).

Resolves to `Write.SyncResult`. Receipts plus the submitted hashes and plan.

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Sending a merged plan and waiting"
import { Plan } from "@ensforge/sdk"

const { receipt } = await ens.plan.sendSync({ plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>

<Tab>
```ts title="Waiting with a standalone call"
import { Actions, Plan } from "@ensforge/sdk"

await Actions.plan.sendSync(ens, { plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>

<Tab>
```ts title="Waiting in an Effect program"
import { Actions, Plan } from "@ensforge/sdk/effect"

yield* Actions.plan.sendSync(ens, { plan: Plan.merge([recordsPlan, primaryNamePlan]) })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`plan.resume`](/docs/reference/sdk/plan/resume) to continue a plan