# hex

Formats a BLOB-backed EVM byte value as uppercase hexadecimal text without a 0x prefix. hex and to_hex are compatibility aliases with identical behavior.

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

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

Formats a BLOB-backed EVM byte value as uppercase hexadecimal text without a 0x prefix. hex and to_hex are compatibility aliases with identical behavior.

## Overload 1: hex(ADDRESS)

```sql
hex(ADDRESS)
```

Returns uppercase hexadecimal for the stored bytes of ADDRESS, BYTES4, BYTES32, or BYTES256.

- 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

- `value` (ADDRESS; required; positional) — ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

### Returns

Uppercase hexadecimal text

Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

- `hex` (VARCHAR)

Uppercase hexadecimal text. Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

## Overload 2: hex(BYTES4)

```sql
hex(BYTES4)
```

Returns uppercase hexadecimal for the stored bytes of ADDRESS, BYTES4, BYTES32, or BYTES256.

- 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

- `value` (BYTES4; required; positional) — ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

### Returns

Uppercase hexadecimal text

Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

- `hex` (VARCHAR)

Uppercase hexadecimal text. Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

## Overload 3: hex(BYTES32)

```sql
hex(BYTES32)
```

Returns uppercase hexadecimal for the stored bytes of ADDRESS, BYTES4, BYTES32, or BYTES256.

- 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

- `value` (BYTES32; required; positional) — ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

### Returns

Uppercase hexadecimal text

Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

- `hex` (VARCHAR)

Uppercase hexadecimal text. Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

## Overload 4: hex(BYTES256)

```sql
hex(BYTES256)
```

Returns uppercase hexadecimal for the stored bytes of ADDRESS, BYTES4, BYTES32, or BYTES256.

- 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

- `value` (BYTES256; required; positional) — ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

### Returns

Uppercase hexadecimal text

Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

- `hex` (VARCHAR)

Uppercase hexadecimal text. Returns two uppercase hex characters per stored byte, without a 0x prefix. NULL returns NULL.

## Additional examples

```sql
-- Display the raw bytes of the mainnet USDC address
SELECT hex('0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'::ADDRESS) AS address_hex;
-- => [{"address_hex":"A0B86991C6218B36C1D19D4A2E9EB0CE3606EB48"}]
```
