- snip -
Sure. Lets grab a random transaction out of the blockchain and take a look at it. I'll pick txID 44d1430102af06489c1a82ae7bb285f684e32a849907b2e11aca67651ac5e292 for this example:
The transaction spends, as an input, the second output (vout=1) of transaction 452d20b51161a8177ce40fa569a26947406d1dae9e40f8472948623d06356ede.
The sum of the values of all the inputs is 26.85898588 BTC.
It sends 3 BTC to 1FeFue5cHarn2B8ntC4wWdfY7eJa3nyUgY
It sends 23.85888588 BTC to 141SFBdbrK9YD4J71LqJw7Fb9vqwYfSmeX
The sum of the values of all the outputs is 26.85888588 BTC.
This leaves 0.0001 BTC unaccounted for in the transaction. All unaccounted for amounts are defined as transaction fees. Therefore, since the transaction used 26.85898588 BTC of value for the inputs and only 26.85888588 BTC for the outputs, the miners take the unaccounted for 0.0001 BTC and pay it to themselves as a transaction fee.
Using createrawtransaction in Bitcoin Core the transaction could have been created as follows:
createrawtransaction [{\"txid\":\"44d1430102af06489c1a82ae7bb285f684e32a849907b2e11aca67651ac5e292\",\"vout\":1}] {\"1FeFue5cHarn2B8ntC4wWdfY7eJa3nyUgY\":3.0, \"141SFBdbrK9YD4J71LqJw7Fb9vqwYfSmeX\": 23.85888588}