ABI signature encoding
Compare encodeWithSignature with explicit selector encoding.
Solidity 0.8.36REPL mode
Why use this example
Use this pattern when you need to check the exact bytes, selector, hash, or decoded values that Solidity will produce. The entry isolates abi signature encoding so its input, result, and state changes stay easy to compare.
Solidity to run
bytes4 selector = bytes4(keccak256("approve(address,uint256)"))
bytes memory bySignature = abi.encodeWithSignature("approve(address,uint256)", address(0xBEEF), 42)
bytes memory bySelector = abi.encodeWithSelector(selector, address(0xBEEF), 42)
bySignature
bySelector
keccak256(bySignature) == keccak256(bySelector)Official Solidity reference
Compare this focused investigation with the complete language definition in the Solidity documentation.
ABI encoding functionsWhat to expect
Both encoding paths produce identical approve calldata, and the final hash comparison returns true.
Continue the investigation
Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.
Read about values and inspection Prototype Solidity behavior