Ethereum
web3_sha3
web3_sha3 hashes a chunk of hex-encoded data with Keccak-256 and hands back the 32-byte digest. The name is a historical trap: despite "sha3", this is the original Keccak-256, not the NIST SHA3-256 that FIPS-202 later standardised with different padding. Ethereum settled on the pre-standard Keccak everywhere — it is the function behind address derivation, event topics, function selectors, and Merkle-Patricia trie keys — which is exactly why the node exposes it here. Send the data to https://ethereum.therpc.io/YOUR_API_KEY on mainnet (chain ID 1) and you get the canonical ETH-flavoured hash without needing a local crypto library. The input must be a 0x-prefixed hex string, and the output is a 0x-prefixed 64-character hex digest.
Use cases
- Derive the topic hash for a log filter by hashing an event signature like
Transfer(address,address,uint256), then drop the result into aneth_getLogsquery against an ERC-20 contract. - Build a 4-byte function selector by hashing a function signature such as
transfer(address,uint256)and taking the first four bytes of the Keccak-256 digest — the same value an EVM call places at the start of its calldata.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | data | string | Yes | Arbitrary data to hash, provided as a 0x-prefixed hex string. Empty input (`"0x"`) is valid. |
Response
| Type | Description |
|---|---|
| string | 0x-prefixed 32-byte (64-character) Keccak-256 hash of the input. |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | invalid argument | Input is not a valid 0x-prefixed hex string. |
Common pitfalls
- The input is interpreted as raw hex bytes, not text. To hash a string like an event signature, encode it to UTF-8 bytes and then to hex first; passing the literal characters will hash the wrong thing.
- Keccak-256 is not SHA3-256. A standard-library
sha3_256will give a different digest because of the padding change introduced when Keccak became FIPS-202. Reach for a library that explicitly offers the Ethereum Keccak variant (for examplekeccak256in viem or ethers), or just let this method compute it for you.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
Parameters
0x-prefixed hex string