Smart contracts, dApps, and Web3.
2 topics
A blockchain is a distributed, immutable ledger. Key concepts: blocks linked by cryptographic hashes, consensus (PoW, PoS), decentralization, immutability, public-key cryptography (wallets), gas (computational cost), and the trilemma (decentralization, security, scalability). Layer 1 vs Layer 2 scaling solutions.
2 resources
Ethereum introduced smart contracts — programmable blockchain. EVM executes bytecode on every node. Accounts: externally owned (private keys) and contract accounts (code). Transactions, gas mechanics, state storage, events/logs. Post-Merge Proof of Stake. EVM-compatible chains: Polygon, Arbitrum, BSC.
Solidity: statically typed, compiles to EVM bytecode. State variables, functions, modifiers, events. Data types: uint256, address, mapping, structs. Visibility: public/private/internal/external. Storage vs memory vs calldata. Security: checks-effects-interactions, access control, safe math. OpenZeppelin for ERC-20, ERC-721, ERC-1155 standards.
Foundry (forge — fast, Solidity-native tests, fuzz testing, gas reports) and Hardhat (JS/TS, rich plugins, console.log debugging). Both: local blockchain simulation, deployment scripts, Etherscan verification. Testing is critical — contracts are immutable. Audit tools: Slither, Mythril for automated vulnerability detection.
DeFi recreates finance without intermediaries. Uniswap (AMM, x*y=k), Aave/Compound (lending), MakerDAO (stablecoins), Curve (stablecoin swaps). Concepts: liquidity pools, yield farming, flash loans, oracles (Chainlink), governance tokens, and composability (money legos).
Stack: Solidity contracts + React/Next.js frontend + ethers.js/viem for chain interaction + wagmi + RainbowKit for wallet connection + The Graph for indexing. UX: wallet flows, tx confirmations, gas estimation, chain switching. Production: IPFS/Arweave for storage, ENS for names, multi-chain support, testnet before mainnet.