Skip to content

Instantly share code, notes, and snippets.

@ydm
Last active June 12, 2026 12:14
Show Gist options
  • Select an option

  • Save ydm/61c78a61f5d0cc1abe9242826d6e0aee to your computer and use it in GitHub Desktop.

Select an option

Save ydm/61c78a61f5d0cc1abe9242826d6e0aee to your computer and use it in GitHub Desktop.
Function Purpose Example
abi.encode(...) Standard ABI encoding of arguments. abi.encode(x, y)
abi.encodePacked(...) Tight/packed encoding (non-standard ABI encoding). Often used before hashing. abi.encodePacked(x, y)
abi.encodeWithSelector(bytes4 selector, ...) ABI-encode arguments and prepend a function selector. abi.encodeWithSelector(IERC20.transfer.selector, to, amount)
abi.encodeWithSignature(string signature, ...) Compute selector from a function signature string and prepend it. abi.encodeWithSignature("transfer(address,uint256)", to, amount)
abi.encodeCall(functionPointer, (...)) Type-safe encoding of a function call. Compiler verifies argument types. abi.encodeCall(IERC20.transfer, (to, amount))
abi.decode(bytes data, (Types...)) Decode ABI-encoded data into specified types. abi.decode(data, (uint256, address))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment