# eth_getUserOperationByHash

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://eth-mainnet.g.alchemy.com/v2/{apiKey}

Return a `UserOperation` based on a `userOpHash`.

<Note title="Limitations">
  This method retrieves and decodes userOperations from the logs of mined transactions by querying the node. The number of blocks scanned in a single request is limited. Use `blockOption` to position a bounded lookup window when searching historical blocks.
</Note>

### Maximum Scan Width

The maximum number of blocks a single request may scan for the operation's `UserOperationEvent` depends on the chain and your plan tier. This limits the width of the scan, not the age of the operation. A `blockOption` may position the scan at historical blocks, provided the resulting range does not exceed this width:

| Chain | Free | Pay As You Go | Enterprise |
|-------|------|---------------|------------|
| Arbitrum Mainnet, Arbitrum Sepolia, Arc Mainnet, Base Mainnet, Base Sepolia, Ethereum Mainnet, Ethereum Sepolia, OP Mainnet, OP Sepolia, Polygon PoS Amoy, Polygon PoS Mainnet, Robinhood Chain Mainnet, World Chain Mainnet, World Chain Sepolia | 150 | unlimited | unlimited |
| Avalanche Fuji, Hyperliquid Mainnet | 150 | 2,000 | 2,000 |
| Avalanche Mainnet, Robinhood Chain Testnet | 150 | 5,000 | 5,000 |
| BNB Smart Chain Testnet | 50 | 50 | 50 |
| Monad Mainnet | 150 | 1,000 | 1,000 |

Chains not listed here use a 150-block limit on every tier.


Reference: https://www.alchemy.com/docs/wallets/api-reference/bundler-api/bundler-api-endpoints/eth-get-user-operation-by-hash

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| userOpHash | string | Yes | The `userOpHash` of the `UserOperation` to retrieve. |
| blockOption | object or string | No | Optional block scope for the lookup: a `{ fromBlock, toBlock }` range (block numbers or tags) or a single block hash. Any other value is ignored, as it was before this parameter existed. |

## Result

**UserOperation** (object or null): The matched `UserOperation` with inclusion metadata, or null if no operation is found.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getUserOperationByHash",
  "params": [
    "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "blockHash": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "blockNumber": "0x12a3b4c",
    "entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
    "transactionHash": "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
    "userOperation": {
      "sender": "0x1111111111111111111111111111111111111111",
      "nonce": "0x1",
      "factory": "0x5555555555555555555555555555555555555555",
      "factoryData": "0x1234",
      "callData": "0x",
      "callGasLimit": "0x5208",
      "verificationGasLimit": "0x186a0",
      "preVerificationGas": "0x7530",
      "maxFeePerGas": "0x59682f00",
      "maxPriorityFeePerGas": "0x59682f",
      "paymaster": "0x0000000000000000000000000000000000000000",
      "paymasterVerificationGasLimit": "0x7530",
      "paymasterPostOpGasLimit": "0x5208",
      "paymasterData": "0x",
      "signature": "0x"
    }
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://eth-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getUserOperationByHash",
  "params": [
    "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    {
      "fromBlock": "string",
      "toBlock": "string"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_getUserOperationByHash',
    params: [
      '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
      {fromBlock: 'string', toBlock: 'string'}
    ]
  })
};

