Tatum
Search…
API Reference
How to send a Bitcoin transaction
Tatum gives you two options how to send a Bitcoin transaction:
  • You can enter a list of blockchain addresses from which the assets will be sent.
  • You can enter specific Unspent Transaction Outputs (UTXO) which will be used to send the assets.

Ensure that you fully understand how Bitcoin transactions work.
The Bitcoin blockchain is not account-based but transaction-based. You operate with a list of previously received transactions and the assets within them. This means that you can use multiple transactions in one transaction as a source of your assets, not just one specific address. To learn more, see this Investopedia article.
  • When you enter a list of addresses, all incoming transactions, that have not been used previously, are used as a source.
  • When you enter a list of UTXOs, only specific unspent transactions that belong to you are used.
Bitcoin transaction inputs
Be aware that all of the assets that belong to the specific transaction are used as input, not only a fraction of them. To learn more about Bitcoin transactions, check out this article.
Before you start:
  • You have to know how much bitcoin you want to send and to whom.
  • You must define a list of recipient addresses with the specific amounts that each address is to receive.
  • The sum of the assets that you send must be bigger than the sum of assets that are expected to be received. The difference will be the transaction fee that must be paid to the network. In other words, you must send more funds than expected to cover the transaction fees.
Example
You want send 9 BTC to 3 recipients, each of which should receive 3 BTC. To cover the fees, you must send (3*3)+1=10 BTC. The fee will be 1 BTC.
This works similar to international wire transfers where you have to pay fees to the banks that handle your transaction.
Private keys and security
In this guide, you are using Tatum API to signing transactions with a private key which is fine for testing and demo purposes.
In production, your private keys and mnemonics should never leave your security perimeter. To sign a transaction correctly and securely, use Tatum JS, the local middleware API, or Tatum KMS.
An EU key does not work in the US and vice versa:
  • If you have a US API key, you need to use the US URL api-us-west1.tatum.io.
  • If you have an EU API key, you need to use the EU URL api-eu1.tatum.io.

Use the following this API endpoint so send Bitcoin.
Request
JavaScript
cURL - List of addresses as a source
cURL - List of UTXOs as a source
import {sendBitcoinTransaction} from '@tatumio/tatum';
/**
* @param testnet - mainnet or testnet version
* @param body - content of the transaction to send
* @returns transaction Id
*/
const body = {
// If source = Wallet address
fromAddress: [{
address: "mhuKgqf7SLRWPX8Sfrqn68i5YcdWsFMRXF",
privateKey: "cNkXKkQ4YoNS2LmnvhtGqWBQKg7oo3BRaowPhSDPvTRjxXyGG6yr"
}],
// If source = UTXO
fromUTXO: [
{
txHash: "887dd5221800c65ada2a2081e65a14b5421b30600d4ab112421a44b17ded6ed4",
index: 0,
privateKey: "cNkXKkQ4YoNS2LmnvhtGqWBQKg7oo3BRaowPhSDPvTRjxXyGG6yr"
}
// Always fill recipient address and amount to send
],
to: [{
address: "n1XD955iuticPuKoJJr8XfAjDw2gYadNrR",
value: 0.15991455
},{
address: "mhuKgqf7SLRWPX8Sfrqn68i5YcdWsFMRXF",
value: 0.4
}]}
const transactionHash = await sendBitcoinTransaction(false, body);
curl --location --request POST 'https://api-eu1.tatum.io/v3/bitcoin/transaction' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"fromAddress": [
{
"address": "mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm",
"privateKey": "cNUHqqs67WVhMZP9hH3i9nLQ1BGEasA87y6N6SQMsfYaBaPi9SEs"
}
],
"to": [
{
"address": "mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm",
"value": 0.000006
},
{
"address": "mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm",
"value": 0.000009
}
]
}'
curl --location --request POST 'https://api-eu1.tatum.io/v3/bitcoin/transaction' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"fromUTXO": [
{
"txHash": "b2dc763cf75373ad14c984c07846f5425c20ddf34606debb0a148cd770528ef9",
"index": 0,
"privateKey": "cNUHqqs67WVhMZP9hH3i9nLQ1BGEasA87y6N6SQMsfYaBaPi9SEs"
},
{
"txHash": "b2dc763cf75373ad14c984c07846f5425c20ddf34606debb0a148cd770528ef9",
"index": 1,
"privateKey": "cNUHqqs67WVhMZP9hH3i9nLQ1BGEasA87y6N6SQMsfYaBaPi9SEs"
}
],
"to": [
{
"address": "mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm",
"value": 0.0000006
},
{
"address": "mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm",
"value": 0.000006
}
]
}'
When using Tatum KMS to securely sign transactions, you will use a signatureId instead of a privateKey parameter in the body of the API request.
The response contains a transaction ID, from which you can get information about the transaction.
Response
{
"txId": "962e4ad3781e7036ff3af6d880744fd3f06131c32d1085254da3cfa77b0e933f"
}

