eth_getTransactionByHash
Returns the information about a transaction by transaction hash on Avalanche.
Why Avalanche? Build on the fastest smart contract platform with sub-second finality and customizable L1 subnets with sub-second finality, Evergreen subnets for institutions, and partnerships with Franklin Templeton, VanEck, and Bergen County.
Use Cases#
The eth_getTransactionByHash method is essential for:
- Transaction tracking - Get details of pending or confirmed transactions
- Payment verification - Verify transaction parameters
- Debugging - Analyze transaction data for institutional RWA tokenization ($18B+ transfer volume), gaming subnets, and enterprise blockchains
- Block explorers - Display transaction information
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
transactionHash | DATA | Yes | 32-byte transaction hash |
Request#
{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0xfe055919188f8e2360bead9ecd97ffa782c610730e9084c6533f799bafafa7e4"],
"id": 1
}
Returns#
| Field | Type | Description |
|---|---|---|
hash | DATA | Transaction hash |
from | DATA | Sender address |
to | DATA | Recipient address |
value | QUANTITY | Value in wei |
gas | QUANTITY | Gas provided |
gasPrice | QUANTITY | Gas price in wei |
input | DATA | Transaction input data |
nonce | QUANTITY | Sender's nonce |
blockHash | DATA | Block hash (null if pending) |
blockNumber | QUANTITY | Block number (null if pending) |
Code Examples#
- cURL
- JavaScript
- Python
- Go
curl -X POST https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0xfe055919188f8e2360bead9ecd97ffa782c610730e9084c6533f799bafafa7e4"],
"id": 1
}'
import { JsonRpcProvider, formatEther } from 'ethers';
const provider = new JsonRpcProvider('https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc');
const txHash = '0xfe055919188f8e2360bead9ecd97ffa782c610730e9084c6533f799bafafa7e4';
const tx = await provider.getTransaction(txHash);
if (tx) {
console.log('From:', tx.from);
console.log('To:', tx.to);
console.log('Value:', formatEther(tx.value));
console.log('Block:', tx.blockNumber);
}
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc'))
tx_hash = '0xfe055919188f8e2360bead9ecd97ffa782c610730e9084c6533f799bafafa7e4'
tx = w3.eth.get_transaction(tx_hash)
if tx:
print(f'From: {tx["from"]}')
print(f'To: {tx["to"]}')
print(f'Value: {w3.from_wei(tx["value"], "ether")}')
print(f'Block: {tx["blockNumber"]}')
package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
client, err := ethclient.Dial("https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc")
if err != nil {
log.Fatal(err)
}
txHash := common.HexToHash("0xfe055919188f8e2360bead9ecd97ffa782c610730e9084c6533f799bafafa7e4")
tx, isPending, err := client.TransactionByHash(context.Background(), txHash)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Pending: %v\n", isPending)
fmt.Printf("Value: %s\n", tx.Value().String())
}
Error Handling#
| Error Code | Message | Description |
|---|---|---|
| -32602 | Invalid params | Invalid transaction hash format |
Related Methods#
eth_getTransactionReceipt- Get transaction receipteth_sendRawTransaction- Send transaction