evm_abi_word

Encodes an ADDRESS, BYTES32, BOOLEAN, or integer as one 32-byte Solidity ABI word. ADDRESS and unsigned integer values are left-padded with zeros. Signed integers are sign-extended in two's-complement form; BOOLEAN uses 0 or 1. BYTES32 values are copied unchanged.

Example

Runs locally

-- Compute a Uniswap v4 PoolId from PoolKey fields
SELECT keccak256(
  evm_abi_word('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS) ||
  evm_abi_word('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'::ADDRESS) ||
  evm_abi_word(200::UINT24) ||
  evm_abi_word(4::INT24) ||
  evm_abi_word('0x0000000000000000000000000000000000000000'::ADDRESS)
) AS pool_id;

API reference

evm_abi_word(69 types) #

Encode one value as a 32-byte ABI word; unsigned values are zero-padded and signed values sign-extended.

Exact signatures (69)
  • evm_abi_word(ADDRESS)
  • evm_abi_word(BYTES32)
  • evm_abi_word(BOOLEAN)
  • evm_abi_word(UTINYINT)
  • evm_abi_word(USMALLINT)
  • evm_abi_word(UINTEGER)
  • evm_abi_word(UBIGINT)
  • evm_abi_word(UHUGEINT)
  • evm_abi_word(TINYINT)
  • evm_abi_word(SMALLINT)
  • evm_abi_word(INTEGER)
  • evm_abi_word(BIGINT)
  • evm_abi_word(HUGEINT)
  • evm_abi_word(UINT160)
  • evm_abi_word(UINT256)
  • evm_abi_word(INT256)
  • evm_abi_word(INT160)
  • evm_abi_word(UINT24)
  • evm_abi_word(UINT32)
  • evm_abi_word(UINT40)
  • evm_abi_word(UINT48)
  • evm_abi_word(UINT56)
  • evm_abi_word(UINT64)
  • evm_abi_word(UINT72)
  • evm_abi_word(UINT80)
  • evm_abi_word(UINT88)
  • evm_abi_word(UINT96)
  • evm_abi_word(UINT104)
  • evm_abi_word(UINT112)
  • evm_abi_word(UINT120)
  • evm_abi_word(UINT136)
  • evm_abi_word(UINT144)
  • evm_abi_word(UINT152)
  • evm_abi_word(UINT168)
  • evm_abi_word(UINT176)
  • evm_abi_word(UINT184)
  • evm_abi_word(UINT192)
  • evm_abi_word(UINT200)
  • evm_abi_word(UINT208)
  • evm_abi_word(UINT216)
  • evm_abi_word(UINT224)
  • evm_abi_word(UINT232)
  • evm_abi_word(UINT240)
  • evm_abi_word(UINT248)
  • evm_abi_word(INT24)
  • evm_abi_word(INT40)
  • evm_abi_word(INT48)
  • evm_abi_word(INT56)
  • evm_abi_word(INT72)
  • evm_abi_word(INT80)
  • evm_abi_word(INT88)
  • evm_abi_word(INT96)
  • evm_abi_word(INT104)
  • evm_abi_word(INT112)
  • evm_abi_word(INT120)
  • evm_abi_word(INT136)
  • evm_abi_word(INT144)
  • evm_abi_word(INT152)
  • evm_abi_word(INT168)
  • evm_abi_word(INT176)
  • evm_abi_word(INT184)
  • evm_abi_word(INT192)
  • evm_abi_word(INT200)
  • evm_abi_word(INT208)
  • evm_abi_word(INT216)
  • evm_abi_word(INT224)
  • evm_abi_word(INT232)
  • evm_abi_word(INT240)
  • evm_abi_word(INT248)

Note: The scalar type must be registered.

Inputs

Name Type Use
value ADDRESS | BYTES32 | BOOLEAN | UTINYINT | USMALLINT | UINTEGER | UBIGINT | UHUGEINT | TINYINT | SMALLINT | INTEGER | BIGINT | HUGEINT | UINT160 | UINT256 | INT256 | INT160 | UINT24 | UINT32 | UINT40 | UINT48 | UINT56 | UINT64 | UINT72 | UINT80 | UINT88 | UINT96 | UINT104 | UINT112 | UINT120 | UINT136 | UINT144 | UINT152 | UINT168 | UINT176 | UINT184 | UINT192 | UINT200 | UINT208 | UINT216 | UINT224 | UINT232 | UINT240 | UINT248 | INT24 | INT40 | INT48 | INT56 | INT72 | INT80 | INT88 | INT96 | INT104 | INT112 | INT120 | INT136 | INT144 | INT152 | INT168 | INT176 | INT184 | INT192 | INT200 | INT208 | INT216 | INT224 | INT232 | INT240 | INT248

ADDRESS, BYTES32, BOOLEAN, native integer, or registered Solidity UINT/INT value.

required positional

Returns

Name Type
word BYTES32

Encoded ABI word. Returns the encoded word as BYTES32.

Overload examples

Runs locally

SELECT hex(evm_abi_word('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'::BYTES32)) AS word;

Runs locally

SELECT hex(evm_abi_word(true::BOOLEAN)) AS word;

Guidance

Choose the encoding function

Use evm_abi_word for layouts that require one standard 32-byte word per scalar.

  • Use encode_function_args to ABI-encode a complete argument list without a selector.
  • Use encode_function_data to prepend the function selector to encoded arguments.
  • Use abi_encode_packed for packed layouts that omit standard 32-byte padding.
  • Cast literals to ADDRESS or the intended UINT/INT width before encoding.

Runs locally

SELECT
  hex(evm_abi_word('0x0000000000000000000000000000000000000001'::ADDRESS)) AS address_word,
  hex(evm_abi_word(-1::INT24)) AS signed_word;

PoolKey hashing

A Uniswap v4 PoolId hashes the ABI encoding of the PoolKey fields in field order. Manual concatenation works here because each field occupies one static ABI word.

  • Encode currency0, currency1, and hooks as ADDRESS.
  • Encode fee as UINT24 and tickSpacing as INT24.
  • Concatenate the five words in PoolKey order and pass the result to keccak256.

Choose the right ABI primitive

Choose by byte framing and direction: selector construction, standard arguments, calldata, packed bytes, raw words, calldata decoding, and return-data decoding are distinct operations.

  • function_selector hashes already-canonical signature text exactly; function_selector_json builds a canonical signature from one JSON ABI fragment first.
  • encode_function_args emits selector-free standard ABI arguments; encode_function_data prefixes those same bytes with the 4-byte selector.
  • abi_encode_packed concatenates compact scalar encodings without standard ABI offsets, lengths, or 32-byte padding; evm_abi_word always emits exactly one padded 32-byte word.
  • decode_function_data consumes and validates selector-prefixed calldata inputs; call_decode consumes selector-free function return bytes.

Runs locally

SELECT
  function_selector('transfer(address,uint256)') AS selector,
  encode_function_data(
    '[{"type":"function","name":"transfer","inputs":[{"type":"address"},{"type":"uint256"}]}]'::JSON,
    'transfer(address,uint256)',
    '0x000000000000000000000000000000000000dEaD'::ADDRESS,
    1::UINT256
  ) AS calldata;

Examples

Runs locally

SELECT hex(evm_abi_word('0x0000000000000000000000000000000000000001'::ADDRESS)) AS word;