# AbiFunction.getSelector

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

Useful for computing function selectors for calldata.

## Imports

:::code-group
```ts [Named]
import { AbiFunction } from 'ox'
```

```ts [Entrypoint]
import * as AbiFunction from 'ox/AbiFunction'
```
:::

## Examples

```ts twoslash
import { AbiFunction } from 'ox'

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

```ts twoslash
import { AbiFunction } from 'ox'

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
```

**Source:** [src/core/AbiFunction.ts](https://github.com/wevm/ox/blob/main/src/core/AbiFunction.ts#L1095)

## 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`](/api/Hash/keccak256) hash of the function signature.

`Hex.Hex`
