Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ambience-app/frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

324 Commits

Repository files navigation

Ambience Chat dApp

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.

πŸš€ Quick Start

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.

πŸ“‹ Prerequisites

  • 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)

πŸ”§ Environment Setup

  1. Create a .env.local file 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
  1. Get your Alchemy API key from Alchemy
  2. Get your WalletConnect Project ID from WalletConnect Cloud

πŸ›  Development

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm start - Start production server
  • npm test - Run tests
  • npm run lint - Run ESLint
  • npm run format - Format code with Prettier

Overview

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

Features

  • 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

Tech Stack

Frontend

  • 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)

Blockchain

  • 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

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Frontend β”‚
β”‚ (Next.js) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚
 β”œβ”€β”€β”€ Web3 Provider (Wagmi/Viem)
 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Smart Contract β”‚
β”‚ (Solidity) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Base Blockchainβ”‚
β”‚ (L2 Network) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ— Project Structure

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

Key Components

  • 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

Releases

No releases published

Packages

No packages published

Contributors 6

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /