BLOCKCHAIN & WEB3 FUNDAMENTALS - Chapter 5, Exercise 1 Solution ========================================================== Building a UTXO Transaction: Paying 0.75 BTC From a 2.0 BTC UTXO PROBLEM ------- Alice owns a single UTXO worth 2.0 BTC. She wants to pay Bob exactly 0.75 BTC. Describe, using this chapter's own UTXO mechanics, what the resulting transaction's inputs and outputs would actually look like, including what happens to the rest of the 2.0 BTC. SOLUTION -------- Because a UTXO must be spent as a whole - there's no way to spend "part of" it directly - Alice's transaction has to consume her entire 2.0 BTC UTXO as its one input, then create new outputs that split that value up correctly. INPUT: - Alice's existing UTXO, worth 2.0 BTC (the whole thing, consumed and removed from the UTXO set) OUTPUTS: - Output 1: 0.75 BTC, locked to Bob's public key - this is the actual payment - Output 2 ("change"): the remainder, locked back to Alice's own public key, minus whatever small transaction fee she includes for the miner If Alice includes, say, a 0.001 BTC transaction fee, the math works out as: 2.0 BTC (input) - 0.75 BTC (to Bob) - 0.001 BTC (fee, left over for the miner, not a separate output) = 1.249 BTC (change, back to Alice as a brand-new UTXO) After this transaction is confirmed, Alice's original 2.0 BTC UTXO no longer exists - it's been consumed. In its place, two brand-new UTXOs now exist: one worth 0.75 BTC that only Bob's private key can spend, and one worth 1.249 BTC that only Alice's private key can spend (the change). The 0.001 BTC fee isn't a UTXO at all - it's simply the gap between the input total and the output total, which goes to whichever miner includes this transaction in a block. ANSWER: The transaction has one input (the full 2.0 BTC UTXO) and two outputs - 0.75 BTC to Bob, and a change output of 1.249 BTC (assuming a 0.001 BTC fee) back to Alice as a fresh UTXO she now owns. ---- WHY THIS WORKS AS AN ANSWER This applies the chapter's own "spend the whole UTXO, get change back" mechanics to a concrete numeric example, correctly identifying that the transaction fee isn't a separate labeled output but simply whatever is left unaccounted for between inputs and outputs.