Let’s step through a typical bitcoin transaction to see how things work.
Jane wants to buy a cup of coffee at Bert’s Coffee using bitcoin. The transaction will look like this:
A cup of coffee is $2.95 and the price of bitcoin is $650.
$2.95/$650 is 0.00453846 bitcoin.
But we can express fractions of a bitcoin in a different and better way. A satoshi is 1/100,000,000 of a bitcoin so 0.00453846 would be 453,846 satoshi.
To encourage miners to include this sale in the next block (takes about 10 minutes to settle), you will need to spend ~7 cents or 10,615 satoshis. This is called the transaction fee.
The transaction fee isn’t actually part of the transaction. It is found by subtracting the price of the coffee (or the output) from the total paid(or the input). The transaction will look like this:
Total paid = coffee fee + transaction fee = 453,846 + 10,615 = 464,461 satoshi
So the transaction will look like this
INPUT -> OUTPUT
464,461 satoshi from Jane -> 453,846 satoshi to Bert’s Coffee
Which is pretty straightforward. In fact, this is too simple. In reality, Jane probably doesn’t have exactly 464,461 satoshi so she’ll need some change. This is similar to having a $5 bill and buying a $2.95 coffee and getting the change back (except for the transaction fee).
Granted, cash doesn’t have a transaction fee, but then let’s look at this as being similar to a credit card transaction fee.
Let’s assume Jane has a number of partial bitcoins such as shown below. I’m truncating the hashes for space reasons. In reality these are
- 1/4 bitcoin = 25,000,000 satoshi (Hash = 6a45764f)
- 1/8 bitcoin = 12,500,000 satoshi (Hash = 23d5fd56)
- 1/100 bitcoin = 1,000,000 satoshi (Hash = 43ed2dac)
Jane’s wallet will probably select the 1/100 bitcoin to spend.
so the transaction will look like this:
INPUT -> OUTPUT
1,000,000 satoshi (43ed2dac) -> 453,846 satoshi to Bert’s Coffee(2bc4545b)
535,539 satoshi change to Jane(3ce69d26)
Note that in this case the transaction fee is staying the same.
Jane’s original amount = Jane’s change + Bert’s coffee + transaction fee
1,000,000 = 453,846 + 545,539 + 10,615
When all is finished, the wallets will look like this:
Jane:
- 1/4 bitcoin = 25,000,000 satoshi (Hash = 6a45764f)
- 1/8 bitcoin = 12,500,000 satoshi (Hash = 23d5fd56)
- 535,539 satoshi (Hash = 3ce69d26)
And Joe’s Coffee:
- other sales & other hashes
- 453,846 satoshi (2bc4545b)