Bitcoin Raw Transaction Made Easy

Raw Transaction on Bitcoin-core lets you create and broadcast transaction through its Application Programming Interface  and Command Line Interface (or on a shell for nix users).   In this short post… we will be using few bitcoin-core commands such as, listunpentcreaterawtransaction,  signrawtransaction and signrawtransaction.  But before we start, make sure your blockchain is fully synced and you have enough bitcoin to play with.

In this example, we will send all spendable amount of bitcoins to wallet address 1ZXsXWvnGHey8Dv7dCYtfBAaeipP2QEBY with 0.00001 of bitcoin reward to miners for processing our transaction.

Step 1:  Pick which set of Bitcoins you want to send.  Use listunpsent command to get the transaction ID and vout index number.

Take note of the Transaction ID on RED  and Output Index on GREEN.  And also the 0.001 Bitcoins

Step 2: Create raw transaction using createrawtransaction command in this format:

createrawtransaction '<source of bitcoins>' '<to wallet address and amount>'

createrawtransaction '[{"txid":"a510483803920726be537a241d9014221ae78ce5e888e23f88c37a0343f4be8b","vout":1}]' '{"1ZXsXWvnGHey8Dv7dCYtfBAaeipP2QEBY":0.00099}'

Use the Transaction ID on RED and Output Index number on GREEN for the source of bitcoins, sending to wallet address and amount highlighted on LIGHT BLUE.


My spendable amount from previous transactions is  0.001 BTC and I’m sending 0.00099 to wallet address “1ZXsXWvnGHey8Dv7dCYtfBAaeipP2QEBY“.  The rest of bitcoins (0.00001) will be the “transaction fee” or the miners reward for processing our transaction.

BUT! WHAT IF your spendable amount is 1 .0 BTC and you’re just sending 0.5 BTC?   All remaining 0.5 BTC will be considered as “transaction fee”… so say goodbye 0.5 BTC!!!   If you don’t like this to happen…. you have to specify your “change”  wallet address.

createrawtransaction ‘[{“txid”:”<past transaction ID>“,”vout”:<output index number>}]’ ‘{“<recipient wallet address>“:0.5, “<your change wallet address>“:0.4999}’

Now, it will sent back 0.4999 BTC to your change wallet address and the remaining bitcoins (0.0001 ) will be the “transaction fee”.

Once you run createrawtransaction with no errors, it will return a hex encoded transaction string that we will use in Step 3.

createrawtransaction unsigned hex string

Step 3:  Sign the transaction.  Sign the transaction using the hex encoded string from Step 2 to create the signed hex encoded transaction string.

Sign the transaction

In this stage,  sending 0.00099 to “1ZXsXWvnGHey8Dv7dCYtfBAaeipP2QEBY” wallet address  transaction is now signed but we have to let anyone  know using sendrawtransaction command for Step 4

Step 4:   Broadcast the transaction using sendrawtransaction command. It will return a Transaction ID that can be tracked using website like this

Send Raw Transaction to Bitcoin Network
Send Raw Transaction to Bitcoin Network

That’s all it!   We sent a bitcoin raw transaction in four easy steps.  With this, it gives us a low-level access for creating and broadcasting bitcoin transaction.  It allows us pick which bitcoin to spent, create multiple recipient or specify change wallet address, adjust miners fee each transactions  and defer or push a transaction to the network.

Also checkout the following links:

If you find this useful, send a tip: 1ZXsXWvnGHey8Dv7dCYtfBAaeipP2QEBY