Understanding the Web3 Stack
π Understanding the Web3 Stack
The Web3 stack is the foundation of the decentralized internet. It consists of multiple layers and technologies that enable decentralized applications (dApps), smart contracts, and secure transactions without central authorities.
β οΈ Web3 is powered by a multi layered stack including blockchain, consensus, smart contracts, tokens, and decentralized infrastructure. This guide covers key components like Ethereum, smart contracts, wallets, and security risks.
π Blockchain Basics
π¦ Block
A block is a record of transactions that are stored in a secure, decentralized manner. It is a data structure that consists of a list of transactions, a timestamp, and a cryptographic hash of the previous block in the chain.
βοΈ Blockchain
A blockchain is a distributed, decentralized ledger that holds chronologically organized transaction records.
π Hashing
Hashing is the process of creating a fixed size string of data, called a hash, from a larger input. It is used to verify the integrity of data and to create unique identifiers for each block in a blockchain. For example f2d81a260dea8a100dd517984e53c56a7523d96942a834b9cdc249bd4e8c7aa9.
π Nonce
A "number used once" is a random number generated during the Proof of Work (PoW) mining process. It serves as a hashing base and a way for miners to check the validity of a block, since the block will only receive a nonce once it has been mined.
π§Ύ Blockchain Transaction
A blockchain transaction is a transfer of value between two parties that is recorded on a blockchain network. It consists of three parts: an input (the source of the funds), an output (the recipient of the funds), and a digital signature that verifies the transaction
π‘ Network Infrastructure
π₯ Node
A node in a blockchain is a computer device that is connected to the blockchain network and is able to validate and broadcast transactions to other nodes in the network. Nodes play a crucial role in maintaining the integrity and security of the blockchain by verifying and adding new transactions to the blockchain. They may also store a copy of the entire blockchain and participate in the consensus process to reach agreement on the state of the blockchain.
β Consensus
Describes a process by which a group of peers or nodes on a network determine which blockchain transactions are valid and which are not. Some popular consensus mechanisms are Proof of Work and Proof of Stake.
βοΈ Consensus Mechanisms
- Proof of Work (PoW): Proof of Work is a consensus mechanism in which miners use cryptographic methods to prove a certain amount of work (computational power) was expended to solve a puzzle. Other network participants can easily verify the proof and validate the blocks proposed by another miner.
- Proof of Stake (PoS): PoS is a consensus mechanism involving stakers and validators. People who stake their cryptocurrency in the network get the right to take part in block production and verify transactions. In Ethereum for example, the minimum staking amount is 32 ETH, which a miner must lock into the network to ensure that they have enough incentive to verify transactions in a non malicious way.
π§ Miners
Miners are individuals or groups who use their computational resources to validate transactions and add them to the blockchain. They play a crucial role in maintaining the integrity and security of the blockchain network. In return for their efforts, they are typically rewarded with a portion of the transaction fees and/or a block reward, which is a set amount of cryptocurrency.
π Blockchain Architecture
βοΈ Immutability
Refers to the fact that once data is written to a blockchain, it cannot be altered or deleted. This ensures the integrity and security of the data on the blockchain. Thanks to all blockchain transactions being recorded on every node in the network, changing one piece of data would require altering every node making it virtually impossible to do.
π§± Layered Structure
- Layer 0: Layer 0 represents the underlying infrastructure that houses nodes, data storage, communication between blockchains, and consensus mechanisms.(e.g., Polkadot)
- Layer 1: Layer 1 is the platform layer specific to a particular blockchain. Ethereum is a platform layer that enables all layers on top of it through EVM and smart contracts.
- Layer 2: Layer 2 is the scalability layer where we can find optimistic rollups or ZK-proofs. These are solutions that scale layer 1 and enable faster transactions.
- Layer 3: Layer 3 is home to decentralized applications (like OpenSea, Uniswap, MetaMask, etc). These are applications that are based on and communicate with layer 1s. They are the frontend of the blockchain and the main way most users interact with Web3 and the underlying infrastructure.
βοΈ Blockchain Trilemma
The blockchain trilemma describes a problem that many blockchains encounter, which is the need to balance the pillars of decentralization, security, and scalability. Typically, blockchains can only achieve two and compromise on the third.
π§ Cryptographic Concepts
𧬠Byzantine Fault Tolerance
Byzantine fault tolerance is the ability of a distributed system, such as a blockchain network, to function correctly even when some of its nodes are behaving in an unreliable or malicious manner. It allows a blockchain to remain decentralized and secure, even when some of its nodes are compromised or fail. Read more about the Byzantine Generals Problem.
π Public/Private Keys
- Public Key: A public key is a unique, long string of numbers or letters used in conjunction with a private key to prove identity and ownership online.
- Private Key: A private key is a secret, unique string of numbers or letters used to decrypt messages encrypted with a corresponding public key.
π Symmetric vs. Asymmetric Encryption
- Symmetric: Symmetric cryptography is a method of encrypting data using the same secret key for both encryption and decryption.
- Asymmetric: Asymmetric cryptography is a method of encrypting data using a public key and a private key, for encryption and decryption, respectively. (e.g., RSA)
π§Ύ Digital Signature
A digital signature is a mathematical technique used to verify the authenticity and integrity of a transaction, message, software, or digital document.
βοΈ Smart Contracts & Development
π€ Smart Contract
A smart contract is a self-executing contract with the terms of the agreement between peers directly written into lines of code.
π§βπ» Solidity
Solidity is a high-level programming language that can be used for designing and writing smart contracts. Itβs built with a strong influence of C++, Javascript, and Python.
π§© ABI (Application Binary Interface)
Application Binary Interface is an interface between two binary program modules. Difficult to read for the end-user, but with the right tools provides all the details about what a smart contract does.
π Approve Function
The approve function in a smart contract is used to allow another address to spend a specified amount of tokens from the contract owner's account.
πͺ Gas
Gas is a unit that describes the amount of computational work miners need to do in order to verify a single transaction. The gas fee is the price users pay to cover the costs associated with the computational work and resources needed to run the network.
π‘ Testnet
A testnet is a tool that mimics the original blockchain network. Testnets are used for experimenting and testing contracts before deploying to the main network (mainnet).
πͺ Tokens & Standards
π ERC
ERC stands for Ethereum Request for Comments and represents a document that developers use to write smart contracts on the Ethereum blockchain. It describes the rules that Ethereum based standards must comply with.
π ERC Standards
- ERC-20: ERC-20 is a technical standard for fungible (interchangeable) tokens created using the Ethereum blockchain. Examples are USDC, SHIBA, UNI, etc.
- ERC-721: ERC-721 is a foundational standard describing how to build nonfungible tokens. It describes the minimum interface a smart contract must implement to allow NFTs to be managed, owned, and traded.
- ERC-1155: ERC-1155 is a standard for a contract used to manage multiple tokens. That means that a single contract may include a mix of different token types: fungible, non fungible or semi fungible. This standard reduces transaction and storage costs.
πΌ NFT (Non Fungible Token)
NFT stands for a Non Fungible Token a unique digital token that cannot be copied, substituted, or subdivided. Examples are the Surge Passport NFT, Bored Ape Yacht Club, Crypto Punks, etc.
π¬ EIP (Ethereum Improvement Proposal)
EIP stands for Ethereum Improvement Proposal a process in which an ERC is reviewed.
π Wallets & Identity
π Wallet Types
- Hot Wallets: Software based (e.g., MetaMask)
- Cold Wallets: Hardware devices (e.g., Ledger, Trezor)
- Paper Wallets: Physical printout of keys
- Multi Sig Wallets: Require multiple key signatures
πͺͺ ENS (Ethereum Name Service)
Ethereum Name Service (ENS) is a distributed, open, and extensible naming system based on the Ethereum blockchain. You can buy an ENS username as an NFT and it serves as your Web3 username. ENS maps human readable names like juliettech.eth to computer readable identifiers like an Ethereum address.
π§ Seed Phrase
A seed phrase is a mnemonic phrase consisting of 12 or 24 words used to recover a wallet.
ποΈ Web3 Accounts
π€ Externally Owned Account (EOA)
An Externally Owned Account (EOA) is an account in Ethereum that is controlled by a private key and owned by a person or entity.
π§Ύ Contract Account
A Contract Account is an account in Ethereum that is created and controlled by a smart contract and can only send a transaction in response to receiving one.
πͺͺ Public Address
A public address is a shorter form of a public key used as a recipient address on the blockchain.
ποΈ Governance & Infrastructure
π’ DAO (Decentralized Autonomous Organization)
Decentralized Autonomous Organization (DAO) It is a form of organizational structure without a central entity whose members share a common goal to act in the best interest of the entity. Decisions are made in a bottom up management approach and rules are established through smart contracts.
π‘ IPFS (InterPlanetary File System)
IPFS stands for InterPlanetary File System distributed system for storing and accessing files, websites, applications, and data.
π¨ Common Web3 Security Risks
β οΈ Reentrancy Attacks
Reentrancy attack Involves exploiting a vulnerability in a smart contract to repeatedly call an external function and execute malicious code.
π Underflow & Overflow
Underflow and overflow attacks in blockchain involve manipulating the data stored in a smart contract to either decrease or increase a value below or above its intended minimum.
β Final Thoughts
Web3 technology reimagines the internet by prioritizing decentralization, privacy, and ownership. Understanding the Web3 stack is the first step toward building or participating in a more open digital world.