Units & Global Variables

11.1 Ether and time units

years was removed (leap years). finney and szabo were removed in 0.7.0. Units apply only to literals: use n * 1 days for variables.

11.2 Block and transaction properties

immediate caller (EOA or contract) wei sent with the call bytes calldata original EOA of the transaction (do not use for auth) effective gas price current block number (on some L2s this differs — check docs) block time in seconds (proposer-influenced within limits) address payable fee recipient of the block EIP-1559 base fee EIP-4844 blob base fee (0.8.24+) block gas limit beacon chain randomness (replaces block.difficulty; biasable — not secure randomness) hash of one of the 256 most recent blocks, else 0 versioned hash of the i-th blob of the tx (0.8.24+)

11.3 ABI and cryptographic functions

ABI-encode arguments (32-byte padded) tightly packed encoding (no padding) abi.encodeWithSelector(bytes4,...) selector + encoded args abi.encodeWithSignature(string,...) same, computing selector from signature abi.encodeCall(fn, (args)) type-checked selector + args (0.8.11+) abi.decode(bytes, (types)) decode ABI data sha256(bytes), ripemd160(bytes) ecrecover(hash, v, r, s) recover signer address from ECDSA signature (returns 0 on failure) addmod(x, y, k), mulmod(x, y, k) modular arithmetic with arbitrary precision intermediates

11.4 Contract-related

current contract (convertible to address) next contract up in the inheritance linearization deprecated; since Cancun only sends Ether (no deletion) unless in the creation tx type(C).creationCode / runtimeCode ERC-165 interface ID type(T).min / type(T).max integer/enum bounds

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Globals {
    function snapshot() external payable returns (address, uint256, uint256, uint256, bytes4) {
        return (msg.sender, msg.value, block.timestamp, block.chainid, msg.sig);
    }

    function deadlinePassed(uint256 start) external view returns (bool) {
        return block.timestamp >= start + 7 days;
    }
}