Ethereum Virtual Machine
The Ethereum Virtual Machine (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.
Application Development
Chain ID
chainID chain identifier, was introduced in EIP-155 to prevent replay attacks.
Value Denominations
Always need to use whole numbers.
Denominations | Value |
---|---|
Wei | 1000000000000000000 |
Gwei | 1000000000 |
Ether | 1 |
Gas
The cost of running a smart contract.
Time x Computing.
Need to engineer Smart Contracts for optimal efficiency to save gas.
Accounts
Get 10 by default with seed phrase.
When you restore from a Seed Phase the account names are not persisted
Smart Contracts
Contracts are only as smart as the data they can process.
The journey from Web2 to Web3 with Scaffold Eth.
Context
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.
- Autonomy and savings: Smart contracts do not need intermediaries to confirm an agreement, eliminating the risk of manipulation by third parties while reducing costs.
- Backup: All the documents stored on blockchain preventing data loss
- Safety: encryption and cryptography maintain integrity of data
- Speed: coded logic automates tasks saving hours on human driven processes
- Accuracy: eliminate manual data processing errors
Limitations
Early days potential regulatory constraints ahead.
- Difficult to change: changes are virtually impossible, any error is extremely expensive.
- No wiggle room: Legal and Smart Contracts are not the same thing with no room for interpretation of good faith.
- Third party: still needed to verify legality of adopting a Smart Contract for certain operations.
- 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.
- 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).
- 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.
- 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 Prerequisites
- 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
Scripting
Learn the fundamentals of interacting with Smart Contracts by scripting a CLI.
Production CLIs