---
title: "eth_getTransactionByHash"
description: "按交易哈希返回交易详情（Polygon Amoy）"
url: "https://blockreq.com/docs/zh-cn/build/api-reference/polygon-amoy/eth_getTransactionByHash/"
---

# eth_getTransactionByHash

**网络：** Polygon Amoy · 测试网 · Chain ID `80002`（`0x13882`）

**计为 1 个 Request。** 计费规则见 [Request Counting](https://blockreq.com/docs/zh-cn/pricing/request-counting/index.md)。

根据交易哈希返回交易详情。

## 参数

1. `DATA`（32 字节）— 交易哈希。

## 返回

`Object|null` — 交易对象；查不到时返回 `null`。

| 字段             | 类型     | 说明                            |
| ---------------- | -------- | ------------------------------- |
| hash             | DATA     | 交易哈希                        |
| nonce            | QUANTITY | 发送方 nonce                    |
| from             | DATA     | 发送方地址                      |
| to               | DATA     | 接收方地址                      |
| value            | QUANTITY | 转账金额（wei）                 |
| gas              | QUANTITY | 交易 Gas 上限                   |
| gasPrice         | QUANTITY | Gas Price（wei）                |
| input            | DATA     | 调用数据                        |
| blockHash        | DATA     | 区块哈希（pending 时为 null）   |
| blockNumber      | QUANTITY | 区块号（pending 时为 null）     |
| transactionIndex | QUANTITY | 区块内索引（pending 时为 null） |

## 请求

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

## 响应

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "hash": "0x88df...",
    "from": "0x...",
    "to": "0x...",
    "value": "0xde0b6b3a7640000",
    "blockNumber": "0x134e82a",
    "gasPrice": "0x3b9aca00"
  }
}
```

## 代码示例

**cURL**

```bash
curl -X POST https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],"id":1}'
```

**TypeScript**

```typescript
const response = await fetch("https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "method": "eth_getTransactionByHash",
  "params": [
    "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
  ],
  "id": 1
}),
});
const data = await response.json();
console.log(data.result);
```

**Python**

```python
import requests

response = requests.post(
    "https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public",
    json={
  "jsonrpc": "2.0",
  "method": "eth_getTransactionByHash",
  "params": [
    "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
  ],
  "id": 1
}
)
print(response.json()["result"])
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],"id":1}`)
	resp, err := http.Post(
		"https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public",
		"application/json",
		bytes.NewBuffer(payload),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result map[string]interface{}
	json.Unmarshal(body, &result)
	fmt.Println(result["result"])
}
```

**viem**

```typescript
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  transport: http("https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public"),
});

const result = await client.request({
  method: "eth_getTransactionByHash",
  params: ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],
});
console.log(result);
```

**Foundry**

```bash
cast rpc --rpc-url https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public eth_getTransactionByHash 0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b
```

**Hardhat**

```javascript
const { ethers } = require("hardhat");

async function main() {
  const provider = new ethers.JsonRpcProvider("https://polygon-amoy-bor-rpc.blockreq.com/v1/rpc/public");
  const result = await provider.send("eth_getTransactionByHash", ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"]);
  console.log(result);
}

main();
```
