Skip to main content
POST
web3_sha3
curl --request POST \
  --url https://tempo-moderato.core.chainstack.com/a25a421add2280d53fdbc23417055501/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "jsonrpc": "2.0",
  "method": "web3_sha3",
  "params": [
    "0x68656c6c6f"
  ],
  "id": 1
}
'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}
Tempo API method that returns the Keccak-256 hash of the given data. This is the same hashing algorithm used by Ethereum for various purposes.
Get you own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • data — the data to hash (hex encoded)

Response

  • result — the Keccak-256 hash of the input data

Use case

The web3_sha3 method is useful for:
  • Computing function selectors (first 4 bytes of keccak256 of function signature)
  • Computing event topics
  • General-purpose hashing

web3_sha3 code examples

const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const sha3Example = async () => {
    // Hash hex-encoded data via RPC
    const hash = await provider.send("web3_sha3", ["0x68656c6c6f"]); // "hello" in hex
    console.log(`Hash of 'hello': ${hash}`);

    // Compare with ethers.js local computation
    const localHash = ethers.keccak256("0x68656c6c6f");
    console.log(`Local hash: ${localHash}`);
    console.log(`Hashes match: ${hash === localHash}`);

    // Compute a function selector
    const transferSelector = await provider.send("web3_sha3", [
      ethers.toUtf8Bytes("transfer(address,uint256)").reduce(
        (hex, byte) => hex + byte.toString(16).padStart(2, '0'),
        '0x'
      )
    ]);
    console.log(`\nTransfer function selector: ${transferSelector.slice(0, 10)}`);
  };

sha3Example();

Body

application/json
jsonrpc
string
default:2.0
method
string
default:web3_sha3
params
any[]

Data to hash (hex encoded)

id
integer
default:1

Response

200 - application/json

Keccak-256 hash

jsonrpc
string
id
integer
result
string

The Keccak-256 hash of the given data

Last modified on January 28, 2026