This first part of the Smart Contract Security course content covers the what and why of blockchains and smart contracts and the benefits of building on the blockchain, as well as addressing some common criticisms of the space.

What is a blockchain?

A blockchain is a public list of records securely linked together with cryptography. Each block contains a hash of the previous block, a timestamp and transaction data. Blockchains are managed by peer-to-peer networks, in which individual nodes (called validators) construct the next block in the chain by following a consensus algorithm. Consensus algorithms are designed to make it more profitable for individual nodes to behave correctly than attempt to subvert the chain. This solves the double-spend problem and makes decentralized, trustless exchange of value over the internet possible.

The blockchain concept was first popularized when Satoshi Nakamoto released the original Bitcoin whitepaper in 2008. At a basic level, blockchains record simple transactions: payments from one user to another in a native blockchain currency. More sophisticated blockchains allow for more flexible and varied transactions, enabling the creation of smart contracts. The Ethereum blockchain, first released in 2014, provides a virtual machine for running arbitrary code, and was the first blockchain to enable easy creation of Turing-complete smart contracts.

What are smart contracts?

A smart contract is a piece of code that executes events and actions according to a set of rules analogous to a traditional legal contract. Smart contracts are designed to allow parties to engage in contractual transactions without requiring the services of a mediator or even trusting each other. If that's too abstract, think of a vending machine. You put money in, press some buttons, and get a predetermined output (though your snack might get stuck against the glass).

A snack vending machine in Helsinki-Vantaa airport, terminal 1 photographed by Tiia Monto [CC BY-SA 3.0]

A snack vending machine in Helsinki-Vantaa airport, terminal 1 photographed by Tiia Monto [CC BY-SA 3.0]

For our purposes, you can think of a smart contract as a program that runs on the blockchain and moves money around. At present, smart contracts are overwhelmingly used for financial operations. Some example use-cases include:

The majority of smart contract projects provide financial instruments for trading cryptocurrencies, some of which are pegged to fiat currencies or assets such as gold. This can make the space seem insular. However, as the technology matures and more ways to integrate with real-world data are developed, largely in the form of Chainlink Oracles, we expect to see more grounded use-cases.

The recent NFT boom has shown the potential for blockchain use in managing art and digital rights, although many details still need to be worked out. Other areas where smart contracts might be usefully applied include voting and real estate. In the future, you might be able to hold an NFT that represents the title deed to your home instead of a cartoon monkey with a cigar.

Why use smart contracts?

But why should you use any of this stuff? Isn't the traditional financial system cheaper, better regulated, more responsive to fraud, and better able to reverse mistakes? And isn't crypto just a bunch of ponzi schemes and scams?

I’m glad you asked! There are two answers to this question: