Here’s an example of how transactions work in Bitcoin:

Let’s say that Gloria has two UTXOs, from past transactions, one worth one hundred (100) bitcoins and one worth fifty (50) bitcoins.

nashashibimajd© Source

She, being incredibly wealthy and generous, wants to send one hundred and one (101) bitcoins to Rustie.

To start off, she first breaks open the one hundred (100) UTXO and makes that an input for the transaction to Rustie.

nashashibimajd© Source

However, she recognises that she does not yet have enough in the input, so she breaks open her next UTXO worth fifty (50) and makes that a second input for the transaction.

The transaction now currently has two inputs, one worth one hundred (100) and one worth fifty (50), and one output worth one hundred and one (101) to Rustie.

nashashibimajd© Source

The transaction now currently has two inputs, one worth one hundred (100) and one worth fifty (50), and one output worth one hundred and one (101) to Rustie.

nashashibimajd© Source


What about the remaining 49 bitcoins that were originally Gloria’s? Where do those go?

To make sure that Gloria can spend these bitcoins at a later date, she makes a second output to herself known as a change UTXO, or another piggy bank, containing all the remaining unspent bitcoins from the inputs.

nashashibimajd© Source

This way, she can give one hundred and one (101) of her one hundred and fifty (150) bitcoins to Rustie and keep her remaining forty nine (49) even though she does not  have UTXOs which sum up to exactly the amount she wants to spend.

From here, if Rustie is equally generous and wants to give that remaining amount to Derrick [third person], he can just make his  new UTXO an input into a different transaction, the output of which will be Derrick’s new UTXO.

nashashibimajd© Source
This is how Bitcoin effectively keeps track of individual transactions and prevents anyone from spending incorrect amounts of bitcoin.