web3_sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data on Optimism Layer 2.
Parameters
- Data -
DATA
- Data to compute the hash of
Implementation Examples
- cURL
- JavaScript
curl -X POST https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": ["0x68656c6c6f20776f726c64"],
"id": 1
}'
// Calculate hash of "hello world"
const response = await fetch('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'web3_sha3',
params: ["0x68656c6c6f20776f726c64"], // "hello world" in hex
id: 1
})
});
const data = await response.json();
console.log('Keccak-256 hash:', data.result);
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
}
Need help? Contact our support team or check the Optimism documentation.