Every transaction you broadcast first sits unconfirmed in the mempool — the swarm of small spheres floating in front of the chain, each hovering at a height proportional to the fee ("gas price") it offers. A block has a limited gas budget; a rational miner fills it greedily with the highest-paying transactions first:
sort mempool by gasPrice, descending
gasUsed = 0
for tx in sorted mempool:
if gasUsed + tx.gasCost <= blockGasLimit:
include tx; gasUsed += tx.gasCost
This is a simplified version of real transaction-selection markets (Ethereum's EIP-1559 fee auction, Bitcoin's fee-rate ordering) — real proposers solve a fuller knapsack over fee *and* dependency ordering, but "highest bidder first, budget permitting" is the core idea.
Each mined block commits to the previous block's hash, so the chain is tamper-evident:
hash(block_i) = H( hash(block_i-1) || tx_ids_i || i )
(The hash shown under each block here is a small illustrative mixing function, not real SHA-256 — see the dedicated SHA-256 lab for that algorithm.) Changing any past transaction would change its block's hash, which breaks every hash that follows — this is what makes a mined block practically final.
Smart contract lifecycle: a Deploy Contract transaction only creates persistent on-chain state once it is actually mined into a block — clicking the button just broadcasts it. Once deployed, Call increment() transactions can be broadcast and, once mined, each increments the contract's on-chain counter by one. State changes are never final until their transaction lands inside a mined block: that's why the counter only updates after you mine, not the instant you click Call.