跳转到内容

eth_getTransactionByHash

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

  1. DATA(32 字节)— 交易哈希。

Object|null — 交易对象;查不到时返回 null

字段类型说明
hashDATA交易哈希
nonceQUANTITY发送方 nonce
fromDATA发送方地址
toDATA接收方地址
valueQUANTITY转账金额(wei)
gasQUANTITY交易 Gas 上限
gasPriceQUANTITYGas Price(wei)
inputDATA调用数据
blockHashDATA区块哈希(pending 时为 null)
blockNumberQUANTITY区块号(pending 时为 null)
transactionIndexQUANTITY区块内索引(pending 时为 null)
Terminal window
curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x88df...",
"from": "0x...",
"to": "0x...",
"value": "0xde0b6b3a7640000",
"blockNumber": "0x134e82a",
"gasPrice": "0x3b9aca00"
}
}
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");
const tx = await provider.getTransaction("0x88df...");
console.log("From:", tx.from, "To:", tx.to, "Value:", tx.value.toString());
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))
tx = w3.eth.get_transaction("0x88df...")
print(f"From: {tx['from']} To: {tx['to']}")
MethodCost
eth_getTransactionByHash10 RU