A section of lecture prose
In 1994 a cryptographer looked at a vending machine and saw a contract. This paragraph exists so the worksheet cards below sit inside real prose, the way they would in a finished course.
Quick check
Which enforcement mechanism does a vending machine use?
Try it
Make this print the first five square numbers.
One way to do it
console.log([1,2,3,4,5].map(n => n * n).join('\n'));
Same numbers; the map form reads as a single thought.
Write
In a sentence or two: what does the vending machine not know about its buyer, and why will that matter?
Compare
A strong answer notices the machine only sees the coin — not the buyer's age, the coin's provenance, or anything else off-machine. That gap is the oracle problem.
Label it
Match each numbered stage of the coin's path.
Project · part 1 of 6
Over this course you'll build a vending machine in code. Start the project: write a function that accepts a coin value and either dispenses (returning change) or rejects the coin.
Full project: a vending machine state machine built over 6 parts. This part is done well if: price is fixed, exact/over payment dispenses with correct change, underpayment rejects and returns the coin. Common miss: forgetting change.Reading packet · Week 1
- Szabo, N. (1994). Smart Contracts. The original essay.
Seminar question
Does the styling hold together?