BNB Smart Chain

BNB Smart Chain

web3_sha3

BNB Smart Chain leans on hashing to identify functions and log topics, the chain where BEP-20 contracts emit events constantly and fees are paid in BNB. web3_sha3 exposes that primitive over RPC. Pass it a 0x-prefixed hex blob and the node returns the Keccak-256 digest of those raw bytes as a 32-byte hex value. The naming is a well-known trap. Despite the sha3 label, this computes Keccak-256, not the later NIST SHA3-256 standard, and the two produce different output for the same input. Send your data to https://bsc.therpc.io/YOUR_API_KEY on chain ID 56 to get the canonical hash the EVM itself uses.

Use cases

  • Derive the topic0 hash of a BEP-20 event signature so you can plug it into an eth_getLogs filter and match exactly the events you care about.
  • Produce a contract's 4-byte function selector by hashing its signature string and keeping the leading four bytes of the digest.

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://bsc.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 BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32602invalid argumentInput is not a valid 0x-prefixed hex string.

Common pitfalls

  • The input must already be hex-encoded bytes; hand it a raw UTF-8 string and you will hash the wrong thing, so convert your text to hex before the call.
  • Keccak-256 is not SHA3-256, and a generic library sha3 routine will quietly return a different digest unless it explicitly implements the EVM's Keccak variant.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

Parameters

0x-prefixed hex string

curl https://bsc.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.