Skip to main content

Nethereum.AccountAbstraction.Bundler.RpcServer

NuGet: Nethereum.AccountAbstraction.Bundler.RpcServer | Source: src/Nethereum.AccountAbstraction.Bundler.RpcServer/

Nethereum.AccountAbstraction.Bundler.RpcServer

JSON-RPC 2.0 server exposing ERC-4337 bundler methods including eth_sendUserOperation, gas estimation, receipt queries, and debug endpoints.

Overview

Nethereum.AccountAbstraction.Bundler.RpcServer provides JSON-RPC handlers that expose the ERC-4337 bundler as a standard JSON-RPC 2.0 endpoint. It implements all spec-required methods (eth_sendUserOperation, eth_estimateUserOperationGas, eth_getUserOperationByHash, eth_getUserOperationReceipt, eth_supportedEntryPoints) plus debug methods for mempool inspection and reputation management.

Each handler extends RpcHandlerBase from Nethereum.CoreChain.Rpc, allowing seamless integration with AppChain or DevChain server infrastructure.

Key Features

  • Full ERC-4337 RPC: All spec-required bundler JSON-RPC methods
  • Debug Endpoints: Mempool dump, flush, reputation get/set
  • Standard Integration: Extends CoreChain RpcHandlerBase for plug-and-play registration
  • Error Codes: Proper JSON-RPC error codes per ERC-4337 spec (-32602, -32500, -32603)

Installation

dotnet add package Nethereum.AccountAbstraction.Bundler.RpcServer

Dependencies

  • Nethereum.AccountAbstraction.Bundler - Core bundler service (IBundlerService)
  • Nethereum.CoreChain - RPC handler base classes and registry

RPC Methods

Standard Methods

MethodDescription
eth_sendUserOperationSubmit a UserOperation to the bundler mempool
eth_estimateUserOperationGasEstimate gas for a UserOperation
eth_getUserOperationByHashGet UserOperation by its hash
eth_getUserOperationReceiptGet receipt for a mined UserOperation
eth_supportedEntryPointsList supported EntryPoint addresses
eth_chainIdGet chain ID

Debug Methods

MethodDescription
debug_bundler_dumpMempoolList all pending UserOperations
debug_bundler_flushForce immediate bundle execution
debug_bundler_setReputationSet entity reputation entries
debug_bundler_getReputationGet entity reputation status

Quick Start

using Nethereum.AccountAbstraction.Bundler.RpcServer;

// Register handlers in RPC registry
var registry = new RpcHandlerRegistry();
registry.Register(new EthSendUserOperationHandler(bundlerService));
registry.Register(new EthEstimateUserOperationGasHandler(bundlerService));
registry.Register(new EthGetUserOperationByHashHandler(bundlerService));
registry.Register(new EthGetUserOperationReceiptHandler(bundlerService));
registry.Register(new EthSupportedEntryPointsHandler(bundlerService));
registry.Register(new BundlerEthChainIdHandler(chainId));

Usage Examples

Example 1: Register All Bundler Handlers

var bundlerService = new BundlerService(web3, bundlerConfig);
var registry = new RpcHandlerRegistry();

// Standard methods
registry.Register(new EthSendUserOperationHandler(bundlerService));
registry.Register(new EthEstimateUserOperationGasHandler(bundlerService));
registry.Register(new EthGetUserOperationByHashHandler(bundlerService));
registry.Register(new EthGetUserOperationReceiptHandler(bundlerService));
registry.Register(new EthSupportedEntryPointsHandler(bundlerService));

// Debug methods
registry.Register(new DebugBundlerDumpMempoolHandler(bundlerService));
registry.Register(new DebugBundlerFlushHandler(bundlerService));

API Reference

EthSendUserOperationHandler

Handles eth_sendUserOperation - submits UserOperation to mempool.

Parameters: [userOp (JSON object), entryPoint (address)] Returns: userOpHash (hex string) Errors: -32602 (invalid params), -32500 (validation failed), -32603 (internal error)

EthEstimateUserOperationGasHandler

Handles eth_estimateUserOperationGas - estimates gas limits.

Parameters: [userOp (JSON object), entryPoint (address)] Returns: { preVerificationGas, verificationGasLimit, callGasLimit }

EthGetUserOperationReceiptHandler

Handles eth_getUserOperationReceipt - retrieves mined operation receipt.

Parameters: [userOpHash (hex)] Returns: Receipt with success, actualGasUsed, actualGasCost, sender, paymaster

Dependencies

See Also

Additional Resources