# eth_getRawTransactionByHash

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

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

Returns the raw transaction data (RLP-encoded) for a transaction by its hash.

Reference: https://www.alchemy.com/docs/chains/pharos/pharos-api-endpoints/eth-get-raw-transaction-by-hash

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Transaction hash | string | Yes | The hash of the transaction to retrieve. |

## Result

**Raw transaction data** (null or string): The raw RLP-encoded transaction data as a hexadecimal string, or null if the transaction is not found.

## Example

### Request

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

### Response

```json
{
  "jsonrpc": "2.0",
  "result": "0xf86c0185012a05f200825208940599d52c37544c07605f470e5e20c1b266de858889021dfc23e5c290008025a084ce48a415a40d664f87a6a05e8ec8e2fd2f07a68b06d3f20d999d7e8c7b12dfa0464c6e93bfa8e779ecd48284cf47d2d797dc611bbc6dbd7ab8f57ccba039acec",
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

fetch('https://pharos-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://pharos-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getRawTransactionByHash",
    "params": ["0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44"]
}
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://pharos-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getRawTransactionByHash\",\n  \"params\": [\n    \"0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44\"\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://pharos-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getRawTransactionByHash\",\n  \"params\": [\n    \"0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://pharos-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_getRawTransactionByHash\",\n  \"params\": [\n    \"0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: eth_getRawTransactionByHash
description: Returns the raw transaction data (RLP-encoded) for a transaction by its hash.
params:
  - name: Transaction hash
    required: true
    description: The hash of the transaction to retrieve.
    schema:
      title: 32 byte hex value
      type: string
      pattern: ^0x[0-9a-f]{64}$
result:
  name: Raw transaction data
  description: The raw RLP-encoded transaction data as a hexadecimal string, or null if the transaction is not found.
  schema:
    oneOf:
      - title: Not Found (null)
        type: 'null'
      - title: Raw transaction data
        type: string
        pattern: ^0x[0-9a-f]*$
examples:
  - name: eth_getRawTransactionByHash example
    params:
      - name: Transaction hash
        value: '0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44'
    result:
      name: Raw transaction data
      value: '0xf86c0185012a05f200825208940599d52c37544c07605f470e5e20c1b266de858889021dfc23e5c290008025a084ce48a415a40d664f87a6a05e8ec8e2fd2f07a68b06d3f20d999d7e8c7b12dfa0464c6e93bfa8e779ecd48284cf47d2d797dc611bbc6dbd7ab8f57ccba039acec'
```
