to_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

-- to_hex is the compatibility alias of hex
SELECT to_hex('0xa9059cbb'::BYTES4) AS selector_hex;
-- => [{"selector_hex":"A9059CBB"}]

API reference

to_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
to_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.

to_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.

to_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.