Skip to main content

Ethereum Virtual Machine

The Ethereum Virtual Machhine (EVM) functions as a world computer that powers decentralized applications (dApps) running on the Ethereum blockchain.

Decentralised Apps enable people to make transactions via Wallets to a decentralized blockchain database through a Smart Contract Interface or ABI, Application Binary Interface. In the context of computer science this is an interface between two program modules, most often between operating systems and user programs.

Smart Contracts

Smart Contracts are only as smart as the data they are feed is valuable.

The journey from Web2 to Web3 with Scaffold Eth.

Schema

Concepts

Smart Contracts control the flow of information and value on a blockchain through one way decisions based on immutable logic acting on data compiled and stored to ensure integrity.

Hybrid Smart contracts are key to unlocking real value for society. See Engineering Smart Contracts to understand how to code smart contracts.

Advantages

See Web3 for more on business case on smart contract benefits.

  1. Autonomy and savings: Smart contracts do not need intermediaries to confirm an agreement, eliminating the risk of manipulation by third parties while reducing costs.
  2. Backup: All the documents stored on blockchain preventing data loss
  3. Safety: encryption and cryptography maintain integrity of data
  4. Speed: coded logic automates tasks saving hours on human driven processes
  5. Accuracy: eliminate manual data processing errors

Limitations

Early days potential regulatory contraints ahead.

  1. Difficult to change: changes are virtually impossible, any error is extremely expensive.
  2. No wiggle room: Legal and Smart Contracts are not the same thing with no room for iterpretation of good faith.
  3. Third party: still needed to verify legality of adopting a Smart Contract for certain operations.
  4. Vague terms: cannot handle situations where terms and conditions are vague.

Foundations

Every smart contract execution triggers a change to the EVM's state, aka a state transition.

  1. Contract bytecode (compiled from the source code) is loaded from the EVM's storage and executed by peer-to-peer nodes on the EVM. Nodes use the same transaction inputs, which guarantees that each node arrives at the same result (or else they cannot reach consensus).
  2. EVM Opcodes (contained in the bytecode) interact with different parts of the EVM’s state (memory, storage, and stack). Opcodes perform read-write operations—reading (getting) values from state storage and writing (sending) new values to the EVM’s storage.
  3. EVM opcodes perform computation on the values obtained from state storage before returning the new values. This update results in the EVM transitioning to a new state (transactions are called “state transitions” for this reason). This new state is replicated by other nodes and remains until another transaction is executed.

Principles to have mastered:

  • Best Possible Tooling
  • Solidity Preprequisites
  • Fuzzing and Invariants
  • Installing Libraries
  • ERC20 Tokens
  • ERC721 Tokens
  • Advanced Solidity
  • Storage Patterns
  • Fallback and Receive
  • ABI Encode
  • Encoding Functions
  • Upgradeable Contracts
  • Self Destruct
  • Fork Tests

Gas Costs

EVM Codes Playground

Scripting a CLI

Learn the fundamentals to interacting with smart contracts.

Production CLIs