web3_sha3
https://api.triport.io/v1/ethereumReturns the Keccak-256 hash of the given data.
web3_sha3 computes the Keccak-256 hash of a single piece of input data and
returns it as a 0x-prefixed hex string. It is a pure utility method: it
performs no chain lookups, so the result depends only on the bytes you pass in.
Despite the sha3 name, this method returns a Keccak-256 digest, not the
finalized NIST SHA-3 standard. The two differ in their padding, so hashing the
same input with a generic SHA-3 library produces a different result. This
Keccak-256 variant is the one used throughout Ethereum — for function selectors,
event topic signatures, storage-slot derivation, and address checksums — which
is why this method exists on the JSON-RPC surface.
The input must be a 0x-prefixed hex string. To hash a UTF-8 string, encode it
to hex first — for example, "hello world" becomes 0x68656c6c6f20776f726c64.
Parameters
The params array takes exactly one positional argument.
datastringrequired0x-prefixed hexadecimal string.Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version, always "2.0". |
id | number | Echoes the request id. |
result | string | The Keccak-256 hash of the input, as a 32-byte (66-character including the 0x prefix) hex string. |
Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The account's trial period has ended. |
-32002 | tier_insufficient | The account's tier does not grant access to this method. |
-32003 | rate_limited | The per-tier RPS limit was exceeded. Back off and retry. |
-32004 | subscription_expired | The account's paid subscription has lapsed. |
-32005 | unauthorized | Missing or invalid API key. |
-32601 | method_unknown | The method name is not recognized. |
A malformed input (missing 0x prefix or non-hex characters) is rejected with
the standard JSON-RPC invalid-params error. See errors.md for
the full error envelope and handling guidance.
Examples
JavaScript (fetch)
const toHex = (s) =>
"0x" + [...new TextEncoder().encode(s)]
.map((b) => b.toString(16).padStart(2, "0"))
.join("");
const res = await fetch("https://api.triport.io/v1/ethereum", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "web3_sha3",
params: [toHex("hello world")],
}),
});
const { result } = await res.json();
console.log("keccak256:", result);TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const result = await client.ethereum.request<string>("web3_sha3", [
"0x68656c6c6f20776f726c64",
]);
console.log("keccak256:", result);Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
payload = "hello world".encode("utf-8").hex()
result = client.ethereum.request("web3_sha3", ["0x" + payload])
print("keccak256:", result)Notes
- This is Keccak-256, not the finalized SHA-3 standard. If you compute the
hash locally to compare, use a Keccak-256 implementation (e.g.
ethers'keccak256, or Python'seth-hash/pysha3Keccak variant), not a genericsha3_256function. - The result is always 32 bytes — a 66-character string including the
0xprefix — regardless of input length. - Passing an empty input (
"0x") returns the Keccak-256 hash of the empty byte string:0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470. - Because the digest is deterministic and computed from your input alone, you can also derive it client-side to avoid a round trip; this method is a convenience for when you want the node to compute it for you.
- Rate limiting is RPS-per-tier with burst; there is no daily quota. A
-32003 rate_limitederror means you should back off and retry shortly. - Related: web3_clientVersion — the other method in
the
web3namespace.