The @account-kit/infra library enables direct interaction with Alchemy's ERC-4337 bundler for advanced UserOperation management. The alchemyFeeEstimator function leverages underlying APIs, including rundler_maxPriorityFeePerGas and eth_estimateUserOperation, to estimate gas fees for UserOperations. Below are examples demonstrating how to estimate and send a UserOperation and how to retrieve a UserOperation by its hash using low-level Bundler APIs.
import { createAlchemyPublicRpcClient } from "@account-kit/infra";import { chain, transport } from "./config.ts";import type { Hash } from "viem";export async function getUserOperationByHash(uoHash: Hash) { const client = createAlchemyPublicRpcClient({ chain, transport, }); try { let userOp = await client.getUserOperationByHash(uoHash); console.log("User Operation: ", userOp); } catch (error) { console.error("Error processing UserOperation:", error); }}
Make sure that your environment is set with the correct ALCHEMY_API_KEY and
PRIVATE_KEY. These examples assume familiarity with ERC-4337 and proper
configuration of the EntryPoint contract (entryPoint07Address).