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.

Example

Runs locally

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

API reference

hex(ADDRESS) #

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

Inputs

Name Type Use
value ADDRESS

ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

required positional

Returns

Name Type
hex VARCHAR

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

Show 3 more signatures
hex(BYTES4) #

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

Inputs

Name Type Use
value BYTES4

ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

required positional

Returns

Name Type
hex VARCHAR

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

hex(BYTES32) #

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

Inputs

Name Type Use
value BYTES32

ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

required positional

Returns

Name Type
hex VARCHAR

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

hex(BYTES256) #

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

Inputs

Name Type Use
value BYTES256

ADDRESS, BYTES4, BYTES32, or BYTES256 value encoded exactly as stored.

required positional

Returns

Name Type
hex VARCHAR

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