DEV Community

WZRD
WZRD

Posted on

High Level Understanding Of Smart Contracts In Ethereum

First, I want to thank Patrick McCorry for making all of this knowledge available to myself and others.

Second, I'd like to assert that I'm writing from an Ethereum paradigm.

Overview

We'll be looking at smart contracts to cover what they are and how they're used in relation to Ethereum.

What Is A Smart Contract?

"A smart contract is a computerized 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." -Nick Szabo (1994)

Simply put, a smart contract will guarantee immutability of code (never modified), atomic operations of code (all or nothing), and public accessibility of code (no secrets).

Smart Contracts In Ethereum

There are two types of accounts in Ethereum's database: externally owned accounts and contract accounts. Externally owned accounts are controlled by individuals (keys), and contract accounts are controlled by code (smart contracts) and storage.

Contract accounts are the reason for two of the three types of transactions on Ethereum: creation transactions, and invocation transactions. Creation transactions carry smart contract code in their payload that get instantiated as an account in the Ethereum database. After a smart contract has been created by a creation transaction, invocation transactions become possible. Invocation transactions carry commands in their payload to invoke code in the target contract- that's stored in the database- that updates the state of the database.

How Are Smart Contracts Built

  • Solidity: Type language; object oriented.
  • Ethereum Virtual Machine: Every peer on the network has an instance of the EVM their local machine; each peer deterministically executes code (transactions).
  • Event Driven Programs: Smart contracts don't run themselves. Every transaction made to the blockchain (Ethereum database) costs "gas" (a unit of measurement for computation).

Top comments (2)

Collapse
 
supportingyouuuu profile image
ijustwantedtocomment • Edited

10/10 wow, very detailed made it easy for me to understand 🙌🏽

Collapse
 
supportingyouuuu profile image
ijustwantedtocomment

Very smart educated man ! Keep up the good work 🙌🏽✨🙂