plan.send
Sends any plan: one prepared by a write's .prepare, or several combined with Plan.merge. Options, result, errors and examples for plan.send.
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
Use to review a plan before sending it, or to send several writes as one flow. Use sendSync to wait for the receipt.
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 withplan.resume; failures carrycontext.planId. onStepreports 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
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
| Option | Type | Default | Description |
|---|---|---|---|
plan (required) | Plan | The plan to send, for this client's chain and signer. |
Also takes the write options.
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
| Error | Codes | When |
|---|---|---|
PlanError | PLAN_CHAIN_MISMATCH, PLAN_ACCOUNT_MISMATCH | a plan prepared elsewhere. |
PlanError | PLAN_STALE | a token it transfers was reissued since it was prepared. |
ContractRevertError | CONTRACT_REVERTED | , or the failing step's own error (Errors.AnyError: a plan can hold any step), with context.planId and context.step. |
UserRejectedError | USER_REJECTED | the user rejects the request. |
WalletError | CHAIN_MISMATCH, ACCOUNT_NOT_FOUND | the wallet is on another chain or has no account to sign with. |
UnsupportedError | 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.
Examples
import { Plan } from "@ensforge/sdk"
const { hash } = await ens.plan.send({ plan: Plan.merge([recordsPlan, primaryNamePlan]) })Plan methods
Each method takes the same options as plan.send and sends nothing. See 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
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.
Resolves to Write.SyncResult. Receipts plus the submitted hashes and plan.
import { Plan } from "@ensforge/sdk"
const { receipt } = await ens.plan.sendSync({ plan: Plan.merge([recordsPlan, primaryNamePlan]) })See also
plan.resumeto continue a plan
Was this page helpful?