Skip to content

withBundler({ entryPoint, mode? })

Test runners: Examples use Vitest test and expect. scenario(...) returns an async function you can pass to any runner with a similar test callback (for example Jest or Node node:test).

Why it is useful

Use withBundler() to enable ERC-4337 flows against a local bundler that is wired to your scenario runtime.

Example

index.ts
import { test, expect } from "vitest";
import { scenario, withFork, withBundler } from "@st8craft/core";
 
const ENTRY_POINT = "0x0576a174D229E3cFA37253523E645A78A0C91B57";
 
test(
  "bundler wiring is exposed in scenario context",
  scenario(
    withFork({
      rpcUrl: process.env.VITE_RPC_URL!,
      blockNumber: 22_000_000n,
    }),
    withBundler({ entryPoint: ENTRY_POINT, mode: "alto" }),
    async ({ bundlerClient }) => {
      expect(await bundlerClient.getSupportedEntryPoints()).toContain(ENTRY_POINT);
    },
  ),
);

Options

OptionTypeRequired?Meaning (units/semantics)Used for / affects
entryPointAddressYesERC-4337 entry point address (typically EntryPoint v0.7 / v0.6).Configures the bundler instance and how user operations are encoded.
mode"alto"NoBundler runtime mode.Selects the local Alto bundler implementation.

Adds to context

  • bundlerUrl
  • bundlerClient
  • entryPoint

Context requirements

  • Requires runtime + ctx.testClient from withFork / withExternalRuntime.
  • Expects the host project to have the peer dependency used by Alto (@pimlico/alto). Docs examples are type-checked, not executed here.

Lifecycle

Managed lifecycle, the fixture starts a local bundler for the scenario and stops it in finally.

Notes and caveats

Additional examples for user operations are planned.