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.

Scalar function TypesEVM

Example

Runs locally

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

API reference

evm_byte(BIGINT, UINT256) #

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

Inputs

Name Type Use
n BIGINT

BIGINT index; 0 is the most significant byte and 31 the least.

required positional
x UINT256

UINT256 EVM word.

required positional

Returns

Name Type
byte_value UINT256

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