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

# AbiFunction.getSelector

:::info
`AbiFunction.getSelector` is a re-export of ox's [`AbiFunction.getSelector`](https://oxlib.sh/api/AbiFunction/getSelector). Refer to the ox documentation for the full reference.
:::

Computes the [4-byte selector](https://solidity-by-example.org/function-selector/) for an [`AbiFunction.AbiFunction`](/docs/utilities/abifunction/types#abifunction).

Useful for computing function selectors for calldata.

## Imports

```ts
import { AbiFunction } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { AbiFunction } from 'viem/utils'

const selector = AbiFunction.getSelector(
  'function ownerOf(uint256 tokenId)'
)
// @log: '0x6352211e'
```

```ts twoslash
// @noErrors
import { AbiFunction } from 'viem/utils'

const selector = AbiFunction.getSelector({
  inputs: [{ type: 'uint256' }],
  name: 'ownerOf',
  outputs: [],
  stateMutability: 'view',
  type: 'function'
})
// @log: '0x6352211e'
```

## Definition

```ts
function getSelector(
  abiItem: string | AbiFunction,
): Hex.Hex
```

## Parameters

### abiItem

* **Type:** `string | AbiFunction`

The ABI item to compute the selector for.

#### abiItem.hash

* **Type:** `0x${string}`
* **Optional**

#### abiItem.overloads

* **Type:** `readonly any[]`
* **Optional**

## Return Type

The first 4 bytes of the [`Hash.keccak256`](/docs/utilities/hash/keccak256) hash of the function signature.

`Hex.Hex`
