> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theblockchainlibrary.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Function Selector

> The four-byte identifier derived from an EVM function signature and used to route calls to the intended function.

# Function Selector

The four-byte identifier derived from an EVM function signature and used to route calls to the intended function.

## Definition

The four-byte identifier derived from an EVM function signature and used to route calls to the intended function.

## Why it matters

Smart-contract concepts are essential for understanding programmable blockchain applications.

## How it works

When you write a function `transfer(address to, uint256 amount)`, the compiler hashes `transfer(address,uint256)`. The first four bytes of that hash become the function's ID. When a call arrives, the EVM compares these four bytes against the selectors defined in the contract's dispatcher to jump to the correct code location.

## Real-world example

When you execute a swap on a DEX, the input data in your transaction starts with a function selector like `0xa9059cbb`, which identifies the `transfer` function.

## Advantages

* Enables efficient function routing
* Provides unique identifiers for contract methods
* Crucial for cross-contract communication

## Limitations

* Risk of collision with very long function signatures
* Fixed size limits function count
* Not human-readable without mapping

## Common misconceptions

* Many think the function selector is the full name of the function, but it is just a short hash.
* Some believe it handles data validation, but it only handles the routing of the call.

## Related knowledge

* [ABI](/generated/v2/glossary/abi) — term
* [Smart Contract](/generated/v2/glossary/smart-contract) — term
* [Solidity](/generated/v2/resources/solidity) — term

***

**Canonical knowledge ID:** `glossary:function-selector`
