Skip to main content

Try it Live

Run Keccak256 examples in the interactive playground
Future Plans: This page is planned and under active development. Examples are placeholders and will be replaced with accurate, tested content.

Ethereum Methods

Specialized Keccak256 methods for Ethereum protocol operations: function selectors, event topics, and contract address derivation (CREATE/CREATE2).

selector(signature)

Compute function selector (first 4 bytes of Keccak256 hash). Signature:
Parameters:
  • signature (string) - Function signature (e.g., "transfer(address,uint256)")
Returns: Uint8Array (4 bytes) - Function selector Throws: Never throws for valid signature string
Technical Notes:
  • Returns first 4 bytes of Keccak256.hashString(signature)
  • Signature format: functionName(type1,type2,...) (no spaces, no param names)
  • Canonical types required: uint256 not uint, address not address payable
  • Case-sensitive - Transfertransfer
Signature normalization critical:
  • "transfer(address,uint256)" - Correct
  • "transfer(address, uint256)" - Space causes different selector
  • "transfer(address to, uint256 amount)" - Param names cause different selector
  • "transfer(address,uint)" - Use canonical uint256

topic(signature)

Compute event topic (32-byte Keccak256 hash). Signature:
Parameters:
  • signature (string) - Event signature (e.g., "Transfer(address,address,uint256)")
Returns: Keccak256Hash (32 bytes) - Event topic hash Throws: Never throws for valid signature string
Technical Notes:
  • Returns full 32 bytes (unlike selector which returns 4 bytes)
  • Used as topics[0] in Ethereum event logs
  • Indexed event parameters become additional topics (topics[1], topics[2], etc.)
  • Non-indexed parameters in log data field
Event Log Structure:

contractAddress(sender, nonce)

Compute contract address from deployer and nonce (CREATE opcode). Signature:
Parameters:
  • sender (Uint8Array) - Deployer address (20 bytes)
  • nonce (bigint) - Transaction nonce
Returns: Uint8Array (20 bytes) - Contract address Throws:
  • InvalidLengthError - Sender not 20 bytes
Algorithm:
Technical Notes:
  • Formula defined in Ethereum Yellow Paper
  • RLP encoding: [sender, nonce] where sender is 20 bytes, nonce is minimal big-endian
  • Last 20 bytes of hash become contract address
  • Nonce increments with each transaction from sender
  • Deterministic - same sender + nonce always produces same address

create2Address(deployer, salt, initCodeHash)

Compute contract address using CREATE2 opcode (EIP-1014). Signature:
Parameters:
  • deployer (Uint8Array) - Deployer address (20 bytes)
  • salt (Uint8Array) - 32-byte salt
  • initCodeHash (Uint8Array) - 32-byte hash of initialization code
Returns: Uint8Array (20 bytes) - Contract address Throws:
  • InvalidLengthError - Deployer not 20 bytes
  • InvalidLengthError - Salt not 32 bytes
  • InvalidLengthError - initCodeHash not 32 bytes
Algorithm:
Technical Notes:
  • Defined in EIP-1014
  • Enables deterministic deployment independent of nonce
  • Same deployer + salt + initCode always produces same address
  • 0xff prefix distinguishes from CREATE (prevents collision)
  • initCode hashed separately (allows large bytecode)
  • Commonly used for counterfactual instantiation, proxy factories
Comparison with CREATE:

Usage Examples

Full Contract Deployment Flow

Function Call Decoding

Event Log Processing