3 min de lectura
Ethereum: How can I determine the number of confirmations of a transaction and its fee using the Blockchain.info DATA API?
CRYPTOCURRENCY
Understanding Ethereum Transaction Confirmations Using the Blockchain.info Data API
As an Ethereum developer, it is extremely important to have a clear understanding of how transactions are processed in the blockchain. In this article, we will consider how to determine the number of transaction confirmations and its commission using the Blockchain.info data API.
What are transaction confirmations?
Transaction confirmations are a measure of how many times a block has been mined and verified by the network before being added to the blockchain. This confirms that the sender of the transaction (also known as the «sender») has indeed received payment from the recipient («the recipient»).
How to determine transaction confirmations using the Blockchain.info data API
The Blockchain.info data API provides a way to query the Ethereum blockchain and extract information about individual transactions, including their confirmations. Here’s how you can use it:
Step 1: Set up your Blockchain.info account
Create an account on Blockchain.info ( and confirm your email address.
Step 2: Get your API key
After logging in, go to the «My Account» section. Click «API Keys» and create a new API key for your application.
Step 3: Use the DATA API to request transactions
You can use the following endpoint to retrieve transaction information using the DATA API:
Replace {txHash}
with the actual hash of the transaction you want to query. The `DATA'' method is used to retrieve data, and the
TX'' parameter indicates that we are interested in transaction information.
Example of use:
curl -X GET \
Replace with your actual transaction hash.
How to determine transaction confirmations using the DATA API
The returned JSON data will contain various fields, includingconfirmations, which represent the number of confirmations for this block. To get the number of confirmations for a specific block, you can use the following query:
curl -X GET \
Replace with your actual transaction hash.
How to find out if a transaction has been confirmed and if a miner has been paid a fee using API DATA
To check if a miner has been paid a fee for a particular transaction, you can use thefeeparameter in the request. The
feefield contains information about the transaction fee, which is the amount of Ether that was paid to the miner for the creation of this block.
Example of use:
curl -X GET \
Replace with the actual transaction hash. The returned JSON data will contain a
feefield, which is the amount of Ether that was paid to the miner to create this block.
Example of use: checking confirmations of transactions and commissions using API DATA
Suppose you are creating an application that needs to track transactions on the Ethereum network. You can use the DATA API to request information about transactions and determine whether a particular transaction has been confirmed and whether a miner's fee has been paid.
«python
import requests
api_key = «YOUR_API_KEY»
tx_hash = «
headers = {
«Authorization»: f»Carrier {api_key}»,
«Content-Type»: «application/json»
}
response = requests.get(f» headers=headers)
if response.status_code == 200:
data = response.json()
confirmeds = data[«confirmations»]
fee_amount = data[«fee»][«amount»]
print(f»Transaction {tx_hash} confirmed {confirmations} times and paid ${fee_amount:.2f} to miners.