EthereumMethods

eth_getTransactionByHash

The eth_getTransactionByHash method returns information about a transaction for a given hash.

eth_getTransactionByHash

Overview

The 'eth_getTransactionByHash' method returns information about a transaction for a given hash.

Request

shell

curl --request POST \
     --url https://ethereum-mainnet-geth-archive.node.coinapi.io \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "params": [
    "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
  ],
  "method": "eth_getTransactionByHash"
}'

csharp

using RestSharp; {

var options = new RestClientOptions("https://ethereum-mainnet-geth-archive.node.coinapi.io");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json","X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY");
request.AddJsonBody("{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b\"],\"method\":\"eth_getTransactionByHash\"}", false);
var response = await client.PostAsync(request);

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

php

<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://ethereum-mainnet-geth-archive.node.coinapi.io",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'params' => [
'0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b'
],
'method' => 'eth_getTransactionByHash'
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"content-type: application/json",
"X-CoinAPI-Key": "73034021-THIS-IS-SAMPLE-KEY"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>

python

import requests

url = "https://ethereum-mainnet-geth-archive.node.coinapi.io"

payload = {
    "id": 1,
    "jsonrpc": "2.0",
    "params": ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],
    "method": "eth_getTransactionByHash"
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "X-CoinAPI-Key" : "73034021-THIS-IS-SAMPLE-KEY"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

javascript

  const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json', 'X-CoinAPI-Key': '73034021-THIS-IS-SAMPLE-KEY'},
  body: JSON.stringify({
    id: 1,
    jsonrpc: '2.0',
    params: ['0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b'],
    method: 'eth_getTransactionByHash'
  })
};

fetch('https://ethereum-mainnet-geth-archive.node.coinapi.io', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

go

package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://ethereum-mainnet-geth-archive.node.coinapi.io"

	payload := strings.NewReader("{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b\"],\"method\":\"eth_getTransactionByHash\"}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("accept", "application/json")
	req.Header.Add("content-type", "application/json")
  req.Header.Add("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}

ruby

require 'uri'
require 'net/http'

url = URI("https://ethereum-mainnet-geth-archive.node.coinapi.io")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["X-CoinAPI-Key"] = '73034021-THIS-IS-SAMPLE-KEY'
request.body = "{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b\"],\"method\":\"eth_getTransactionByHash\"}"

response = http.request(request)
puts response.read_body

java

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b\"],\"method\":\"eth_getTransactionByHash\"}");
Request request = new Request.Builder()
  .url("https://ethereum-mainnet-geth-archive.node.coinapi.io")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")
  .build();

Response response = client.newCall(request).execute();

Request Parameters

  • 'transaction hash': [Required] A string representing the hash (32 bytes) of a transaction.

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "blockHash": "0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
    "blockNumber": "0x5daf3b",
    "hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
    "from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
    "gas": "0xc350",
    "gasPrice": "0x4a817c800",
    "input": "0x68656c6c6f21",
    "nonce": "0x15",
    "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
    "s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c",
    "to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
    "transactionIndex": "0x41",
    "type": "0x0",
    "v": "0x25",
    "value": "0xf3dbb76162000"
  }
}

A transaction object, or 'null' when no transaction was found. The transaction object will consist of the following keys and their values:

  • 'accessList': [Optional] A list of addresses and storage keys accessed by the transaction. See access list transactions.
  • 'blockHash': 32 bytes. A hash of the block including this transaction. 'null' when it's pending.
  • 'blockNumber': The number of the block including this transaction. 'null' when it's pending.
  • 'chainID': [Optional] Chain ID specifying the network. Returned only for EIP-1559 transactions.
  • 'from': 20 bytes. The address of the sender.
  • 'gas': Gas provided by the sender.
  • 'gasPrice': Gas price provided by the sender in Wei.
  • 'hash': 32 bytes. The hash of the transaction.
  • 'input': The data sent along with the transaction.
  • 'maxPriorityFeePerGas': [Optional] Maximum fee, in Wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions.
  • 'maxFeePerGas': [Optional] Maximum total fee (base fee + priority fee), in Wei, the sender is willing to pay per gas. See EIP-1559 transactions.
  • 'nonce': The number of transactions made by the sender prior to this one.
  • 'r': 32 bytes. The ECDSA signature 'r'.
  • 's': 32 bytes. The ECDSA signature 's'.
  • 'to': 20 bytes. The address of the receiver. 'null' when it's a contract creation transaction.
  • 'transactionIndex': The transaction's index position in the block, in hexadecimal. 'null' when it's pending.
  • 'type': The transaction type.
  • 'v': The ECDSA recovery ID.
  • 'value': The value transferred in Wei.
Service StatusGitHub SDK