Skip to main content

Introduction to Smart Contracts

Concretely, decentralized applications are constructed by smart contracts on the Ethereum blockchain. Here's a few mental models to think about what a smart contract is capable of.

  • Web development lens: You can think of smart contract as the backend + database of your application.
  • Object oriented programming lens: A smart contract is just a class. It's got methods and attributes. When someone says a smart contract has X address, they are saying there's an instance of the smart contract out there with memory address X. It's expensive for users to instantiate new instances of the smart contracts, so we try to design them in a way that everyone can share the same instance.
  • Purely technical lens: A smart contract is bytecode deployed to Ethereum's virtual machine. Similar to byte code or machine level code, humans write programs in a high level language that gets compiled. In Ethereum, most programmers write code in Solidity. This code defines the functions the smart contract has as well as how the smart contract manipulates data. In solidity, this data can take the form of hashmaps, integers, or strings.

When someone deploys a smart contract, they will receive the smart contract's address. By interacting with an ethereum node (most commonly via javascript or python), the user can tell the node to call a function in the smart contract at address X. Every time a user calls a smart contract function, this becomes a transaction on the Ethereum network.

Recommended reading:

Introduction to Smart Contracts - Solidity 0.8.3 documentation

Anatomy of smart contracts |