This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the EIP-4337 reference bundler implementation. The bundler implements the full EIP-4337 RPC calls (both production and debug calls), required to pass the bundler-spec-tests test suite.
This is a monorepo managed with Lerna and Yarn workspaces. The main packages are:
- bundler - The core bundler server that processes UserOperations
- sdk - SDK to create and send UserOperations, provides both low-level and high-level APIs
- utils - Shared utilities for the account abstraction ecosystem
- validation-manager - SDK to check if UserOperation validation violates any rules
Key architectural components in the bundler:
BundlerServer- Express server handling RPC endpointsUserOpMethodHandler- Handles production UserOperation RPC methodsDebugMethodHandler- Handles debug RPC methods- Module system:
BundleManager,EventsManager,ExecutionManager,MempoolManager,ReputationManager
# Install dependencies and compile contracts
yarn && yarn preprocess
# Deploy contracts locally
yarn hardhat-deploy --network localhost
# Start local bundler
yarn run bundler
# For unsafe mode (when using hardhat node or ganache)
yarn run bundler --unsafe# Run all tests
yarn lerna-test
# Run bundler tests
yarn --cwd packages/bundler hardhat-test
# Run specific test
yarn --cwd packages/bundler hardhat test test/BundlerManager.test.ts# Lint all packages
yarn lerna-lint
# Fix lint issues
yarn lint-fix
# Type check
yarn lerna-tsc
# Watch mode for TypeScript
yarn lerna-watch-tsc# Build all packages
yarn preprocess
# Clean build artifacts
yarn lerna-clear# Run a UserOperation
yarn run runop --deployFactory --network http://localhost:8545/ --entryPoint 0x0000000071727De22E5E9d8BAf0edAc6f37da032
# Start bundler with specific config
yarn --cwd packages/bundler bundler --config ./localconfig/bundler.config.jsonThe bundler uses a JSON configuration file. Key configuration options:
gasFactor: Gas multiplier for estimationsport: Server port (default 3000)beneficiary: Address to receive bundle feesminBalance: Minimum balance for bundler walletmnemonic: Path to mnemonic filemaxBundleGas: Maximum gas for a bundleautoBundleInterval: Auto-bundling interval in secondsautoBundleMempoolSize: Mempool size to trigger auto-bundling
The bundler requires a GETH node supporting debug_traceCall with JavaScript tracer to implement full spec storage access rules and opcode banning. Hardhat node and Ganache do NOT support this API - use --unsafe flag with these nodes.
To run a local GETH node:
docker run --rm -ti --name geth -p 8545:8545 ethereum/client-go:v1.10.26 \
--miner.gaslimit 12000000 \
--http --http.api personal,eth,net,web3,debug \
--http.vhosts '*,localhost,host.docker.internal' --http.addr "0.0.0.0" \
--ignore-legacy-receipts --allow-insecure-unlock --rpc.allow-unprotected-txs \
--dev \
--verbosity 2 \
--nodiscover --maxpeers 0 --mine --miner.threads 1 \
--networkid 1337The bundler interacts with the EIP-4337 contracts located in submodules/account-abstraction. Key contracts:
EntryPoint- Core contract that processes UserOperationsSimpleAccount- Sample account implementationSimpleAccountFactory- Factory for creating SimpleAccounts
Tests are organized by module in packages/bundler/test/:
- Unit tests for individual components
- Integration tests for RPC methods
- Validation tests for rules checking
The bundler uses Docker for containerized deployment. Images are versioned using the ERC-4337 version followed by the git commit SHA.
Use the dbuild.sh script located in dockers/bundler/:
# Build locally (without pushing)
VERSION=0.7.0-$(git rev-parse --short HEAD) IMAGE=0xbigboss/bundler ./dockers/bundler/dbuild.sh
# Build and push to Docker Hub
VERSION=0.7.0-$(git rev-parse --short HEAD) PUSH=1 IMAGE=0xbigboss/bundler ./dockers/bundler/dbuild.sh- Images are tagged as:
0.7.0-<short-commit-sha> - Example:
0.7.0-66737fb - The ERC-4337 version (0.7.0) indicates the EntryPoint contract version
- The commit SHA ensures traceability to specific code versions
- The script preprocesses the code with
yarn preprocess - Webpack bundles the application if source files have changed
- Docker buildx creates multi-platform images (linux/amd64, linux/arm64)
- Images are tagged with both the specific version and
latest
VERSION: The version tag (e.g.,0.7.0-66737fb)IMAGE: The Docker image name (e.g.,0xbigboss/bundler)PUSH=1: Set to push the image to the registry (omit for local build only)
# Get the current commit SHA
COMMIT=$(git rev-parse --short HEAD)
# Build and push the image
VERSION=0.7.0-$COMMIT PUSH=1 IMAGE=0xbigboss/bundler ./dockers/bundler/dbuild.sh