githubEdit

web3_sha3 - Arbitrum

Example code for the web3_sha3 JSON RPC method. Сomplete guide on how to use web3_sha3 JSON RPC in GetBlock Web3 documentation.

This method returns Keccak-256 (not the standardized SHA3-256) hash of the given data.

Parameters

parameters
Data Type
description

data

string

The data to hash, encoded as a hexadecimal string.

Request

curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "method": "web3_sha3",
  "params": ["0xf2a2b854721d4372474fc76cc13445a73369c0c334f4935c88bde3c310f28c9a"],
  "id": "getblock.io"
}'

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0xf5d3389b32cee33308ce9af2d8aefa1517aa90ccb7b1d2eb29c61f13e1fd3cea"
}

Reponse Parameter Definition

Field
Type
Description

result

string

The Keccak-256 hash of the input data, as a hexadecimal string.

Use case

The web3_sha3 method helps developers to:

  • Generate a hash of arbitrary data for off-chain validation.

  • Create message digests for signing and verification.

  • Derive storage keys for smart contracts.

  • Hash inputs for deterministic contract logic or mapping keys.

  • Prepare data for signature-based login flows in dApps.

Error handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS_TOKEN.

-32602

invalid argument

Input is not properly hex-encoded.

Integration with Web3

Using web3_sha3 allows developers to:

  • Ensure consistent hashing for signing or contract storage.

  • Generate identifiers or keys deterministically.

  • Validate data integrity off-chain.

  • Prepare inputs for smart contracts that require Keccak-256 hashes.

  • Build signature-based authentication or meta-transaction systems.

Last updated

Was this helpful?