ERC-20 transfer function
transfer(address,uint256)
a9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b
The first 4 bytes, a9059cbb, are the function selector you see at the start of every ERC-20 transfer transaction.
Generate Keccak-256 hashes exactly as Ethereum and Solidity do. Hash a function signature to get its 4-byte selector, or an event signature to get its topic.
transfer(address,uint256).0x) into Compare with a checksum.transfer(address,uint256)
a9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b
The first 4 bytes, a9059cbb, are the function selector you see at the start of every ERC-20 transfer transaction.
hello
1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
Different from SHA3-256 of the same word, which is 3338be69…
c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
This is Ethereum's "empty code hash", the codehash of accounts without contract code.
Keccak-256 is the original version of the algorithm that became SHA-3, and the hash function used throughout Ethereum. When NIST standardised SHA-3 in 2015, it changed the padding rule. Ethereum had already chosen Keccak in 2014, so it kept the original. That is why Solidity's keccak256() and the standard SHA3-256 give different results for the same input.
| Use | What is hashed | What is kept |
|---|---|---|
| Function selector | The signature, e.g. transfer(address,uint256) | First 4 bytes (0xa9059cbb) |
| Event topic | The event signature, e.g. Transfer(address,address,uint256) | All 32 bytes (topic 0) |
| Address | The 64-byte public key | Last 20 bytes |
| Storage slots | Mapping key and slot number (ABI-encoded) | All 32 bytes |
| Checksum addresses (EIP-55) | The lowercase hex address | Decides which letters are uppercase |
For a selector, the signature must be in canonical form: the function name, then parameter types only, no names and no spaces, with aliases expanded. transfer(address to, uint amount) must be written as transfer(address,uint256). A single extra space gives a completely different hash.
bytes32 h = keccak256(abi.encodePacked("hello"));bytes4 selector = bytes4(keccak256("transfer(address,uint256)"));import { keccak256, toUtf8Bytes, id } from 'ethers'; keccak256(toUtf8Bytes('hello'));id('transfer(address,uint256)').slice(0, 10); // "0xa9059cbb"from eth_utils import keccak keccak(text='hello').hex()# Note: hashlib.sha3_256 is NOT Keccak-256My hash does not match Solidity's keccak256
Check you did not use SHA3-256: Python's hashlib.sha3_256 and PHP's hash("sha3-256") are the standard SHA-3, not Keccak. Also check the exact input: Solidity often hashes ABI-encoded bytes, not text.
The function selector is wrong
The signature must have no spaces and no parameter names, and use full type names (uint256, not uint).
I need to hash hex bytes, not text
This tool hashes text as UTF-8, so 0x1234 is hashed as six characters. Use a library such as ethers.js for raw bytes.
No. They share the same core, but SHA3-256 uses different padding, so the hashes differ. Ethereum uses Keccak-256.
Hash the canonical signature, such as transfer(address,uint256), and take the first 8 hex characters: a9059cbb.
256 bits: 64 hexadecimal characters, usually shown with a 0x prefix in Ethereum tools.
No. The hash is calculated in your browser.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.