Bundler
The Openfort Bundler is a high-performance ERC-4337 bundler that aggregates UserOperations and submits them to the blockchain. It's designed for reliability and speed, ensuring your users' transactions are included quickly.
Overview
ERC-4337 bundlers are specialized relayers that:
- Receive UserOperations from applications
- Validate and simulate operations
- Bundle multiple operations into transactions
- Submit them to the blockchain via the EntryPoint contract
The bundler handles all this complexity, providing a JSON-RPC interface for your application.
Getting Started
To use the bundler, make JSON-RPC requests to:
https://api.openfort.io/rpc/{chainId}Replace {chainId} with the appropriate chain ID. Include your Openfort publishable key in the Authorization header:
Authorization: Bearer YOUR_OPENFORT_PUBLISHABLE_KEYGet your public key from the Openfort Dashboard.
Available Endpoints
| Method | Description |
|---|---|
eth_sendUserOperation | Submit a UserOperation for inclusion |
eth_estimateUserOperationGas | Estimate gas for a UserOperation |
eth_getUserOperationReceipt | Get the receipt for a submitted operation |
eth_getUserOperationByHash | Retrieve a UserOperation by its hash |
eth_supportedEntryPoints | List supported EntryPoint contracts |
Quick Example
This example shows how to use the Openfort bundler with viem to send a sponsored UserOperation:
import { createPublicClient, http } from 'viem'
import { sepolia } from 'viem/chains'
import { privateKeyToAccount } from 'viem/accounts'
import {
createBundlerClient,
createPaymasterClient,
toCoinbaseSmartAccount
} from 'viem/account-abstraction'
// Create a public client for reading blockchain state
const client = createPublicClient({
chain: sepolia,
transport: http(),
})
// Create the paymaster client with Openfort
const paymasterClient = createPaymasterClient({
transport: http('https://api.openfort.io/rpc/11155111', {
fetchOptions: {
headers: {
'Authorization': 'Bearer YOUR_OPENFORT_PUBLISHABLE_KEY',
},
},
}),
})
// Create a smart account (using Coinbase Smart Account as an example)
const owner = privateKeyToAccount(process.env.PRIVATE_KEY)
const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// Create the bundler client with the Openfort bundler
const bundlerClient = createBundlerClient({
account,
paymaster: paymasterClient,
client,
paymasterContext: {
policyId: 'YOUR_POLICY_ID_HERE'
},
transport: http('https://api.openfort.io/rpc/11155111', {
fetchOptions: {
headers: {
'Authorization': 'Bearer YOUR_OPENFORT_PUBLISHABLE_KEY',
},
},
}),
})
// Send a UserOperation
const hash = await bundlerClient.sendUserOperation({
calls: [{
to: '0xcb98643b8786950F0461f3B0edf99D88F274574D',
value: 0n,
data: '0x1234',
}],
})
// Wait for the UserOperation receipt
const receipt = await bundlerClient.waitForUserOperationReceipt({ hash })
console.log('UserOperationReceipt:', receipt)Next Steps
- Endpoint Reference - Detailed documentation for all bundler methods
- Error Reference - Common errors and how to resolve them
- Supported Chains - List of networks where the bundler is available