
Explore how the decentralized computer behind Ethereum powers smart contracts and dapps, enabling blockchain state changes and projects from cryptocurrencies to games like cryptic kitties.
Build a smart contract language by implementing an interpreter with state, program counter, stack, and op codes like push, add, and stop to run code.
Review Ethereum white paper, yellow paper, and beige paper to understand smart contracts and the language. Implement op codes, comparisons, and jump instructions for conditional execution and loops.
Install the Windows subsystem for Linux and set the default version, then install Ubuntu 18.04 and optional Visual Studio Code to enable a Linux-like command line with VS Code integration.
Extend the smart contract language to support subtraction, multiplication, and division by updating the interpreter to pop two values and push the computed result, alongside existing add functionality.
Explore how conditionality works in the Ethereum smart contract language by introducing comparison operators like lte, eq, and, or, and a jumping mechanism that enables if-like decisions and conditional execution.
Explore jump and jump i instructions to control program flow, using the program counter and stack to implement loops and conditional execution, with testing and defensive checks.
Explore how the blockchain serves as a public ledger shared across nodes, linking blocks with parent hashes to store transactions; learn mining, proof of work, and block validation.
Explore how to bootstrap a block chain by building a block chain structure with a genesis block, block headers, and a mining workflow to connect blocks in a decentralized system.
Create and test a sort characters utility in the you tell directory to produce a deterministic string from objects, enabling equality checks regardless of property order, with hashing ahead.
Explore hashing fundamentals, including deterministic, unique outputs with kcal 256 producing 64-character hex hashes, and how sorting inputs and the parent hash enable blockchain validation.
Discover how mining uses proof of work to secure a blockchain, spending power to find a valid block, adjusting difficulty via the under target hash and dag.
Implement the mine block target hash calculation for proof-of-work mining. Introduce a beneficiary field, handle max hash, difficulty division, and 64-character hex output with edge-case safeguards and tests.
Explore the mine block algorithm by computing the block target hash, generating truncated headers, and iterating nonce values with a do-while loop to meet the proof-of-work target.
Implement and test the mine block method by restoring the target hash logic and verifying a block instance and that the under target hash meets the proof of work target.
Dynamically adjust the mining difficulty by comparing block timestamps to a configured mine rate. Keep it above one and test its integration.
learn to validate blocks in a decentralized blockchain by enforcing parent hash integrity, proper block number increments, controlled difficulty adjustments, and proof-of-work requirements, including genesis block handling.
Learn to test the validateBlock method in a blockchain context by writing promise-based tests for the genesis and subsequent blocks, validating parent hashes, block headers, and proof-of-work requirements.
Finish the section by confirming the blockchain component and the smart contract language are in place for the decentralized computer. Next, focus on blockchain network, transactions, accounts, and state management.
Build the blockchain network with a private api node using get and post requests, and a pub-sub messaging layer for inter-node blocks and transactions in a decentralized computer.
Develop a private block chain API with Express, exposing endpoints to view the block chain and mine blocks, enabling decentralized networking via a pub sub messaging system.
Learn to implement a server-to-server pub/sub layer with PubNub to synchronize blocks among miners, by configuring credentials, subscribing to test and block channels, publishing messages, and handling asynchronous listeners.
Broadcast blocks via a pub-sub block channel, process incoming messages with a listener, and sync a local blockchain across peers in a decentralized network.
Advance the decentralized computer by mastering the three layers: smart contract language, the block chain, and the block chain network.
Explore accounts and transactions in a decentralized computer, including miner accounts, currency transfers, and mining rewards, as state changes update balances and create new accounts or smart contracts.
Explore how regular and smart contract accounts are defined, attach a key pair for addresses and balances, and implement signature-based transaction authorization using elliptic-curve cryptography.
Implement account objects with sign and verify signature methods, hashing data before signing and validating signatures with a public key. Learn through tests in a node-based environment to verify workflow.
Explore how transactions drive state changes in a decentralized computer, enabling currency transfers between accounts and new account creation, with a transaction class, signing, and a factory pattern.
Implement static methods validateStandardTransaction and validateCreateAccountTransaction to verify signatures, reconstruct data, and resolve or reject promises with clear error messages.
Set up a transaction queue backed by a map to prevent duplicates, with add and get transaction series methods, then test by creating an account and a transaction.
Implement a transact endpoint to post transactions or create accounts, using to and value from request body, with body-parser middleware, and test via API script for pub-sub broadcast to miners.
Learn how to broadcast transactions across a pub-sub network, ensuring every miner updates its local transaction queue by subscribing to the transaction channel, logging receipts, and synchronizing the transaction series.
Explore how blocks store transactions using a transaction series and a transaction root to secure history. Learn how mining and a transaction queue manage new transactions and ensure validations pass.
Advance the decentralized computer by completing accounts and transactions, introducing the smart contract language and blockchain concepts, and creating transaction objects that describe state changes toward the final layer.
Build and explore a trie-based tree to store key-value pairs, implementing put and get, leveraging a root hash for verifiable storage and iterative node navigation.
Build a state management system with a state class backed by a tree, supporting put/get account, and a state route (root hash) included in block headers to synchronize nodes.
implement and execute block and transaction processing by adding run block, run transaction, and helpers for standard and create-account transactions to update the state.
Develop a new account balance endpoint and a static calculate balance method to fetch balances from the world state, with an optional address query parameter.
Introduce a validate transaction series method to verify each transaction in a series, including account existence and balance checks, with async awaiting for robust formatting validation.
Update and test transaction validation by including state for transactions, ensuring the from account balance and recipient exist. Validate the block's transaction series and prepare for a tree-based transactions root.
learn to build a transactions tree to derive the block headers root hash, using a deterministic build tree that sorts items by their KCAL cache.
Define a standard mining reward in the config, add a mining reward transaction type, and update mining logic to credit the miner's account when blocks are mined.
Develop a decentralized computer by integrating the world state with running blocks of transactions and smart contracts to execute programs on a blockchain network of accounts.
Integrate smart contracts into the blockchain by treating each contract as an account with a code array and address, and execute them via transactions using gas and store and load.
Learn how to execute smart contracts stored in state by sending transactions, running the interpreter on contract code, and logging execution results to verify smart contract execution.
Set up per-account storage trees and implement store and load instructions in the interpreter to let smart contracts persist and access data across transactions.
Conclude the final coding section and outline ways to extend the project with follow-ups and learning resources for continuing to explore smart contracts in the decentralized computer.
Master a quick JavaScript primer: primitives, variables, arrays, objects, console use, loops, conditionals, undefined, and strict vs loose equality in browser and Node.js.
Explore core javascript concepts in this part two overview, including functions, callbacks, and arrow syntax, then dive into classes, constructors, and this for object creation.
Congratulate yourself on completing the project and explore extensions to Ethereum smart contracts, including transaction fees, gas price, and validation enhancements.
The most requested topic for a course I've had so far is to "build a smart contract blockchain and cryptocurrency." And for plenty of reasons:
Smart contracts are the main feature behind Ethereum, which is the second most valuable cryptocurrency.
Learning smart contracts is a natural next step after learning about blockchains. A blockchain is a decentralized ledger. A smart contract blockchain is a decentralized computer.
A smart contract blockchain can support decentralized applications. This opens the door to a wide variety of solutions.
Based on these points and more it would definitely be a valuable learning experience to try building a smart contract blockchain and cryptocurrency like Ethereum.
So it can be quite surprising to discover that existing tutorials are challenging to find. Sure, there's the Ethereum documentation. But this information is better understood when you're pretty knowledgeable about blockchains already. Likewise, other resources you find, like articles and videos, mostly focus on aspects of a completed Ethereum system. They don't take you through the process of completely building a smart contract blockchain and cryptocurrency.
However, it's understandable. A complete system like Ethereum is quite complex. It uses many advanced data structures and technologies. And untangling the interaction between its many components can feel like navigating through a labyrinth.
This is why I made it my mission to create a "Build Ethereum From Scratch" tutorial that focuses on the essential elements. By the end of the tutorial, you should be able to execute smart contracts in a decentralized way.
And with a few months of work, here you have the finished product! Here is the course journey:
Build a smart contract language and an interpreter to execute code
Next, create an ethereum-inspired blockchain, with its own mining implementation, and block structures
Extend the blockchain with a network implementation
Incorporate transactions and accounts. This will set up the Ethereum-like cryptocurrency, and create the concept of a decentralized computer
Come full circle by running smart contracts on the blockchain
By the end of the course, you will have built a decentralized computer platform that resembles many of the key features of Ethereum. In addition, at the end of the course, I'll provide a list that you can use for continued development. That way, the project is truly in your hands - ready to go as far as you want to take it.
Take this course if you want to learn how Ethereum works. Especially take this course if you've been hoping to build your own version of Ethereum. By the end, you'll have a unique item on your resume, or even the foundation for your next startup!
Alright, let's get started coding!