Bitcoin, Litecoin, Doge, ... and other UTXO-based chains have several ways to make transactions.
Examples
Let's say address_x
contains 100BTC and you want to make a tx from address_x
to address_y
of 10BTC.
Considering what's possible, we can make a BTC transfer as follows.
Default transfer type:
curl --location --request POST 'https://api.tatum.io/v3/bitcoin/transaction' \ --header 'x-api-key: ##API_KEY' \ --header 'Content-Type: application/json' \ --data-raw '{ "fromAddress": [ { "address": "address_x", "privateKey": "pk_address_x" } ], "to": [ { "address": "address_x", // rest of coin back to original address, IF that's what you want. "value": 89.87654321 // Here you also consider the amount of "fee" you will allocate for the "miners" }, { "address": "address_y", // where you want to transfer those "complete" 10BTC "value": 10 } ] }' // within the "to" IF you only have x1 address as destination && don't specify where the rest of the coins go, the blockchain considers that amount as the "fee" to be given to the miner.
Using fromUTXO with fee && changeAddress:
curl --location --request POST 'https://api.tatum.io/v3/bitcoin/transaction' \ --header 'x-api-key: ##API_KEY' \ --header 'Content-Type: application/json' \ --data-raw '{ "fromUTXO":[ { "txHash":"######", "index":##, // the index of the "PublicAddress" within that "txHash" "privateKey":"pk_address_x" } ], "to": [ // this is an array, you can have multiple destinations { "address":"address_y", //main destination address "value":10 } ], "changeAddress":"address_x", //where you sent the rest "unspent" coin back "fee":"0.87654321" // this fee is quite high for BTC or LTC, take it as an example. Also, max decimals is 8 }'
Good to know
We strongly encourage all our customers to try this out with their testnet API keys with coins from a faucet.
Find popular faucets available at the following link.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article