Real-time chat app where room owners can gate access using ERC20 tokens on Base. Built with React, Supabase, and Privy to power the Chat Fidget for nounspace.com, but works anywhere. 100% of the code was written by https://bolt.new with supervision from @willywonka.eth and @sktbrd.eth.
👾🚀🌈
- 💬 Real-time chat rooms with automatic message updates
- 🔒 Token-gating with ERC20 tokens on Base
- 👤 Web3 authentication with Privy
- 🎭 Farcaster identity integration
- ⚡ Real-time updates with Supabase
- 🎨 Beautiful UI with Tailwind CSS
- 😎 Emoji and GIPHY pickers
- 🖼️ Chat room avatar management system
- 🏆 Chat room leaderboard
- 🏷️ Automatic token name and symbol detection
- 🔍 Smart contract owner detection
- 📝 Manual owner address assignment for non-contract rooms
- Node.js 18+
- A Supabase project
- A Privy account
- An Airstack API key
- An Alchemy API key
- An Etherscan API key
- A GIPHY API key
Create a .env
file with the following variables:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_PRIVY_APP_ID=your_privy_app_id
VITE_AIRSTACK_API_KEY=your_airstack_api_key
VITE_ALCHEMY_API_KEY=your_alchemy_api_key
VITE_ETHERSCAN_API_KEY=your_etherscan_api_key
-
Clone the repository:
git clone https://github.com/yourusername/token-gated-chat.git cd token-gated-chat
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173
src/
├── components/ # React components
│ ├── auth/ # Authentication components
│ ├── chat/ # Chat-related components
│ └── room/ # Room management components
├── lib/ # Utility functions and hooks
│ ├── airstack/ # Airstack API integration
│ ├── api/ # API functions
│ ├── auth/ # Authentication utilities
│ ├── contracts/ # Smart contract interactions
│ ├── etherscan/ # Etherscan API integration
│ ├── hooks/ # Custom React hooks
│ ├── store/ # State management
│ └── types/ # TypeScript type definitions
└── main.tsx # Application entry point
- Create or load rooms directly from the homepage by a name. If a room with that name already exists, it will be loaded instead of created.
- To create a room with query parameters, pass the room name (or contract address) like so:
- For contract addresses: Automatically detects owner through:
deployer()
function callowner()
function call- Contract creation transaction
- Etherscan API fallback
- For non-contract rooms or when automatic detection fails
- Prompts user to input owner address
- Handles addresses case-insensitively
- Room owner can set required token and amount for room access
- Real-time token balance checking
- Automatic token symbol detection
- BaseScan integration for token verification
- For contract rooms, app queries 'image' for the default avatar
- Room owners can upload any image <2mb as the avatar
name
(text, primary key): Room identifierowner_address
(text): Ethereum address of room ownertoken_address
(text, optional): ERC20 token address for gatingrequired_tokens
(numeric): Required token balancecreated_at
(timestamp): Room creation timeavatar_url
(text): URL of room avataravatar_updated_at
(timestamp): Avatar upload timeuse_contract_avatar
(boolean): True to use the 'image' returned from the contract, False for custom avatar
id
(uuid, primary key): Message identifierroom_id
(text): Reference to room nameuser_address
(text): Sender's Ethereum addresscontent
(text): Message contentcreated_at
(timestamp): Message timestampfarcaster_username
(text, optional): Sender's Farcaster usernamefarcaster_avatar
(text, optional): Sender's Farcaster avatar
room_name
(text): Reference to room namemessage_count
(int8): Number of messages sent in a roomunique_users
(int8): Number of unique users that have sent at least 1 message in a roomlast_message_at
(timestamp): Last message timestamp
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -am 'Add new feature'
- Push to the branch:
git push origin feature/my-feature
- Submit a pull request
- Follow the existing code style and conventions
- Write clear commit messages
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- Use TypeScript for type safety
- Keep components small and focused
- Extract reusable logic into hooks
npm run build
The built files will be in the dist
directory.
MIT License. See LICENSE for details.