EthereumMethods

eth_getTransactionReceipt

The eth_getTransactionReceipt method returns the receipt of a transaction given its transaction hash. Please note that the receipt is not available for pending transactions.

eth_getTransactionReceipt

Overview

The 'eth_getTransactionReceipt' method returns the receipt of a transaction given its transaction hash. Please note that the receipt is not available for pending transactions.

Request

shell

curl --request POST \
     --url https://coinapi.io/v1/ethereum \
     --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": [
    "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae"
  ],
  "method": "eth_getTransactionReceipt"
}'

csharp

using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://coinapi.io/v1/ethereum"),
    Headers =
    {
        { "accept", "application/json" },
    },
    Content = new StringContent("{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\"],\"method\":\"eth_getTransactionReceipt\"}")
    {
        Headers = ("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY");
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}

php

<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://coinapi.io/v1/ethereum",
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' => [
'0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae'
],
'method' => 'eth_getTransactionReceipt'
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"content-type: application/json"
],
]);

$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://coinapi.io/v1/ethereum"

payload = {
    "id": 1,
    "jsonrpc": "2.0",
    "params": ["0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae"],
    "method": "eth_getTransactionReceipt"
}
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: ['0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae'],
    method: 'eth_getTransactionReceipt'
  })
};

fetch('https://coinapi.io/v1/ethereum', 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://coinapi.io/v1/ethereum"

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

	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://coinapi.io/v1/ethereum")

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\":[\"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\"],\"method\":\"eth_getTransactionReceipt\"}"

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

java

AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "https://coinapi.io/v1/ethereum")
  .setHeader("accept", "application/json")
  .setHeader("content-type", "application/json")
  .setHeader("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEYs")
  .setBody("{\"id\":1,\"jsonrpc\":\"2.0\",\"params\":[\"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\"],\"method\":\"eth_getTransactionReceipt\"}")
  .execute()
  .toCompletableFuture()
  .thenAccept(System.out::println)
  .join();

client.close();

Request Parameters

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

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "transactionHash": "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae",
    "blockHash": "0x58a945e1558810523df00490ff28cbe111b37851c44679ce5be1eeaebb4b4907",
    "blockNumber": "0xeb8822",
    "logs": [
      {
        "transactionHash": "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae",
        "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "blockHash": "0x58a945e1558810523df00490ff28cbe111b37851c44679ce5be1eeaebb4b4907",
        "blockNumber": "0xeb8822",
        "data": "0x000000000000000000000000000000000000000000000000000000001debea42",
        "logIndex": "0x6c",
        "removed": false,
        "topics": [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          "0x0000000000000000000000005067c042e35881843f2b31dfc2db1f4f272ef48c",
          "0x0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585"
        ],
        "transactionIndex": "0x4e"
      },
      {
        "transactionHash": "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae",
        "address": "0x98f3c9e6e3face36baad05fe09d375ef1464288b",
        "blockHash": "0x58a945e1558810523df00490ff28cbe111b37851c44679ce5be1eeaebb4b4907",
        "blockNumber": "0xeb8822",
        "data": "0x000000000000000000000000000000000000000000000000000000000001371e000000000000000000000000000000000000000000000000000000006eca00000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000008501000000000000000000000000000000000000000000000000000000001debea42000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000267c46aa713cfe47608dd1c16f8a0325208df084c3cbebf9f366ad0eafc2653e4000100000000000000000000000000000000000000000000000000000000001e8542000000000000000000000000000000000000000000000000000000",
        "logIndex": "0x6d",
        "removed": false,
        "topics": [
          "0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2",
          "0x0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585"
        ],
        "transactionIndex": "0x4e"
      }
    ],
    "contractAddress": null,
    "effectiveGasPrice": "0x2d7003407",
    "cumulativeGasUsed": "0x76c649",
    "from": "0x5067c042e35881843f2b31dfc2db1f4f272ef48c",
    "gasUsed": "0x1a14b",
    "logsBloom": "0x00000000000100000000008000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000000008008008000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000010000000000000000000000000000000000000000000000000010002000000000000000400000000000400200001000000000000000000000000040000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000",
    "status": "0x1",
    "to": "0x3ee18b2214aff97000d974cf647e7c347e8fa585",
    "transactionIndex": "0x4e",
    "type": "0x0"
  }
}

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

  • 'blockHash': 32 bytes. Hash of the block including this transaction.
  • 'blockNumber': Block number including this transaction.
  • 'contractAddress': 20 bytes. The contract address created if the transaction was a contract creation, otherwise null.
  • 'cumulativeGasUsed': The total amount of gas used when this transaction was executed in the block.
  • 'effectiveGasPrice': The actual value per gas deducted from the sender's account. Before EIP-1559, equal to the gas price.
  • 'from': 20 bytes. The address of the sender.
  • 'gasUsed': The amount of gas used by this specific transaction alone.
  • 'logs': (Array) An array of log objects generated by this transaction.
  • 'logsBloom': 256 bytes. Bloom filter for light clients to quickly retrieve related logs.
  • One of the following:
    • 'root': 32 bytes of post-transaction stateroot (pre-Byzantium)
    • 'status': Either 1 (success) or 0 (failure)
  • 'to': 20 bytes. The address of the receiver. null when the transaction is a contract creation transaction.
  • 'transactionHash': 32 bytes. The hash of the transaction.
  • 'transactionIndex': Hexadecimal of the transaction's index position in the block.
  • 'type': The transaction type.
Service StatusGitHub SDK