A full-stack Web3 application that allows users to "Buy me a Coffee" by sending ETH on the Sepolia Testnet. This project uses a Hybrid Architecture: blockchain for transactions and permanence, and a Django-based "Indexer" for high-performance data retrieval.
- Direct ETH Transfers: Tips go directly to the smart contract, with a secure withdrawal pattern for the owner.
- On-Chain Memos: Every coffee includes a name and message stored permanently on the Ethereum blockchain.
- Fast Indexing: A custom Python background worker listens for blockchain events and saves them to a database.
- Real-Time UI: Built with React and Tailwind CSS, featuring a "Wall of Memos" that loads instantly via REST API.
- Responsive Design: Fully mobile-friendly UI with unique avatars for every supporter.
- Frontend: React, Vite, Tailwind CSS, Wagmi, RainbowKit
- Backend: Django, Django REST Framework, Web3.py
- Smart Contract: Solidity (OpenZeppelin Ownable)
- Infrastructure: Alchemy (WebSocket RPC), Vercel (Frontend Hosting), Render (Backend Hosting)
Most dApps are slow because they fetch data directly from the blockchain every time a user loads the page. This app is different:
- User Sends Coffee: The user triggers a transaction via MetaMask.
- Contract Emits Event: The Solidity contract emits a
newMemoevent. - Indexer Picks It Up: The Django background worker (
listen.py) sees the event via a WebSocket. - Database Storage: The memo is saved to the database.
- API Delivery: The frontend fetches the memos from the Django API in milliseconds.
- Python 3.10+
- Node.js 18+
- An Alchemy API Key (Sepolia WebSocket)
- Navigate to the backend folder:
cd backend- Install dependencies:
pip install -r requirements.txt- Create a
.envfile and add your credentials:
ALCHEMY_API_KEY=your_alchemy_websocket_key
CONTRACT_ADDRESS=0x49072199Ca43207500463bf1f562eFe32ce160Df- Start the whole backend system:
sh run.shThis single command runs database migrations, starts the blockchain event listener, and launches the Django API server.
- Navigate to the frontend folder:
cd frontend- Install dependencies:
npm install- Create a
.envfile:
VITE_API_URL=http://127.0.0.1:8000- Start the development server:
npm run devThe contract uses the Withdrawal Pattern. ETH sent by supporters is held in the contract. Only the owner (the deployer) can call the withdrawTip() function to transfer the accumulated balance to their personal wallet.
This project is licensed under the MIT License.
- Frontend: https://coffee-five-psi.vercel.app/
- Contract Address:
0x49072199Ca43207500463bf1f562eFe32ce160Df(Sepolia)