History

Smart contracts were first theorized by Nick Szabo in the late 1990s in an article named Formalizing and Securing Relationships on Public Networks, but it was almost 20 years before the real potential and benefits of them were indeed appreciated with the invention of Bitcoin and subsequent development in blockchain technology. Smart contracts are described by Szabo as follows:

"A smart contract is an electronic transaction protocol that executes the terms of a contract. The general objectives are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries. Related economic goals include lowering fraud loss, arbitrations and enforcement costs, and other transaction costs."
The original article written by Szabo is available at  http://firstmonday.org/ojs/index.php/fm/article/view/548.

This idea of smart contracts was implemented in a limited fashion in Bitcoin in 2009, where Bitcoin transactions using a limited scripting language can be used to transfer value between users, over a peer-to-peer network where users do not necessarily trust each other, and there is no need for a trusted intermediary.