TriportRPC

web3_sha3

POSThttps://api.triport.io/v1/polygon/rpc

Computes the keccak256 (SHA3) hash of the given data on the server and returns it as a hex string.

Polygon (mainnet, chainId 0x89 / 137)polygon_read_rpcfree — free 15 rps · basic 20 rps · pro 100 rps · business 250 rps

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)required
The byte string to hash. Must be valid hex with a 0x 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)
The keccak256 digest of the input — always 32 bytes (66 characters including the 0x prefix).

Errors

Errors follow the standard JSON-RPC error envelope. See errors.md for the full structure.

CodeMeaningWhen it happens
-32001trial_expiredThe trial period for the API key has ended.
-32002tier_insufficientThe key's tier is below the required tier for this method.
-32003rate_limitedThe per-tier RPS limit (15/20/100/250) was exceeded.
-32004subscription_expiredThe subscription tied to the key has lapsed.
-32005unauthorizedMissing, malformed, or invalid API key.
-32601method_unknownThe 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);
// 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad

TypeScript 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);
// 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad

Python (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)
# 0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad

Notes

  • Prefer local hashing. Libraries such as ethers.keccak256, web3.utils.sha3, and eth_utils.keccak produce 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. data has to be a 0x-prefixed hex string. Pass 0x for the empty input; the result is the keccak256 of zero bytes.
  • Related: web3_clientVersion is the other method in the web3 namespace. For network identity see net_version and eth_chainId.