viem.sh
Open in
urlscan Pro
76.76.21.98
Public Scan
Submitted URL: https://viem.sh/docs/utilities/keccak256.html#keccak256
Effective URL: https://viem.sh/docs/utilities/keccak256.html
Submission: On January 03 via api from US — Scanned from DE
Effective URL: https://viem.sh/docs/utilities/keccak256.html
Submission: On January 03 via api from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
Skip to content SearchK Main NavigationDocsExamples 1.21.4 Migrating to 1.21.x Changelog Contributing GitHub Appearance GitHub Menu On this page Sidebar Navigation INTRODUCTION Why viem Getting Started Migration Guide Ethers v5 → viem TypeScript Error Handling Platform Compatibility FAQ CLIENTS & TRANSPORTS Introduction Public Client Wallet Client Test Client Build your own Client TRANSPORTS HTTP WebSocket Custom (EIP-1193) Fallback Chains PUBLIC ACTIONS Introduction ACCOUNT getBalance getTransactionCount BLOCK getBlock getBlockNumber getBlockTransactionCount watchBlockNumber watchBlocks CHAIN getChainId FEE estimateFeesPerGas estimateGas estimateMaxPriorityFeePerGas getFeeHistory getGasPrice FILTERS & LOGS createBlockFilter createEventFilter createPendingTransactionFilter getFilterChanges getFilterLogs getLogs watchEvent uninstallFilter PROOF getProof SIGNATURE verifyMessage verifyTypedData TRANSACTION call prepareTransactionRequest getTransaction getTransactionConfirmations getTransactionReceipt sendRawTransaction waitForTransactionReceipt watchPendingTransactions WALLET ACTIONS Introduction ACCOUNT getAddresses requestAddresses ASSETS watchAsset CHAIN addChain switchChain DATA signMessage signTypedData PERMISSIONS getPermissions requestPermissions TRANSACTION prepareTransactionRequest sendRawTransaction sendTransaction signTransaction TEST ACTIONS Introduction ACCOUNT impersonateAccount setBalance setCode setNonce setStorageAt stopImpersonatingAccount BLOCK getAutomine increaseTime mine removeBlockTimestampInterval setAutomine setIntervalMining setBlockTimestampInterval setBlockGasLimit setNextBlockBaseFeePerGas setNextBlockTimestamp NODE setCoinbase setMinGasPrice SETTINGS reset setLoggingEnabled setRpcUrl STATE dumpState loadState revert snapshot TRANSACTION dropTransaction getTxpoolContent getTxpoolStatus inspectTxpool sendUnsignedTransaction ACCOUNTS JSON-RPC LOCAL Private Key Mnemonic Hierarchical Deterministic (HD) Custom signMessage signTransaction signTypedData CONTRACT Contract Instances ACTIONS createContractEventFilter deployContract estimateContractGas getBytecode getContractEvents getStorageAt multicall readContract simulateContract writeContract watchContractEvent ENCODING decodeDeployData decodeErrorResult decodeEventLog decodeFunctionData decodeFunctionResult encodeDeployData encodeErrorResult encodeEventTopics encodeFunctionData encodeFunctionResult ENS ACTIONS getEnsAddress getEnsAvatar getEnsName getEnsResolver getEnsText UTILITIES labelhash namehash normalize ABI decodeAbiParameters encodeAbiParameters encodePacked getAbiItem parseAbi parseAbiItem parseAbiParameter parseAbiParameters UTILITIES ADDRESSES getAddress getContractAddress isAddress isAddressEqual CHAIN extractChain DATA concat isBytes isHex pad slice size trim ENCODING fromBytes fromHex fromRlp toBytes toHex toRlp HASH getEventSelector getEventSignature getFunctionSelector getFunctionSignature keccak256 ripemd160 sha256 SIGNATURE compactSignatureToHex compactSignatureToSignature hashMessage hashTypedData hexToCompactSignature hexToSignature recoverAddress recoverMessageAddress recoverPublicKey recoverTypedDataAddress signatureToCompactSignature signatureToHex verifyMessage verifyTypedData TRANSACTION parseTransaction serializeTransaction UNITS formatEther formatGwei formatUnits parseEther parseGwei parseUnits THIRD PARTY Account Abstraction Miscellaneous GLOSSARY Terms Types Errors On this page Table of Contents for current page * Install * Usage * Returns * Parameters * value * to On this page KECCAK256 Calculates the Keccak256 hash of a byte array or hex value. This function is a re-export of keccak_256 from @noble/hashes – an audited & minimal JS hashing library. INSTALL ts import { keccak256 } from 'viem' import { keccak256 } from 'viem' USAGE ts import { keccak256 } from 'viem' keccak256(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]) // 0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0 keccak256('0xdeadbeef') // 0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1 // hash utf-8 string keccak256(toHex('hello world')) // 0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0 import { keccak256 } from 'viem' keccak256(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]) // 0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0 keccak256('0xdeadbeef') // 0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1 // hash utf-8 string keccak256(toHex('hello world')) // 0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0 RETURNS Hex | ByteArray The hashed value. PARAMETERS VALUE * Type: Hex | ByteArray The hex value or byte array to hash. TO * Type: "bytes" | "hex" * Default: "hex" The output type. ts import { keccak256 } from 'viem' keccak256( new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33], 'bytes' ) // Uint8Array [62, 162, 241, 208, 171, 243, 252, 102, 207, 41, 238, 187, 112, 203, 212, 231, 254, 118, 46, 248, 160, 155, 204, 6, 200, 237, 246, 65, 35, 10, 254, 192] import { keccak256 } from 'viem' keccak256( new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33], 'bytes' ) // Uint8Array [62, 162, 241, 208, 171, 243, 252, 102, 207, 41, 238, 187, 112, 203, 212, 231, 254, 118, 46, 248, 160, 155, 204, 6, 200, 237, 246, 65, 35, 10, 254, 192] Edit this page on GitHub Previous pagegetFunctionSignature Next pageripemd160 Released under the MIT License. Copyright © 2023-present weth, LLC