> **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.

# Create Block Filter \[block.createFilter]

Creates a filter to listen for new block hashes.

Poll the filter with [`Actions.filter.getChanges`](/docs/actions/public/filter/getChanges) and tear it down with [`Actions.filter.uninstall`](/docs/actions/public/filter/uninstall).

## Usage

This example creates a filter to listen for new block hashes.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const filter = await client.block.createFilter()
// @log: { id: '0x345a6572337856574a76364e457a4366', request: ƒ, type: 'block' }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())
```
:::

### Standalone Action

Call `Actions.block.createFilter` directly by passing the Client as the first argument.

:::code-group
```ts twoslash [example.ts]
import { Actions } from 'viem'
import { client } from './viem.config'

const filter = await Actions.block.createFilter(client)
// @log: { id: '0x345a6572337856574a76364e457a4366', request: ƒ, type: 'block' }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
})
```
:::

## Return Value

`Actions.filter.Filter<'block'>`

A block filter. Its `request` function uses the transport that created the filter ID.
