Skip to main content

Onchain Apps

Blockchain apps are web apps. The chain is just another backend.

Smart contract writing is 20-30% of a production Web3 project. The other 70-80% is standard web development — hooks, routes, state management, UI components. Your Next.js skills transfer directly. The only layer that changes is where the action lands.

Same Patterns

Every onchain interaction maps to a pattern you already use.

Web Dev PatternTraditionalOnchain
Data fetchinguseQuery / useSWRuseSuiClientQuery / wagmi useReadContract
MutationServer action / useMutationTransaction (Sui PTB) / useWriteContract
AuthNextAuth / ClerkzkLogin / wallet connect
EventsWebSocket / SSEContract events / indexer subscription
API routeapp/api/route.tsSame — talks to RPC instead of database
StateZustand / React Query cacheSame — chain is source of truth, cache locally

The mental shift: a database stores mutable rows. A chain stores owned objects (Sui) or contract state (EVM). Your hooks read and write to it the same way — the SDK handles the transport.

App Architecture

Next.js pages / API routes          ← standard web dev

React hooks (read, write, auth) ← only this layer changes

SDK + Provider (wagmi, dApp Kit) ← chain-specific adapter

RPC → Blockchain ← replaces database

Everything above the hooks layer is identical to traditional web dev. Everything below is handled by the SDK. The hooks layer is where you learn something new — and each platform gives you a React-native toolkit for it.

SDK Comparison

Three platforms, three React toolkits. Same job: read state, send transactions, manage wallets.

ConcernEVMSolanaSui
Base SDKviem / ethers.js@solana/web3.js@mysten/sui
React hookswagmiwallet-adapter-react@mysten/dapp-kit
WalletWalletConnect / MetaMaskPhantom adapterSui Wallet + zkLogin
Seedless onboardingERC-4337 (complex)None nativezkLogin (protocol-level)
Tx compositionMulticall (limited)Instructions in one txPTBs (1,024 ops, atomic)
Sponsored gasPaymaster contractsRelayer servicesGas station API (native)

The DX question: which platform lets a web developer ship a working dApp fastest? Sui's zkLogin removes the wallet install barrier entirely — users sign in with Google and get a Sui address. No extension, no seed phrase, no onboarding friction.

Three Failure Layers

Where bugs actually live in onchain apps:

LayerWhat BreaksWeb Dev Analogy
ContractLogic errors are permanentDatabase schema bugs
BridgeSDK calls, event parsing, tx constructionAPI client / ORM bugs
Off-chainIndexers, agents, API routesBackend service bugs

Most integration bugs live in the bridge layer — the same place most REST API bugs live. The contract is small by design. The off-chain code is where complexity compounds.

Dig Deeper

  • Data Indexers — How chain data becomes queryable: The Graph, custom subgraphs, indexer patterns
  • Notifications — Transaction status and event push via Blocknative and alternatives

Context

Questions

At what layer does onchain interaction stop being "just web dev" and require chain-specific thinking?

  • What state management pattern handles wallet connection, transaction status, and chain switching without chain-specific code in the UI layer?
  • When does an SDK abstraction layer add value versus hide errors you need to see?
  • How do you test onchain interactions in CI without hitting a live network?
  • What makes sponsored transactions (zero gas for users) a product requirement rather than a nice-to-have?