These are known as Contracts. Any input bitcoins not redeemed in an output is considered a transaction fee ; whoever generates the block can claim it by inserting it into the coinbase transaction of that block. Crypto wallets and light clients usually tracks the utxos of the private keys they own. Then, it adds up the values of the utxos and shows you the final balance. When the transaction is being constructed, we must create an output that is a bit less than the input in order to let the miners know the fees that the transaction carries. The data in "coinbase" can be anything; it isn't used. So in simple terms a transaction output sits in the uxto pool and a transaction points to a transaction output in the uxto and says to the network via mathematical proof I have the right to spend this transaction output. The public key is used to verify the redeemers signature, which is the second component. This is referred to as an output and it consists of one or more previous inputs.
From now on, were going to call the outputs the proper way: Unspent Transactions Outputs or utxos. See also BIP 0016 Generation Generations have a single input, and this input has a " coinbase " parameter instead of a scriptSig. A sends 100 BTC to C and C generates 50 BTC. If you own any bitcoins, you (and the public) will be able to use the blockchain to find all of the transactions ever made to your address. Its also beneficial to stop spammers for sending constant transactions. Another important aspect is that fees arent mandatory, however transactions with zero fees rarely get mined and sometimes will not even be propagated across the network. There can be more than one output, and they share the combined value of the inputs. These incoming transactions are referred to as inputs. How utxos can be spent or how transaction inputs are created?
A Guide to Transaction Outputs in Bitcoin - learn me a bitcoin
Transactions - Calculating total received and balance