evm
Category
Auto-generated documentation for the evm bag.watch functions.
- divmul Computes (x * d) / y using 512-bit intermediate to avoid overflow. Inverse of muldiv. Useful for price calculations.Scalar#types #evm
- evm_addmod EVM ADDMOD opcode: (a + b) % n without overflow. Returns 0 if n == 0 (EVM behavior). Uses 512-bit intermediate.Scalar#types #evm
- evm_bit_count Population count: Returns the number of set bits (1s) in a UINT256 value. Useful for bitmap analysis and flag counting.Scalar#types #evm
- evm_byte EVM BYTE opcode: Extract the nth byte from a 256-bit value. Byte 0 is MSB, byte 31 is LSB. Returns 0 if n >= 32.Scalar#types #evm
- evm_ceil_div Ceiling division: (x + y - 1) / y. Rounds up to ensure no remainder.Scalar#types #evm
- evm_clamp Constrains x to the range [lo, hi]. Equivalent to max(lo, min(hi, x)).Scalar#types #evm
- evm_clz Count leading zeros: Returns the number of leading zero bits in a UINT256 value. Returns 256 for zero. Useful for finding the most significant bit position.Scalar#types #evm
- evm_ctz Count trailing zeros: Returns the number of trailing zero bits in a UINT256 value. Returns 256 for zero. Useful for finding the least significant bit position.Scalar#types #evm
- evm_disassemble Disassembles EVM bytecode into core instruction metadata using evmone's advanced analysis. Returns 22 essential columns: pc, label, mnemonic, opcode, push_value (BYTES32), instruction properties, stack analysis, block structure, and gas costs from evmone. For comprehensive analysis including CFG, function detection, memory tracking, and dominance analysis, use evm_disassemble_full().Table#evm
- evm_iszero EVM ISZERO opcode: Returns 1 if x == 0, otherwise returns 0.Scalar#types #evm
- evm_max Returns the maximum of two UINT256 values.Scalar#types #evm
- evm_min Returns the minimum of two UINT256 values.Scalar#types #evm
- evm_modexp EVM MODEXP precompile: Computes base^exp mod mod using modular exponentiation. Returns 0 if mod is 0 or 1. Uses square-and-multiply algorithm. Critical for cryptographic operations like RSA verification.Scalar#types #evm
- evm_mulmod EVM MULMOD opcode: (a * b) % n without overflow. Returns 0 if n == 0 (EVM behavior). Uses 512-bit intermediate. Essential for cryptographic operations.Scalar#types #evm
- evm_prepare_deployment Creates deployment payloads by combining bytecode with constructor arguments.Scalar#evm
- evm_prepare_tx Builds an unsigned eth_sendTransaction JSON payload with minimal inputs.Scalar#evm
- evm_sar EVM SAR opcode: Arithmetic right shift x by shift bits. Sign-extends (fills with 1s for negative values). For signed INT256.Scalar#types #evm
- evm_shl EVM SHL opcode: Left shift x by shift bits. Returns 0 if shift >= 256.Scalar#types #evm
- evm_shr EVM SHR opcode: Logical right shift x by shift bits. Fills with zeros.Scalar#types #evm
- evm_sign Returns the sign of an INT256 value: -1 for negative, 0 for zero, 1 for positive. Useful for direction detection in price changes and deltas.Scalar#types #evm
- evm_signextend EVM SIGNEXTEND opcode: Sign-extend x from byte k. Byte k is 0-indexed from LSB. Extends sign bit through higher bytes. Returns x unchanged if k >= 31.Scalar#types #evm
- evm_sqrt Integer square root (floor) using Newton-Raphson iteration. Returns floor(sqrt(x)). Essential for AMM liquidity calculations.Scalar#types #evm
- format_ether Human-readable helper for wei balances. Equivalent to format_units(amount, 18).Scalar#types #evm
- format_units Scales raw EVM integer balances by 10^decimals and returns a VARCHAR string representation.Scalar#types #evm
- muldiv Computes (x * y) / z using 512-bit intermediate to avoid overflow. Essential for DeFi calculations like token swaps and price computations.Scalar#types #evm
- parse_ether Shorthand for parse_units(value, 18). Converts ETH/WETH amounts to wei.Scalar#types #evm
- parse_gwei Shorthand for parse_units(value, 9). Converts gwei to wei.Scalar#types #evm
- parse_units Converts human-readable token amounts to UINT256 raw values by multiplying by 10^decimals.Scalar#types #evm
- sort_key Converts INT256/UINT256 to a sortable BLOB for use in ORDER BY. Necessary because DuckDB's default BLOB ordering doesn't handle signed integers correctly.Scalar#types #evm
- to_timestamp Converts a UINT256 Unix timestamp (seconds since epoch) to a TIMESTAMP.Scalar#types #evm
- try_add Add two UINT256 values, returning NULL if overflow occurs. Follows DuckDB's try_* convention for safe arithmetic.Scalar#types #evm
- try_mul Multiply two UINT256 values, returning NULL if overflow occurs. Follows DuckDB's try_* convention for safe arithmetic.Scalar#types #evm
- try_sub Subtract two UINT256 values, returning NULL if underflow occurs. Follows DuckDB's try_* convention for safe arithmetic.Scalar#types #evm