Skip to content

How to Bundle a User Operation

To bundle a user operation, you need to use your Pimlico API key and make a JSON-RPC request as follows:

import { createPublicClient, http } from "viem"
const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at
const pimlicoEndpoint = `${chain}/rpc?apikey=${pimlicoApiKey}`
const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
const pimlicoClient = createPublicClient({ transport: http(pimlicoEndpoint) })
const result = await pimlicoClient.request({ 
    // @ts-ignore
    method: "pm_sponsorUserOperation", 
    params: [userOperation, { entryPoint: entryPoint }] 
const paymasterAndData = result.paymasterAndData