web3_sha3
https://api.triport.io/v1/polygon/rpcComputes the keccak256 (SHA3) hash of the given data on the server and returns it as a hex string.
web3_sha3 takes a single 0x-prefixed hex byte string, computes its keccak256
digest server-side, and returns the 32-byte result as a 0x-prefixed hex string.
This is the same keccak256 used throughout the EVM (function selectors, event
topics, storage slots), not the NIST SHA3-256 variant — despite the method name.
In practice you rarely need this method in production. Every major client
library (ethers, web3.js, web3.py) computes keccak256 locally without a network
round-trip, which is faster and avoids spending your rate-limit budget. Reach
for web3_sha3 only when you have no local hashing primitive available, or when
you want to confirm a hash against the node's own implementation.
The method is read-only and available on the free tier under the
polygon_read_rpc category.
Parameters
Positional params array with exactly one element.
datastring (0x-prefixed hex)required0x prefix; an empty payload is encoded as 0x.Response
(0x68656c6c6f20776f726c64 is the ASCII bytes for hello world; its keccak256
digest is the value shown above.)
resultstring (0x-prefixed hex)0x prefix).Errors
Errors follow the standard JSON-RPC error envelope. See errors.md for the full structure.
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The trial period for the API key has ended. |
-32002 | tier_insufficient | The key's tier is below the required tier for this method. |
-32003 | rate_limited | The per-tier RPS limit (15/20/100/250) was exceeded. |
-32004 | subscription_expired | The subscription tied to the key has lapsed. |
-32005 | unauthorized | Missing, malformed, or invalid API key. |
-32601 | method_unknown | The method name is not recognized or not enabled for this key. |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/polygon/rpc", {
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: ["0x68656c6c6f20776f726c64"],
}),
});
const { result } = await res.json();
console.log(result);
// 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fadTypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const triport = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const hash = await triport.polygon.rpc<string>("web3_sha3", [
"0x68656c6c6f20776f726c64",
]);
console.log(hash);
// 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fadPython (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
result = client.polygon.rpc("web3_sha3", ["0x68656c6c6f20776f726c64"])
print(result)
# 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fadNotes
- Prefer local hashing. Libraries such as
ethers.keccak256,web3.utils.sha3, andeth_utils.keccakproduce the identical result without a request. Use them in hot paths to avoid consuming your RPS budget. - keccak256, not SHA3-256. The output matches the EVM's keccak256 (used for selectors, event topics, and storage layout), not the finalized NIST SHA3.
- Input must be hex.
datahas to be a0x-prefixed hex string. Pass0xfor the empty input; the result is the keccak256 of zero bytes. - Related:
web3_clientVersionis the other method in theweb3namespace. For network identity seenet_versionandeth_chainId.