A decentralized, blockchain-based chat application built on Base blockchain that enables secure, transparent, and censorship-resistant communication. All messages are stored onchain, ensuring immutability and verifiability.
Get started with Ambience Chat in minutes:
# Clone the repository git clone https://github.com/ambience-app/frontend.git cd frontend # Install dependencies npm install # Copy environment variables cp .env.example .env.local # Start development server npm run dev
Visit http://localhost:3000 in your browser to see the app running.
- Node.js 20.x or higher
- npm (v7+) or yarn (v1.22+)
- Git
- Web3 wallet (MetaMask, Coinbase Wallet, etc.)
- Test ETH on Base Sepolia (for testing)
- Create a
.env.localfile in the root directory with the following variables:
# Required NEXT_PUBLIC_ALCHEMY_API_KEY=your_alchemy_api_key NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id # Optional (with defaults) NEXT_PUBLIC_CHAIN_ID=84532 # Base Sepolia testnet NEXT_PUBLIC_RPC_URL=https://sepolia.base.org NEXT_PUBLIC_APP_NAME=Ambience Chat
- Get your Alchemy API key from Alchemy
- Get your WalletConnect Project ID from WalletConnect Cloud
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm test- Run testsnpm run lint- Run ESLintnpm run format- Format code with Prettier
This project demonstrates how to build a fully onchain messaging platform where:
- All chat messages are stored directly on the blockchain
- Users authenticate with their Web3 wallets
- Messages are immutable and permanently recorded
- Chat history is transparent and verifiable by anyone
- No centralized servers control the data
- Wallet Authentication: Connect with MetaMask, Coinbase Wallet, WalletConnect, and other Web3 wallets
- Onchain Messages: All messages stored directly on Base blockchain
- Real-time Updates: Live chat interface with automatic message updates
- User Profiles: Onchain identity management with ENS/Basename support
- Message History: Browse complete immutable chat history
- Gas Optimization: Efficient smart contract design to minimize transaction costs
- Responsive Design: Mobile-first UI that works across all devices
- Message Encryption: Optional end-to-end encryption for private messages
- Room/Channel Support: Create and join different chat rooms
- Moderation Tools: Decentralized moderation mechanisms
- Next.js 16 - React framework for production
- TypeScript - Type-safe development
- Tailwind CSS v4 - Utility-first CSS framework
- Wagmi - React hooks for Ethereum (to be added)
- Viem - TypeScript Ethereum interface (to be added)
- RainbowKit/ConnectKit - Wallet connection UI (to be added)
- Base Blockchain - Layer 2 network built on Optimism
- Solidity - Smart contract development
- Foundry/Hardhat - Smart contract development framework
- The Graph - Indexing and querying blockchain data
βββββββββββββββββββ
β Frontend β
β (Next.js) β
ββββββββββ¬βββββββββ
β
ββββ Web3 Provider (Wagmi/Viem)
β
ββββββββββΌβββββββββ
β Smart Contract β
β (Solidity) β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Base Blockchainβ
β (L2 Network) β
βββββββββββββββββββ
frontend/
βββ src/
β βββ app/ # Next.js app directory (pages)
β β βββ page.tsx # Homepage
β β βββ chat/ # Chat interface
β β βββ rooms/ # Room management
β β βββ profile/ # User profile
β βββ components/ # React components
β β βββ Chat/ # Chat-related components
β β βββ Wallet/ # Wallet connection
β β βββ UI/ # Common UI components
β βββ hooks/ # Custom React hooks
β β βββ useContract.ts # Contract interaction hook
β β βββ useMessages.ts # Message management
β β βββ useProfile.ts # User profile hook
β βββ lib/ # Utility functions
β β βββ contract.ts # Contract ABI and config
β β βββ wagmi.ts # wagmi configuration
β β βββ utils.ts # Helper functions
β βββ types/ # TypeScript type definitions
β βββ styles/ # Global styles
βββ contracts/ # Smart contracts (Solidity)
β βββ src/
β β βββ ChatContract.sol # Main chat contract
β β βββ interfaces/ # Contract interfaces
β βββ test/ # Contract tests
β βββ script/ # Deployment scripts
βββ public/ # Static assets
βββ config files # Configuration files
- ChatRoom: Main chat interface with message display and input
- MessageList: Displays messages with sender info and timestamps
- WalletConnect: Wallet connection and authentication
- RoomSelector: Browse and join different chat rooms
- UserProfile: Display and edit user profile information