Ethereum

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 an eth_getLogs query 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

#NameTypeRequiredDescription
1datastringYesArbitrary data to hash, provided as a 0x-prefixed hex string. Empty input (`"0x"`) is valid.

Response

TypeDescription
string0x-prefixed 32-byte (64-character) Keccak-256 hash of the input.

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": ["0x"],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602invalid argumentInput 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_256 will 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 example keccak256 in 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

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"web3_sha3","params":["0x"]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.