UTXO - Get Confirmations from a Transaction
When dealing with UTXO (Unspent Transaction Output) based cryptocurrencies like Bitcoin, it's recommended to track the number of confirmations after receiving a transaction notification to ensure its finality and security.
Confirmations give confidence that a transaction has been included in the blockchain and is resistant to reversals or invalidations.
What are Confirmations?
A "confirmation" in the context of Bitcoin and similar cryptocurrencies refers to how many blocks have been added to the blockchain after the block containing your transaction. The more confirmations a transaction has, the more secure and final it becomes, as it becomes increasingly difficult for the transaction to be reversed or invalidated.
Here’s a simplified way to think about it:
- 0 confirmations: The transaction has been broadcast to the network but has not yet been included in a block. It remains in the "mempool" (pending state).
- 1 confirmation: The transaction has been included in a block. It is now part of the blockchain but is still vulnerable to rare reorganization events.
- 2+ confirmations: Additional blocks have been added after the block containing your transaction, further securing it. With each additional confirmation, the chances of reversal decrease dramatically.
Why Are Confirmations Important?
The number of confirmations directly impacts a transaction's security and finality. The more confirmations, the harder it is to alter the transaction’s status.
For high-value or critical transactions, it's recommended to wait for 6 confirmations before considering the transaction finalized. This number is derived from Bitcoin’s original design, as it provides a robust balance between security and practicality. Each block added further decreases the risk of transaction reversal through blockchain reorganization attacks.
For low-value transactions, 1 or 2 confirmations may be sufficient, but for larger transactions or significant payments, waiting for 6 or more confirmations is the norm.
How to Check the Number of Confirmations for a Bitcoin Transaction with Tatum
Step_1: Find Your Transaction ID (TXID)
To check the status of your transaction, you first need to find its unique identifier, called the Transaction ID (TXID). The TXID is a long string of letters and numbers that uniquely identifies your transaction on the blockchain.
You can obtain the TXID from:
- A Notification
- The wallet you used to send or receive the Bitcoin.
- The exchange or service that facilitated the transaction.
- The sender of the funds, if you are the recipient.
- Other
Step_2: Get the Transaction details
With your TXID in hand, use Tatum’s REST API to get the transaction details. The blockNumber
associated with your transaction will indicate the block that contains your transaction.
Example request:
curl --location 'https://api.tatum.io/v3/bitcoin/transaction/4241e9a94c15639e1f28527ab1cd9497c4dc09889ea70c85e07ad9211ca101bc' \
--header 'x-api-key: {YOUR_API_KEY}'
//Response:
{
"blockNumber": 860501, //The block
"fee": 0,
"hash": "4241e9a94c15639e1f28527ab1cd9497c4dc09889ea70c85e07ad9211ca101bc",
"hex": "010000000001010000000000000000000000000000000000000000000000000000000000000000fff...
// other details
}
Step_3: Get the hash from a blockNumber
To query further information about the block containing your transaction, you need to get the block hash using the block number retrieved in the previous step.
Example request:
curl --location 'https://api.tatum.io/v3/bitcoin/block/hash/860501' \
--header 'x-api-key: {YOUR_API_KEY}'
//Response:
{
"hash": "00000000000000000000e156226064aa77a91871224b4cbbac7ce5cdc956b78d"
}
Step_4: Get the block details from its hash
Once you have the block hash, use it to retrieve detailed block information, including the number of confirmations for your transaction.
Example request:
curl --location 'https://bitcoin-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key:{YOUR_API_KEY}' \
--data '{
"jsonrpc": "1.0",
"id":"curltest",
"method": "getblock",
"params": ["00000000000000000000e156226064aa77a91871224b4cbbac7ce5cdc956b78d"]
}'
//Response:
{
"result": {
"hash": "00000000000000000000e156226064aa77a91871224b4cbbac7ce5cdc956b78d",
"confirmations": 2315,//This is the value you are looking for.
"height": 860501,
"version": 668934144,
"versionHex": "27df2000",
// other details
}
Updated 19 days ago