Intro
Web3 is a label for blockchain-based apps. Smart contracts as the backend, wallets for identity, on-chain assets, and a different trust model from Web2.
Web3 — what it is
EXAMPLE
// ===== The values (and the trade-offs) =====
// - Decentralised state shared across many nodes
// - Public verifiability of code + data
// - Self-custody of assets via wallets
// - New trust model: math + game theory instead of company T&Cs
// Trade-offs: latency, cost (gas), UX complexity, mistakes are often final
// ===== The pieces =====
// Wallet key manager + transaction signer (MetaMask, Rabby, Coinbase Smart Wallet)
// Chain shared ledger (Ethereum mainnet, L2s like Base / Arbitrum / Optimism)
// Smart contract code on chain (Solidity, Vyper, Move)
// Node service that talks to the chain (Infura, Alchemy, self-hosted)
// Indexer reshapes on-chain events for queries (The Graph, Goldsky)
// Dapp web app talking to wallet + contract
// ===== Hello, read =====
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const client = createPublicClient({ chain: mainnet, transport: http() });
const block = await client.getBlockNumber();
console.log('latest block:', block);
// ===== Hello, write (via wallet) =====
import { createWalletClient, custom, parseEther } from 'viem';
const wallet = createWalletClient({ chain: mainnet, transport: custom(window.ethereum) });
const [address] = await wallet.requestAddresses();
const hash = await wallet.sendTransaction({
account: address, to: '0xRecipient', value: parseEther('0.001'),
});
// ===== A tiny Solidity contract =====
// pragma solidity ^0.8.20;
// contract Counter {
// uint256 public n;
// function bump() public { n += 1; }
// }
// ===== When Web3 wins =====
// - Trust-minimised value transfer (payments, payouts)
// - Programmable money (DeFi, prediction markets, escrow)
// - Cross-organisation coordination without a central operator
// - Provable scarcity + ownership (NFTs, credentials)
// ===== When Web3 hurts =====
// - Apps without a clear decentralisation requirement
// - High-throughput consumer features without an L2 or alternative chain
// - When the team would rather not run on-chain ops
// ===== Patterns to internalise =====
// - Read with a typed library (viem / ethers); write via the wallet
// - Test on testnets + forks (Anvil / Hardhat) before mainnet
// - Audit before deploys; bugs in deployed contracts are often irreversible
// - Defensive UI: show transactions clearly; warn on unlimited approvals
// ===== Pitfalls =====
// - Asking users for seed phrases — never do this
// - Unlimited token approvals as 'convenience'
// - Trusting front-end displays without on-chain verification
// - Deploying without bug bounties / audits / pause functions
Why it matters
Web3 is a different trust model with a different toolchain. The technology is fascinating; the discipline is figuring out which products actually need a chain and which would be served better by a database. When the answer is "we need provable ownership or trust-minimised value transfer", the stack earns its keep.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
// Web3 = the on-chain web: open ledgers, programmable money, user-owned identity. // You write smart contracts in Solidity (or Vyper), deploy them, and interact via wallets.Try it Yourself »
Discussion
Loading…