fetch('https://eth-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getUserOperationByHash",
    "params": [
        "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        {
            "fromBlock": "string",
            "toBlock": "string"
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getUserOperationByHash\",\n  \"params\": [\n    \"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n    {\n      \"fromBlock\": \"string\",\n      \"toBlock\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://eth-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getUserOperationByHash\",\n  \"params\": [\n    \"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n    {\n      \"fromBlock\": \"string\",\n      \"toBlock\": \"string\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://eth-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getUserOperationByHash\",\n  \"params\": [\n    \"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n    {\n      \"fromBlock\": \"string\",\n      \"toBlock\": \"string\"\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: eth_getUserOperationByHash
description: |
  Return a `UserOperation` based on a `userOpHash`.

  <Note title="Limitations">
    This method retrieves and decodes userOperations from the logs of mined transactions by querying the node. The number of blocks scanned in a single request is limited. Use `blockOption` to position a bounded lookup window when searching historical blocks.
  </Note>

  ### Maximum Scan Width

  The maximum number of blocks a single request may scan for the operation's `UserOperationEvent` depends on the chain and your plan tier. This limits the width of the scan, not the age of the operation. A `blockOption` may position the scan at historical blocks, provided the resulting range does not exceed this width:

  | Chain | Free | Pay As You Go | Enterprise |
  |-------|------|---------------|------------|
  | Arbitrum Mainnet, Arbitrum Sepolia, Arc Mainnet, Base Mainnet, Base Sepolia, Ethereum Mainnet, Ethereum Sepolia, OP Mainnet, OP Sepolia, Polygon PoS Amoy, Polygon PoS Mainnet, Robinhood Chain Mainnet, World Chain Mainnet, World Chain Sepolia | 150 | unlimited | unlimited |
  | Avalanche Fuji, Hyperliquid Mainnet | 150 | 2,000 | 2,000 |
  | Avalanche Mainnet, Robinhood Chain Testnet | 150 | 5,000 | 5,000 |
  | BNB Smart Chain Testnet | 50 | 50 | 50 |
  | Monad Mainnet | 150 | 1,000 | 1,000 |

  Chains not listed here use a 150-block limit on every tier.
x-compute-units: 20
params:
  - name: userOpHash
    required: true
    description: The `userOpHash` of the `UserOperation` to retrieve.
    schema:
      type: string
      pattern: ^0x[0-9a-fA-F]*$
      minLength: 66
      maxLength: 66
  - name: blockOption
    required: false
    description: 'Optional block scope for the lookup: a `{ fromBlock, toBlock }` range (block numbers or tags) or a single block hash. Any other value is ignored, as it was before this parameter existed.'
    schema:
      anyOf:
        - type: object
          properties:
            fromBlock:
              anyOf:
                - type: string
                  pattern: ^0x[0-9a-fA-F]*$
                  minLength: 3
                  maxLength: 66
                - type: string
                  enum:
                    - earliest
                    - finalized
                    - safe
                    - latest
                    - pending
            toBlock:
              anyOf:
                - type: string
                  pattern: ^0x[0-9a-fA-F]*$
                  minLength: 3
                  maxLength: 66
                - type: string
                  enum:
                    - earliest
                    - finalized
                    - safe
                    - latest
                    - pending
        - type: string
          pattern: ^0x[0-9a-fA-F]*$
          minLength: 66
          maxLength: 66
result:
  name: UserOperation
  description: The matched `UserOperation` with inclusion metadata, or null if no operation is found.
  schema:
    anyOf:
      - type: object
        required:
          - entryPoint
          - userOperation
        properties:
          blockHash:
            anyOf:
              - type: string
                pattern: ^0x[0-9a-fA-F]*$
                minLength: 66
                maxLength: 66
              - type: 'null'
            description: Block hash of the block containing `UserOperation`.
          blockNumber:
            anyOf:
              - type: string
                pattern: ^0x[0-9a-fA-F]*$
                minLength: 3
                maxLength: 66
              - type: 'null'
            description: Block number in which `UserOperation` is included.
          entryPoint:
            type: string
            pattern: ^0x[0-9a-fA-F]*$
            minLength: 42
            maxLength: 42
            description: Address of the EntryPoint contract.
          transactionHash:
            anyOf:
              - type: string
                pattern: ^0x[0-9a-fA-F]*$
                minLength: 66
                maxLength: 66
              - type: 'null'
            description: Transaction hash of the `UserOperation`.
          userOperation:
            anyOf:
              - type: object
                required:
                  - sender
                  - nonce
                  - callData
                  - callGasLimit
                  - verificationGasLimit
                  - preVerificationGas
                  - maxFeePerGas
                  - maxPriorityFeePerGas
                  - signature
                properties:
                  sender:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 42
                    maxLength: 42
                    description: The account sending the userOperation.
                  nonce:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Anti-replay parameter; also used as the salt for first-time account creation.
                  initCode:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: The initCode of the account (needed if and only if the account is not yet on-chain and needs to be created).
                  callData:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: Encoded data for executing the primary function call or operation within the user's transaction, such as calling a smart contract function or transferring tokens. This data is passed to the sender's address during the execution of the userOperation.
                  callGasLimit:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to allocate for the main execution call.
                  verificationGasLimit:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to allocate for the verification step.
                  preVerificationGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to compensate the bundler for pre-verification execution and calldata.
                  maxFeePerGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The maximum fee per gas to pay for the execution of this operation (similar to EIP-1559 max_fee_per_gas).
                  maxPriorityFeePerGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas).
                  paymasterAndData:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction).
                  signature:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: Data passed into the account along with the nonce during the verification step.
                  eip7702Auth:
                    anyOf:
                      - type: object
                        required:
                          - chainId
                          - nonce
                          - address
                          - yParity
                          - r
                          - s
                        properties:
                          chainId:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The chain ID authorized by this EIP-7702 tuple.
                          nonce:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The nonce of the EIP-7702 authority.
                          address:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                            description: The contract address to set as code for the authority.
                          yParity:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The y-parity value for the authorization signature.
                          r:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The ECDSA r value.
                          s:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The ECDSA s value.
                        additionalProperties: {}
                        title: EIP-7702 authorization
                      - type: 'null'
                  aggregator:
                    anyOf:
                      - anyOf:
                          - type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                          - type: string
                            enum:
                              - 0x
                      - type: 'null'
                  entryPoint:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 42
                    maxLength: 42
                    description: Address of the EntryPoint contract.
                  blockNumber:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Block number in which `UserOperation` is included.
                  blockHash:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 66
                    maxLength: 66
                    description: Block hash of the block containing `UserOperation`.
                  transactionHash:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 66
                    maxLength: 66
                    description: Transaction hash of the `UserOperation`.
                additionalProperties: {}
                title: Entrypoint v0.6 Response
              - type: object
                required:
                  - sender
                  - nonce
                  - callData
                  - callGasLimit
                  - verificationGasLimit
                  - preVerificationGas
                  - maxFeePerGas
                  - maxPriorityFeePerGas
                  - signature
                properties:
                  sender:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 42
                    maxLength: 42
                    description: The account sending the userOperation.
                  nonce:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Anti-replay parameter; also used as the salt for first-time account creation.
                  factory:
                    anyOf:
                      - anyOf:
                          - type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                          - type: string
                            enum:
                              - 0x
                      - type: 'null'
                    description: The account factory address (needed if and only if the account is not yet on-chain and needs to be created).
                  factoryData:
                    anyOf:
                      - type: string
                        pattern: ^0x[0-9a-fA-F]*$
                      - type: 'null'
                    description: Data for the account factory (only if the account factory exists).
                  callData:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: Encoded data for executing the primary function call or operation within the user's transaction, such as calling a smart contract function or transferring tokens. This data is passed to the sender's address during the execution of the userOperation.
                  callGasLimit:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to allocate for the main execution call.
                  verificationGasLimit:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to allocate for the verification step.
                  preVerificationGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The amount of gas to compensate the bundler for pre-verification execution and calldata.
                  maxFeePerGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: The maximum fee per gas to pay for the execution of this operation (similar to EIP-1559 max_fee_per_gas).
                  maxPriorityFeePerGas:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas).
                  paymaster:
                    anyOf:
                      - anyOf:
                          - type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                          - type: string
                            enum:
                              - 0x
                      - type: 'null'
                    description: Address of the paymaster contract (or empty, if the account pays for itself).
                  paymasterVerificationGasLimit:
                    anyOf:
                      - type: string
                        pattern: ^0x[0-9a-fA-F]*$
                        minLength: 3
                        maxLength: 66
                      - type: 'null'
                    description: The amount of gas to allocate for the paymaster validation code (only if a paymaster exists).
                  paymasterPostOpGasLimit:
                    anyOf:
                      - type: string
                        pattern: ^0x[0-9a-fA-F]*$
                        minLength: 3
                        maxLength: 66
                      - type: 'null'
                    description: The amount of gas to allocate for the paymaster post-op code (only if a paymaster exists).
                  paymasterData:
                    anyOf:
                      - type: string
                        pattern: ^0x[0-9a-fA-F]*$
                      - type: 'null'
                    description: Data for the paymaster (only if the paymaster exists).
                  signature:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    description: Data passed into the account along with the nonce during the verification step.
                  eip7702Auth:
                    anyOf:
                      - type: object
                        required:
                          - chainId
                          - nonce
                          - address
                          - yParity
                          - r
                          - s
                        properties:
                          chainId:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The chain ID authorized by this EIP-7702 tuple.
                          nonce:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The nonce of the EIP-7702 authority.
                          address:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                            description: The contract address to set as code for the authority.
                          yParity:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The y-parity value for the authorization signature.
                          r:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The ECDSA r value.
                          s:
                            type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            description: The ECDSA s value.
                        additionalProperties: {}
                        title: EIP-7702 authorization
                      - type: 'null'
                  aggregator:
                    anyOf:
                      - anyOf:
                          - type: string
                            pattern: ^0x[0-9a-fA-F]*$
                            minLength: 42
                            maxLength: 42
                          - type: string
                            enum:
                              - 0x
                      - type: 'null'
                  entryPoint:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 42
                    maxLength: 42
                    description: Address of the EntryPoint contract.
                  blockNumber:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 3
                    maxLength: 66
                    description: Block number in which `UserOperation` is included.
                  blockHash:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 66
                    maxLength: 66
                    description: Block hash of the block containing `UserOperation`.
                  transactionHash:
                    type: string
                    pattern: ^0x[0-9a-fA-F]*$
                    minLength: 66
                    maxLength: 66
                    description: Transaction hash of the `UserOperation`.
                additionalProperties: {}
                title: Entrypoint v0.7 / v0.8 Response
            description: The `UserOperation` object.
            title: UserOperation
        additionalProperties: {}
        title: UserOperation by hash result
      - type: 'null'
examples:
  - name: eth_getUserOperationByHash example
    params:
      - name: userOpHash
        value: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
    result:
      name: UserOperation
      value:
        blockHash: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
        blockNumber: '0x12a3b4c'
        entryPoint: '0x0000000071727De22E5E9d8BAf0edAc6f37da032'
        transactionHash: '0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'
        userOperation:
          sender: '0x1111111111111111111111111111111111111111'
          nonce: '0x1'
          factory: '0x5555555555555555555555555555555555555555'
          factoryData: '0x1234'
          callData: 0x
          callGasLimit: '0x5208'
          verificationGasLimit: '0x186a0'
          preVerificationGas: '0x7530'
          maxFeePerGas: '0x59682f00'
          maxPriorityFeePerGas: '0x59682f'
          paymaster: '0x0000000000000000000000000000000000000000'
          paymasterVerificationGasLimit: '0x7530'
          paymasterPostOpGasLimit: '0x5208'
          paymasterData: 0x
          signature: 0x
```
