curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": [
"0x68656c6c6f"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": [
"0x68656c6c6f"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}data — the data to hash (hex encoded)result — the Keccak-256 hash of the input dataweb3_sha3 method is useful for:
web3_sha3 code examplesconst 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();
Was this page helpful?