The one-line mental model
A cryptocurrency transaction does not move a balance from one place to another; it consumes previous outputs as inputs and mints brand-new outputs, and every full node re-checks that the spender proved ownership with a valid digital signature.
Prerequisites
- !Public-key cryptography: private keys derive public keys which derive addresses
- !Basic comfort reading JSON payloads
What You'll Learn
- 1Trace a Bitcoin payment end to end through inputs, outputs, and change
- 2Explain why a private key never touches the network during a signature
- 3Derive addresses from a mnemonic and describe how one seed covers thousands of accounts
- 4Compare fee behavior on Bitcoin with gas accounting on Ethereum
Two ledgers, two ways to count money
Bitcoin and Ethereum both track ownership with cryptography, but they disagree about what "balance" even means.
Bitcoin uses the UTXO model. The chain never stores account balances at all; it stores a growing set of unspent transaction outputs, each carrying a value and a locking script that says who may spend it. Your wallet balance is the sum of outputs your keys can satisfy â an amount it computes locally, not a number anyone else stores. Spending an output consumes it entirely, so paying 0.2 BTC out of a 1 BTC output creates a 0.2 BTC output for the recipient and a 0.8 BTC output back to yourself, called change.
Ethereum uses the account model. Every address has a nonce and a balance in global state, a transaction simply debits one account and credits another, and the nonce increments to prevent replay.
| Property | Bitcoin (UTXO) | Ethereum (account) |
|---|---|---|
| Balance storage | Derived from unspent outputs | Stored per address in state |
| Privacy | Fresh change addresses hide linkage | Reused address is trivially linkable |
| Parallelism | Independent outputs can be spent concurrently | Nonce serializes every account's transactions |
| Replay protection | Each output spent once | Nonce increments per account |
| Typical fee unit | satoshis per virtual byte | gwei per unit of gas |
Anatomy of a real transaction
When you broadcast a payment, nodes receive a small object that references earlier outputs and declares where the value goes next. The structure below is simplified but faithful to the fields that consensus actually validates:
{
"txid": "9a3f5c1e7b2d4a6f8c0e1d3b5a7f9c2e4d6b8a0f1c3e5d7b9a1f3c5e7d9b0a2c",
"version": 2,
"vin": [
{
"txid": "41eb3f0d9c8a7b6e5f4d3c2b1a0987654321fedcba9876543210abcdef123456",
"vout": 1,
"scriptSig": "3045022100c1...02207a...01",
"sequence": 4294967295
}
],
"vout": [
{ "value": 12000000, "scriptPubKey": "0014a1b2c3d4e5f6...9876" },
{ "value": 35000000, "scriptPubKey": "0014f6e5d4c3b2a1...4321" }
],
"locktime": 0
}
Values are expressed in satoshis, never decimal BTC, so no floating-point rounding can quietly inflate a payment. The first output pays the recipient; the second returns the remainder to a change address controlled by the sender. A single transaction may consume many inputs from different earlier transactions, which is why a wallet that receives lots of tiny payments can end up with a large, expensive-to-spend transaction.
Proving ownership without revealing the key
The scriptSig (or, on modern outputs, a signature and public key) proves the spender controls the coin. Bitcoin uses ECDSA over the secp256k1 curve, and the signature is computed over a hash of the transaction with the input scripts of other coins blanked out, so one signature cannot be replayed against a different payment.
import hashlib
from ecdsa import SigningKey, SECP256k1
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
def b58(payload: bytes) -> str:
n = int.from_bytes(payload, "big")
out = ""
while n:
n, rem = divmod(n, 58)
out = ALPHABET[rem] + out
return "1" * (len(payload) - len(payload.lstrip(b"\x00"))) + out
def address_from_private(hex_key: str) -> str:
sk = SigningKey.from_string(bytes.fromhex(hex_key), curve=SECP256k1)
pub = sk.get_verifying_key().to_string() # 64-byte uncompressed key
sha = hashlib.sha256(pub).digest() # hash160 step one
ripe = hashlib.new("ripemd160", sha).digest() # hash160 step two
payload = b"\x00" + ripe
checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:4]
return b58(payload + checksum) # legacy base58 address
def sign_payment(sk: SigningKey, tx_digest: bytes) -> bytes:
return sk.sign_digest(tx_digest, sigencode=lambda r, s, order: r.to_bytes(32, "big") + s.to_bytes(32, "big"))
key = SigningKey.generate(curve=SECP256k1)
digest = hashlib.sha256(b"spend output 1 to merchant").digest()
print(sign_payment(key, digest).hex()[:64] + "...")
The signature is verifiable by anyone holding the public key, which appears alongside it. Nodes verify in microseconds, and the private key itself is never transmitted â it stays inside the wallet, hardware device, or signer service that produced the signature.
Seeds, derivation, and why 12 words are enough
Modern wallets do not store thousands of keys; they store one master secret. A mnemonic phrase such as twelve BIP-39 words is converted into a 512-bit seed, which feeds a hierarchical deterministic (HD) tree. Each branch of the tree yields a fresh key pair, so you can rotate addresses for every payment while recovery remains a single backup.
import { HDNodeWallet, Mnemonic, getAddress } from "ethers";
const phrase = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
const mnemonic = Mnemonic.fromPhrase(phrase);
for (let i = 0; i < 3; i++) {
const path = `m/44'/60'/0'/0/${i}`;
const wallet = HDNodeWallet.fromMnemonic(mnemonic, path);
console.log(path, getAddress(wallet.address));
}
// m/44'/60'/0'/0/0 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
// m/44'/60'/0'/0/1 0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0
// m/44'/60'/0'/0/2 0x361552616Bc4901749a34898659D2cE0F1A63989
The coin type in the path (60 for Ethereum, 0 for Bitcoin) keeps networks separate, and the address index lets one backup restore an unbounded sequence of addresses. Anyone who learns the twelve words controls every derived key, which is why the phrase must never be typed into a website or photographed.
Fees: the market for block space
Bitcoin miners assemble a block from the highest-fee-per-byte transactions first, so your fee is a bid for limited space measured in sat/vB. Ethereum instead prices computation: every opcode consumes gas, the block has a gas ceiling, and a base fee is burned with an optional tip on top.
| Fee question | Bitcoin | Ethereum |
|---|---|---|
| What you pay for | Bytes of data | Compute plus data bytes |
| Unit | sat/vB | gwei per gas |
| Typical simple transfer | 100â200 vbytes at market rate | 21,000 gas |
| Fee market | First-price auction, replaced-by-fee allowed | Base fee burned, tip added, EIP-1559 burns excess |
| Predictability | Estimate from mempool byte pressure | Estimate from base fee history per block |
Because a Bitcoin signature check is cheap but block space is scarce, consolidation transactions that pack many small outputs into one can be worth running during fee dips. On Ethereum, optimization means reducing storage writes rather than bytes, since state operations dominate the gas bill.
From broadcast to confirmed
A signed transaction is not instantly final. Your wallet broadcasts it to a handful of peers, who relay it to the rest of the network, and it lands in the mempool â the pool of valid but unmined transactions. Miners and builders then select from that pool, so a transaction with an uncompetitive fee can sit unconfirmed indefinitely, or be replaced by a higher-bidding transaction spending the same input.
Once included in a block, the transaction has one confirmation, and each subsequent block adds another. For small payments one confirmation is usually plenty because reversing it would require reorganizing the chain and forfeiting the block reward. For high-value settlement, waiting six or more blocks is standard practice on Bitcoin. Ethereum compresses this timeline: with checkpoints and finality gadgets, a justified block becomes irreversible in roughly fifteen minutes instead of an hour.
Between broadcast and finality there are three states worth distinguishing in your application code: pending (visible in the mempool), confirmed (in a block but shallow), and finalized (reorganization is economically or protocol-wise impossible). Treating all three as "paid" is the single most common source of accounting bugs in wallet and exchange software.
Supply schedule: halvings and issuance
Bitcoin's issuance halves every 210,000 blocks, roughly four years, cutting the block reward in half and asymptotically approaching a 21 million coin cap. Each halving also removes half of the marginal sell pressure from miners, which is why the event is watched so closely.
| Era | Block reward | Approximate year |
|---|---|---|
| Genesis | 50 BTC | 2009 |
| First halving | 25 BTC | 2012 |
| Second halving | 12.5 BTC | 2016 |
| Third halving | 6.25 BTC | 2020 |
| Fourth halving | 3.125 BTC | 2024 |
Ethereum took the opposite approach after the merge: issuance now depends on how much stake is participating, and base-fee burning can make net supply fall during busy periods.
â ī¸Change addresses are not optional
A wallet that forgets to sweep its change output will show a balance that looks correct but cannot be spent as a whole. Always confirm that your wallet generates a fresh change address per transaction, especially when recovering from seed on a different application.
Common Mistakes
Copying a balance from a block explorer instead of your wallet's derived UTXO set
Fix: Trust your wallet's own scan of the chain; explorers may lag, and watch-only setups often track only the first address
Sending the full balance and leaving no fee headroom
Fix: Estimate fees against a target confirmation time and keep enough value on at least one output to pay for a future spend
Reusing one address for every payment to simplify bookkeeping
Fix: Rotate addresses per counterparty; reuse makes all your counterparties visible to each other on a public ledger
Confusing a public address with a private key or seed
Fix: Only the seed is secret, but treat addresses as phone numbers you are willing to publish â never paste either into unknown sites
Best Practices
- Keep long-term holdings on hardware that signs offline, with the seed generated and stored away from any networked device
- Verify the first and last six characters of an address on the hardware screen before confirming a large transfer
- Track fee estimates before batching payments, and consolidate dust outputs when the mempool is quiet
- Write the mnemonic on metal or paper and store two geographically separate copies; a single digital backup is a single point of failure
Interview Questions
Q1: What problem does the change output solve?
UTXOs are indivisible: spending one consumes it entirely. The change output returns the surplus to the sender so the wallet can spend it later, otherwise the remainder would be lost or implicitly donated as a fee.
Q2: Why does Ethereum need a nonce if Bitcoin does not?
Bitcoin gets replay protection for free because each UTXO can be spent only once. Ethereum accounts can transact repeatedly, so a monotonically increasing nonce ensures an account's transactions execute in order and an old signed transaction cannot be rebroadcast.
Q3: Where does a wallet balance actually live?
Nowhere on chain. A full node derives balances by summing outputs whose locking script the wallet's keys can satisfy (Bitcoin) or by reading the account's state entry (Ethereum). The ledger stores ownership records, not the number shown in your app.
Key Takeaways
- Bitcoin transactions consume UTXOs and create new outputs, so change is a normal and necessary part of any payment
- Signatures prove key control without transmitting the key, and each signature is bound to the specific outputs being spent
- A single BIP-39 seed deterministically derives unlimited addresses, making one backup sufficient for recovery
- Bitcoin fees price block space in sat/vB while Ethereum fees price computation in gas
- Issuance rules are code: halvings and burn mechanics change supply on a schedule no participant can alter