To get information about the transaction, you can use the transaction ID from the response of the previous request with the Bitcoin/Get transaction endpoint.
JavaScript
cURL
import {btcGetTransaction} from '@tatumio/tatum';
/**
* @param hash - transaction hash
* @returns - transaction detail
*/
const transaction = await abtcGetTransaction('962e4ad3781e7036ff3af6d880744fd3f06131c32d1085254da3cfa77b0e933f');
curl --location --request GET 'https://api-eu1.tatum.io/v3/bitcoin/transaction/962e4ad3781e7036ff3af6d880744fd3f06131c32d1085254da3cfa77b0e933f' \
--header 'x-api-key: YOUR_API_KEY'
The response contains the details of the transaction you have performed.
Response
{
"txid": "962e4ad3781e7036ff3af6d880744fd3f06131c32d1085254da3cfa77b0e933f",
"hash": "962e4ad3781e7036ff3af6d880744fd3f06131c32d1085254da3cfa77b0e933f",
"size": 374,
"vsize": 374,
"version": 2,
"locktime": 0,
"vin": [
{
"txid": "b2dc763cf75373ad14c984c07846f5425c20ddf34606debb0a148cd770528ef9",
"scriptSig": {
"asm": "3045022100e3ae860d446af1199e2799361abf8cc4cae3648a029fed3ad926fb3206ae13770220797889b261ec643c0c1dca38855bd58b6b367a9a98cda43fa220d15a919cc89201 0313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238a",
"hex": "483045022100e3ae860d446af1199e2799361abf8cc4cae3648a029fed3ad926fb3206ae13770220797889b261ec643c0c1dca38855bd58b6b367a9a98cda43fa220d15a919cc89201210313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238a"
},
"sequence": 4294967295,
"vout": 0
},
{
"txid": "b2dc763cf75373ad14c984c07846f5425c20ddf34606debb0a148cd770528ef9",
"scriptSig": {
"asm": "304502210081baa63650e42672c8dde6d5b3b414e037102620b9154168c49abd4a90cc491c02204e5808826457bff853aa68c2f9ddaebf46baa3b77dfaee5c467b66eaa773690e01 0313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238a",
"hex": "48304502210081baa63650e42672c8dde6d5b3b414e037102620b9154168c49abd4a90cc491c02204e5808826457bff853aa68c2f9ddaebf46baa3b77dfaee5c467b66eaa773690e01210313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238a"
},
"sequence": 4294967295,
"vout": 1
}
],
"vout": [
{
"value": 6e-7,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 0a21a1144fd4f6892c111c00141932608d17d3a9 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9140a21a1144fd4f6892c111c00141932608d17d3a988ac",
"type": "PUBKEYHASH",
"reqSigs": 1,
"addresses": [
"mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm"
]
}
},
{
"value": 0.000006,
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 0a21a1144fd4f6892c111c00141932608d17d3a9 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9140a21a1144fd4f6892c111c00141932608d17d3a988ac",
"type": "PUBKEYHASH",
"reqSigs": 1,
"addresses": [
"mgSXLa5sJHvBpYTKZ62aW9z2YWQNTJ59Zm"
]
}
}
],
"blockhash": null,
"confirmations": 0,
"time": 1605903228,
"blocktime": 0,
"hex": "0200000002f98e5270d78c140abbde0646f3dd205c42f54678c084c914ad7353f73c76dcb2000000006b483045022100e3ae860d446af1199e2799361abf8cc4cae3648a029fed3ad926fb3206ae13770220797889b261ec643c0c1dca38855bd58b6b367a9a98cda43fa220d15a919cc89201210313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238afffffffff98e5270d78c140abbde0646f3dd205c42f54678c084c914ad7353f73c76dcb2010000006b48304502210081baa63650e42672c8dde6d5b3b414e037102620b9154168c49abd4a90cc491c02204e5808826457bff853aa68c2f9ddaebf46baa3b77dfaee5c467b66eaa773690e01210313f828eb023cde7a5924add3f2bd9c3e228b4e49ec6f550e8e1c5439572c238affffffff023c000000000000001976a9140a21a1144fd4f6892c111c00141932608d17d3a988ac58020000000000001976a9140a21a1144fd4f6892c111c00141932608d17d3a988ac00000000"
}
To find out more about the endpoints you used today, read our API Reference.
Copy link
On this page
Prerequisites
Send a Bitcoin transaction
Get transaction details