# evm_byte

Implements the EVM BYTE opcode over a UINT256 word. BYTE index 0 selects the most significant byte and index 31 selects the least significant byte. Negative indices and indices above 31 return zero. NULL input propagates to NULL.

Canonical HTML: <https://determica.com/docs/functions/evm_byte>

- Kind: scalar function
- Category: [EVM utilities](/docs/category/evm-utilities.md)
- Tags: Types, EVM

Implements the EVM BYTE opcode over a UINT256 word. BYTE index 0 selects the most significant byte and index 31 selects the least significant byte. Negative indices and indices above 31 return zero. NULL input propagates to NULL.

## Overload 1: evm_byte(BIGINT, UINT256)

```sql
evm_byte(BIGINT, UINT256)
```

Extracts one byte using EVM most-significant-byte-first indexing.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `n` (BIGINT; required; positional) — BIGINT index; 0 is the most significant byte and 31 the least.
- `x` (UINT256; required; positional) — UINT256 EVM word.

### Returns

Selected byte

UINT256 value 0 through 255; out-of-range indices return zero; NULL input returns NULL.

- `byte_value` (UINT256)

Selected byte. UINT256 value 0 through 255; out-of-range indices return zero; NULL input returns NULL.

### Examples

_Local SQL · Local_

```sql
SELECT evm_byte(0::BIGINT, '0x1200000000000000000000000000000000000000000000000000000000000034'::UINT256)::VARCHAR AS result;
-- => [{"result":"18"}]
```
