Paymaster Client
A function to create a Paymaster Client.
A Paymaster Client is an interface to interact with ERC-7677 compliant Paymasters and provides the ability to sponsor User Operation gas fees.
Import
import { createPaymasterClient } from 'viem/account-abstraction'
Usage
import { http } from 'viem'
import {
createBundlerClient,
createPaymasterClient,
} from 'viem/account-abstraction'
import { sepolia } from 'viem/chains'
const paymasterClient = createPaymasterClient({
transport: http('https://public.pimlico.io/v2/11155111/rpc'),
})
const bundlerClient = createBundlerClient({
chain: sepolia,
paymaster: paymasterClient,
transport: http('https://public.pimlico.io/v2/11155111/rpc'),
})
Parameters
key (optional)
- Type:
string
- Default:
"paymaster"
A key for the Client.
const client = createPaymasterClient({
key: 'foo',
transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
name (optional)
- Type:
string
- Default:
"Paymaster Client"
A name for the Client.
const client = createPaymasterClient({
name: 'Foo Bundler Client',
transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
pollingInterval (optional)
- Type:
number
- Default:
4_000
Frequency (in ms) for polling enabled Actions.
const client = createPaymasterClient({
pollingInterval: 10_000,
transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
rpcSchema (optional)
- Type:
RpcSchema
- Default:
PaymasterRpcSchema
Typed JSON-RPC schema for the client.
import { rpcSchema } from 'viem'
type CustomRpcSchema = [{
Method: 'eth_wagmi',
Parameters: [string]
ReturnType: string
}]
const client = createPaymasterClient({
rpcSchema: rpcSchema<CustomRpcSchema>(),
transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
const result = await client.request({
method: 'eth_waeth_wagmi
params: ['hello'],
})
transport
- Type:
Transport
The Transport of the Paymaster Client.
const paymasterClient = createPaymasterClient({
transport: http('https://public.pimlico.io/v2/11155111/rpc'),
})