eth_userop_hash
Compute the ERC-4337 userOpHash: an operation's id and signing digest.
Instructions
Compute the ERC-4337 userOpHash: an operation's id and signing digest.
The hash binds the operation to entry_point and chain_id, so the same
operation cannot be replayed against another EntryPoint or another chain.
version decides the rule and defaults to reading it off the canonical
EntryPoint address (0.6 0x5FF1…2789, 0.7 0x0000000071727De2…da032, 0.8
0x4337084d…f108, the same on every chain); pass it explicitly for a custom
deployment. v0.6 encodes six separate gas fields; v0.7 packs
verificationGasLimit/callGasLimit and maxPriorityFeePerGas/maxFeePerGas into
one word each (16 bytes apiece, high half first); v0.8 hashes that same
packed struct as EIP-712 typed data. The unpacked eth_sendUserOperation JSON
is accepted for v0.7/v0.8 and packed here, which is the fiddly half.
Returns {version, entry_point, chain_id, user_op_hash} plus the intermediate
values — op_hash for 0.6/0.7, domain_separator and struct_hash for
0.8 — and packed (the words that were hashed) for 0.7/0.8. signature is
never read: it signs this hash, so it cannot be part of it.
Example: eth_userop_hash(user_op, "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
-> version="0.7", user_op_hash="0x…".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_op | Yes | The ERC-4337 user operation as JSON, in the shape a bundler speaks. v0.7/v0.8 accept either the packed form (accountGasLimits/gasFees/initCode/paymasterAndData) or the unpacked eth_sendUserOperation form (factory+factoryData, verificationGasLimit+callGasLimit, maxPriorityFeePerGas+maxFeePerGas, paymaster+paymasterVerificationGasLimit+paymasterPostOpGasLimit+paymasterData). camelCase and snake_case keys are both understood; `signature` is ignored, being what signs this hash. A stringified JSON object is accepted. | |
| version | No | EntryPoint version, which decides the hashing rule. 'auto' reads it off a canonical EntryPoint address. | auto |
| chain_id | Yes | The chain id the operation is valid on (int, decimal string, or 0x-hex); part of the hash. | |
| entry_point | Yes | The EntryPoint contract address the operation is sent to — part of the hash, so the operation cannot be replayed against a different one. Also selects the version when `version` is 'auto'. |