> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# `PaymasterClient.create`

A Paymaster Client is an interface to interact with **[ERC-7677 compliant Paymasters](https://eips.ethereum.org/EIPS/eip-7677)** and provides the ability to sponsor **User Operation** gas fees.

:::note
Read more on **ERC-7677 Paymasters**:

* [Website](https://erc7677.xyz/)
* [Specification](https://eips.ethereum.org/EIPS/eip-7677)
:::

## Import

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
```

## Usage

```ts twoslash
import { http } from 'viem'
import {
  BundlerClient,
  PaymasterClient,
} from 'viem/erc4337'
import { sepolia } from 'viem/chains'

const paymasterClient = PaymasterClient.create({ // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc'), // [!code focus]
}) // [!code focus]

const bundlerClient = BundlerClient.create({
  chain: sepolia,
  paymaster: paymasterClient, // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc'),
})
```

:::info
The Paymaster URL above is a public endpoint **for testnets only**. Please do not use it in production as you will likely be rate-limited. Consider using [Pimlico's Paymaster](https://www.pimlico.io) or another Paymaster service.
:::

:::tip
You can see an example of end-to-end Paymaster Client usage on the [Sending User Operations guide](/account-abstraction/guides/sending-user-operations#7-optional-sponsor-user-operation).
:::

## Parameters

### key

* **Type:** `string`
* **Default:** `"paymaster"`

A key for the Paymaster Client.

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
import { http } from 'viem'
const paymasterClient = PaymasterClient.create({
  key: 'foo', // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
```

### name

* **Type:** `string`
* **Default:** `"Paymaster Client"`

A name for the Paymaster Client.

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
import { http } from 'viem'
const paymasterClient = PaymasterClient.create({
  name: 'Foo Paymaster Client', // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
```

### pollingInterval

* **Type:** `number`
* **Default:** `4_000`

Frequency (in ms) for polling enabled Actions.

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
import { http } from 'viem'
const paymasterClient = PaymasterClient.create({
  pollingInterval: 10_000, // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc')
})
```

### schema

* **Type:** `RpcSchema`
* **Default:** `PaymasterRpcSchema`

Typed JSON-RPC schema for the client.

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
import { http } from 'viem'
import { z } from 'viem/zod'

const paymasterClient = PaymasterClient.create({
  schema: z.RpcSchema.from({ // [!code focus]
    eth_wagmi: { params: z.tuple([z.string()]), returns: z.string() }, // [!code focus]
  }), // [!code focus]
  transport: http('https://public.pimlico.io/v2/11155111/rpc')
})

const result = await paymasterClient.request({ // [!code focus]
  method: 'eth_wagmi', // [!code focus]
  params: ['hello'], // [!code focus]
}) // [!code focus]
```

### transport

* **Type:** `Transport`

The Transport of the Paymaster Client.

```ts twoslash
import { PaymasterClient } from 'viem/erc4337'
import { http } from 'viem'
const paymasterClient = PaymasterClient.create({
  transport: http('https://public.pimlico.io/v2/11155111/rpc'), // [!code focus]
})
```
