# 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 method retrieves and decodes userOperations from the logs of mined transactions by querying the node. If you attempt to fetch a userOperation from a distant past block, the request may be rejected by the node due to limitations on the block range size it can process.

  The default range we support is 150 blocks, however the following networks have an unlimited range.

  - Ethereum
  - Polygon
  - Base
  - Optimism
  - Worldchain
  - Arbitrum
</Note>


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. |

## Result

**UserOperation** (object): The `UserOperation` object.

## Example

### Request

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

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "sender": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "nonce": 1,
    "initCode": "0x",
    "callData": "0x",
    "callGasLimit": "0x0",
    "verificationGasLimit": "0x0",
    "preVerificationGas": "0x0",
    "maxFeePerGas": "0x0",
    "maxPriorityFeePerGas": "0x0",
    "paymasterAndData": "0x",
    "signature": "0x",
    "entryPoint": "0x",
    "blockNumber": "0x",
    "blockHash": "0x",
    "transactionHash": "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": [
    "0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122"
  ]
}'
```

### JavaScript

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

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": ["0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122"]
}
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    \"0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122\"\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    \"0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122\"\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    \"0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122\"\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 method retrieves and decodes userOperations from the logs of mined transactions by querying the node. If you attempt to fetch a userOperation from a distant past block, the request may be rejected by the node due to limitations on the block range size it can process.

    The default range we support is 150 blocks, however the following networks have an unlimited range.

    - Ethereum
    - Polygon
    - Base
    - Optimism
    - Worldchain
    - Arbitrum
  </Note>
params:
  - name: userOpHash
    required: true
    description: The `userOpHash` of the `UserOperation` to retrieve.
    schema:
      title: 32 byte hex value
      type: string
      pattern: ^0x[0-9a-f]{64}$
result:
  name: UserOperation
  description: The `UserOperation` object.
  schema:
    type: object
    required:
      - entrypointV06Response
      - entrypointV07Response
    properties:
      entrypointV06Response:
        title: Entrypoint v0.6 Response
        type: object
        properties:
          sender:
            type: string
            description: The account sending the userOperation.
          nonce:
            type: string
            description: Anti-replay parameter; also used as the salt for first-time account creation.
          initCode:
            type: string
            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
            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
            description: The amount of gas to allocate for the main execution call.
          verificationGasLimit:
            type: string
            description: The amount of gas to allocate for the verification step.
          preVerificationGas:
            type: string
            description: The amount of gas to compensate the bundler for pre-verification execution and calldata.
          maxFeePerGas:
            type: string
            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
            description: Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas).
          signature:
            type: string
            description: Data passed into the account along with the nonce during the verification step.
          paymasterAndData:
            type: string
            description: Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction).
          entryPoint:
            type: string
            description: Address of the EntryPoint contract.
          blockNumber:
            type: string
            description: Block number in which `UserOperation` is included.
          blockHash:
            type: string
            description: Block hash of the block containing `UserOperation`.
          transactionHash:
            type: string
            description: Transaction hash of the `UserOperation`.
      entrypointV07Response:
        title: Entrypoint v0.7 / v0.8 Response
        type: object
        properties:
          sender:
            type: string
            description: The account sending the userOperation.
          nonce:
            type: string
            description: Anti-replay parameter; also used as the salt for first-time account creation.
          factory:
            type: string
            description: The account factory address (needed if and only if the account is not yet on-chain and needs to be created).
          factoryData:
            type: string
            description: Data for the account factory (only if the account factory exists).
          callData:
            type: string
            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
            description: The amount of gas to allocate for the main execution call.
          verificationGasLimit:
            type: string
            description: The amount of gas to allocate for the verification step.
          preVerificationGas:
            type: string
            description: The amount of gas to compensate the bundler for pre-verification execution and calldata.
          maxFeePerGas:
            type: string
            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
            description: Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas).
          paymasterVerificationGasLimit:
            type: string
            description: The amount of gas to allocate for the paymaster validation code (only if a paymaster exists).
          paymasterPostOpGasLimit:
            type: string
            description: The amount of gas to allocate for the paymaster post-op code (only if a paymaster exists).
          signature:
            type: string
            description: Data passed into the account along with the nonce during the verification step.
          paymaster:
            type: string
            description: Address of the paymaster contract (or empty, if the account pays for itself).
          paymasterData:
            type: string
            description: Data for the paymaster (only if the paymaster exists).
          entryPoint:
            type: string
            description: Address of the EntryPoint contract.
          blockNumber:
            type: string
            description: Block number in which `UserOperation` is included.
          blockHash:
            type: string
            description: Block hash of the block containing `UserOperation`.
          transactionHash:
            type: string
            description: Transaction hash of the `UserOperation`.
examples:
  - name: eth_getUserOperationByHash example
    params:
      - name: userOpHash
        value: '0x77c0b560eb0b042902abc5613f768d2a6b2d67481247e9663bf4d68dec0ca122'
    result:
      name: UserOperation
      value:
        sender: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
        nonce: 1
        initCode: 0x
        callData: 0x
        callGasLimit: '0x0'
        verificationGasLimit: '0x0'
        preVerificationGas: '0x0'
        maxFeePerGas: '0x0'
        maxPriorityFeePerGas: '0x0'
        paymasterAndData: 0x
        signature: 0x
        entryPoint: 0x
        blockNumber: 0x
        blockHash: 0x
        transactionHash: 0x
```
