Pimlico Bundler Client
A Pimlico Bundler Client is an interface to official ERC-4337 JSON-RPC API methods that include sending user operations, estimation user operation gas limits, getting user operation receipts and more as well as the Pimlico-specific bundler methods.
To create a Pimlico Bundler Client, create a basic client and extend it with the Bundler Actions and Pimlico Bundler Actions.
Import
import { pimlicoBundlerActions } from 'permissionless/actions/pimlico'
Usage
Initialize a Bundler Client with your desired Chain (e.g. mainnet) and Transport (e.g. http) from viem by creating a simple client and extending it with the Pimlico bundler methods and (optionally) the standard bundler methods.
import { createClient, http } from 'viem'
import { goerli } from 'viem/chains'
import { bundlerActions } from 'permissionless'
import { pimlicoBundlerActions } from 'permissionless/actions/pimlico'
const pimlicoBundlerClient = createClient({
chain: goerli,
transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
})
.extend(bundlerActions)
.extend(pimlicoBundlerActions)
Then you can consume Pimlico Bundler Actions:
const userOperationGasPrice = await pimlicoBundlerClient.getUserOperationGasPrice()
Alternatively, you can initialize a Bundler Client with the createPimlicoBundlerClient
method:
import { http } from 'viem'
import { goerli } from 'viem/chains'
import { createPimlicoBundlerClient } from "permissionless/clients/pimlico";
const pimlicoBundlerClient = createPimlicoBundlerClient({
chain: goerli,
transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
})