Prerequisites
- A running Bitcoin Core node with bitcoin-cli access. See Setup Bitcoin Node guide in order to run a testnet4 bitcoin node and install bitcoin-cli.
- Maestro API credentials for retrieving transaction fees and broadcasting transactions. See Getting Started guide in order to create a free Maestro Account.
Submit a Bitcoin Transaction
Step 1: Create a new Wallet and Generate a New Bitcoin Address
Step 2: Get tBTC or Test Bitcoin (UTXOs)


abe3318569c84d229dd8aea53ca8e7c9dfe725d2f866ee60a8926cbfba4ddc0cMaestro Bitcoin ExplorerYou can lookup the transaction by visiting explorer.gomaestro.org and entering the transaction id (txid).https://explorer.gomaestro.org/bitcoin/testnet/transactions/abe3318569c84d229dd8aea53ca8e7c9dfe725d2f866ee60a8926cbfba4ddc0c
Step 3: Get Unspent Transaction Outputs (UTXOs)


"txid": "a4b80f03ff283418825ef8b30e4d2668fc8f61295f6dd2f95ac46074f704b1fb"vout (Output Index):
The index of this specific output in the transaction.A Bitcoin transaction can have multiple outputs, and vout specifies which output is being referenced."vout" : 1 means this is the second output (indexes start at 0).Together, txid and vout uniquely identify a UTXO, which can be spent in a future transaction.Each Transaction Creates OutputsEach Bitcoin transaction can create multiple outputs. The vout index refers to the specific output within that transaction."txid": "a4b80f03ff28..."has an output at vout: 1."txid": "0a35bebbd903..."also has an output at vout: 1.
txid corresponds to a different transaction, but both have at least two outputs (one at index 0 and another at index 1).In our case each UTXO Comes from a Different TransactionEven though both UTXOs belong to the same address (mwB5SqzYMFQj1BQxPTTL8W2brMr6ehFEEM), they originate from separate transactions, making their combination of txid and vout unique.in the screenshot below we can witness that "txid": "0a35bebbd903..." has two outputs and one of them, with the vout:1 for that transaction, was an input UTXO to our address.
txid: "0a35bebbd903..." has two outputs. One of them, with index vout:1, became an input UTXO for our address when funds were spent in a new transaction. The remaining change from the transaction was sent back to our address. Refer to the screenshot below.
txid and vout. Since each txid is different, these are two separate UTXOs, even though both have vout: 1.This returns a list of UTXOs available for spending. Identify the UTXO’s txid and vout to use in the next step.Step 4: Create a Second Bitcoin Testnet Address
-

- Let’s create a Raw transaction using bitcoin-cli command
Step 5: Create a Raw Transaction
UTXO_TXID: The transaction ID of the unspent output.UTXO_VOUT: The output index of the UTXO.RECIPIENT_ADDRESS: The address receiving Bitcoin.AMOUNT: The amount (in BTC) to send.CHANGE_ADDRESS: Your change address for receiving remaining funds.CHANGE_AMOUNT: The remaining balance after subtracting the transaction fee.
createrawtransaction- Creates a raw Bitcoin transaction without signing or broadcasting it.- First argument
[\{"txid":"...","vout":1 }]– Specifies the transaction input:- txid is the transaction ID from which the UTXO is being spent.
- vout specifies the output index (1 in this case) from the previous transaction, meaning we are using the second output as an input.
- Second argument
{"mxVhXyQgXYaJ1ZfuWBa7QGUyH97obnYnkA":0.00015206, "mwB5SqzYMFQj1BQxPTTL8W2brMr6ehFEEM":0.00001}– Defines the outputs:- Sends 0.00015206 tBTC to address
mxVhXyQgXYaJ1ZfuWBa7QGUyH97obnYnkA. - Sends 0.00001 tBTC to address
mwB5SqzYMFQj1BQxPTTL8W2brMr6ehFEEM.
- Sends 0.00015206 tBTC to address
-

Step 6: Calculate Transaction Fee Using Maestro
CHANGE_AMOUNT accordingly. See Mempool Block Fee Rates Maestro API Documentation
CHANGE_AMOUNT accordingly. See Mempool Block Fee Rates Maestro API Documentation.
block_height: The height (or index) of the block on the blockchain. In this case, it’s block number 70608.sats_per_vb(Satoshis per virtual byte): This shows the estimated fee rate in (sats/vbyte), which is used for calculating transaction fees.
chain_tip: The latest block in the blockchain that is known by the indexer. It provides the block hash and the block height of the latest confirmed block.block_hash: The hash of the latest block in the chain.block_height: The height of the latest block in the blockchain.mempool_timestamp: The timestamp of when the data related to the mempool was recorded. The mempool holds unconfirmed transactions waiting to be included in a block.estimated_blocks: The predicted next block and its fee structure.
Step 7: Sign the Transaction
(hex) ready for broadcasting.
Step 8: Verify the Signed Transaction
SIGNED_TX_HEX), it will return a JSON response where you can find the key-value pair - "allowed":true indicating whether the transaction would be accepted into the mempool or not.Step 9: Broadcast the Transaction Using Maestro API


Step 10: Monitor the Transaction in the Mempool using Maestro


Step 11: Monitor Transaction onchain using Maestro APIs



