What is a smart contract, and how does it work?

What is a smart contract, and how does it work?