getUserOperationGasPrice
Return a User Operation based on a User Operation hash.
Usage
import { pimlicoBundlerClient } from "./client"
const smartAccountClient = createSmartAccountClient({
account: safeAccount,
entryPoint: ENTRYPOINT_ADDRESS_V06,
chain: sepolia,
bundlerTransport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=API_KEY"),
middleware: {
gasPrice: async () => (await pimlicoBundlerClient.getUserOperationGasPrice()).fast, // use pimlico bundler to get gas prices, if using pimlico
sponsorUserOperation: paymasterClient.sponsorUserOperation, // optional
},
})
/* other gas alternatives */
const gasPriceResult = await pimlicoBundlerClient.getUserOperationGasPrice()
/**
* {
"slow": {
"maxFeePerGas": 3267781404n,
"maxPriorityFeePerGas": 3267781404n
},
"standard": {
"maxFeePerGas": 3439769899n,
"maxPriorityFeePerGas": 3439769899n
},
"fast": {
"maxFeePerGas": 3620810421n,
"maxPriorityFeePerGas": 3620810421n
}
}
*/import { ENTRYPOINT_ADDRESS_V07, bundlerActions } from "permissionless"
import { pimlicoBundlerActions } from "permissionless/actions/pimlico"
import { createClient, http } from "viem"
import { sepolia } from "viem/chains"
export const pimlicoBundlerClient = createClient({
chain: sepolia,
transport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_API_KEY_HERE"),
})
.extend(bundlerActions(ENTRYPOINT_ADDRESS_V07))
.extend(pimlicoBundlerActions(ENTRYPOINT_ADDRESS_V07))Returns
- Type:
GetUserOperationGasPriceReturnType
The maxFeePerGas and maxPriorityFeePerGas values for the different gas price tiers. Choosing a faster gas price will mean faster inclusion by the Pimlico Bundler.