Fully On-Chain Encrypted Messaging App with IPFS Storage
A decentralized, censorship-resistant, privacy-focused messaging application where encrypted messages are stored on IPFS and message metadata is stored on-chain with end-to-end encryption.
- End-to-End Encryption: Messages encrypted client-side before IPFS storage
- IPFS Integration: Encrypted content stored on IPFS, only CIDs on-chain
- Wallet Authentication: MetaMask integration for seamless login
- User Wallet System: Deposit/withdrawal functionality with spending authorization
- Escrow System: Message fees held in escrow with refund capability
- Rate Limiting: Anti-spam protection (100 messages/hour default)
- Decentralized: No central servers or authorities
- Privacy-First: Only sender and recipient can decrypt messages
- Comic-Style UI: Fun, engaging interface with comic book aesthetics
- Responsive Design: Works on desktop and mobile
- React + TypeScript + Vite - Modern frontend framework
- TailwindCSS - Utility-first CSS framework
- Ethers.js - Web3 wallet interaction
- MetaMask - Wallet connection and encryption
- Framer Motion - Animations and transitions
- Radix UI - Accessible component primitives
- Solidity ^0.8.19 - Smart contract language
- Hardhat - Development framework
- OpenZeppelin - Security-audited contract libraries
- Sepolia Testnet - Test network
- IPFS Storage: Encrypted messages stored off-chain
- On-Chain Metadata: Message CIDs, sender/receiver, timestamps
- User Wallets: Deposit-based spending system
- Escrow Management: Fee collection and refund system
- Rate Limiting: Configurable message limits per user
- Primary messaging contract with IPFS integration
- Stores IPFS CIDs of encrypted messages on-chain
- Integrates with user wallet system for fee payment
- Rate limiting and anti-spam protection
- Conversation indexing and pagination
- User deposit/withdrawal management
- Minimum deposit requirement (0.01 ETH)
- Authorized spender pattern for messaging contracts
- Balance tracking and spending authorization
- Message fee escrow system
- Holds fees from messaging transactions
- Refund capability for disputed messages
- Owner withdrawal functionality
- Minimum Deposit: 0.01 ETH required for wallet deposits
- Message Fee: 0.001 ETH per message (configurable)
- Rate Limiting: 100 messages per hour per user
- IPFS CID Storage: Up to 200 character CID strings
- Anti-Abuse: User blocking and contract pause functionality
- Node.js 18+
- MetaMask wallet
- Sepolia ETH for testing
cd frontend
npm install
npm run dev
cd contracts
npm install
npx hardhat compile
npx hardhat test
# Deploy to Sepolia
cd contracts
npx hardhat run scripts/deploy-v3.ts --network sepolia
- Landing Page: View the introduction and click "Get Started"
- Connect Wallet: Click "Connect MetaMask" to authenticate
- Deposit Funds: Deposit ETH into your messaging wallet (minimum 0.01 ETH)
- Send Messages:
- Encrypt message content client-side
- Upload encrypted content to IPFS
- Send IPFS CID through smart contract
- Receive Messages: Retrieve CIDs from blockchain and decrypt content from IPFS
- Client-Side Encryption: Messages encrypted before leaving browser
- IPFS Upload: Encrypted content uploaded to IPFS
- On-Chain Storage: Only IPFS CID stored on blockchain
- Decryption: Recipients fetch from IPFS and decrypt locally
- Wallet-Based Authentication: No passwords, only wallet signatures
- Rate Limiting: Prevents spam attacks
- User Blocking: Admin can block malicious users
- Emergency Pause: Contract can be paused in emergencies
- Escrow System: Fee refunds for disputed messages
App.tsx # Main application with routing logic
βββ contexts/
β βββ WalletContext # Wallet connection management
βββ components/
β βββ LandingScreen # Introduction/welcome page
β βββ ChatApplication # Main messaging interface (in development)
β βββ magicui/ # Comic text and visual effects
β βββ comic-text # Comic book style text
β βββ dot-pattern # Animated background pattern
βββ App.css # Global styles and animations
MessagingContractV3Simple # Main messaging logic
βββ UserWalletContract # Balance management
βββ SimpleEscrow # Fee escrow
βββ IPFS Network # Encrypted content storage
cd contracts
npm run test
cd frontend
npm run test
- β Smart contract deployment and functionality
- β User wallet deposit/withdrawal
- β Message sending with IPFS CID storage
- β Rate limiting and anti-spam
- β Escrow fee management
- β Frontend wallet connection
- β Landing page and navigation
# contracts/.env
SEPOLIA_PRIVATE_KEY=your_private_key
INFURA_PROJECT_ID=your_infura_id
ETHERSCAN_API_KEY=your_etherscan_key
Parameter | Value | Description |
---|---|---|
Minimum Deposit | 0.01 ETH | Required for wallet deposits |
Message Fee | 0.001 ETH | Fee per message |
Rate Limit | 100 msg/hour | Anti-spam protection |
Max CID Length | 200 chars | IPFS CID limit |
- Complete smart contract architecture with IPFS integration
- User wallet system with deposit/withdrawal
- Escrow system for message fees
- Rate limiting and anti-spam protection
- Frontend landing page with comic aesthetics
- Wallet connection with MetaMask
- Responsive design and animations
- ChatApplication component implementation
- IPFS client integration in frontend
- Message encryption/decryption in browser
- Contract deployment and verification
- Frontend-to-contract integration
- Complete messaging UI implementation
- IPFS pinning service integration
- ENS name resolution
- Group messaging capabilities
- Message attachments support
- Mobile app development
- Uses OpenZeppelin battle-tested contracts
- ReentrancyGuard protection
- Input validation and error handling
- Rate limiting prevents abuse
- Emergency pause functionality
- Client-side encryption only
- No plaintext data on blockchain
- IPFS content addressing
- Wallet-based identity
- No centralized data storage
Zephex/
βββ frontend/ # React application
β βββ src/
β β βββ components/ # UI components
β β βββ contexts/ # React contexts
β β βββ magicui/ # Custom UI components
β βββ package.json
βββ contracts/ # Smart contracts
β βββ contracts/ # Solidity source
β βββ scripts/ # Deployment scripts
β βββ test/ # Contract tests
β βββ package.json
βββ README.md # This file
The contracts are designed for Sepolia testnet deployment:
cd contracts
npm run deploy:sepolia
- Mainnet Deployment: Requires audit and security review
- IPFS Pinning: Need reliable pinning service
- Gas Optimization: Further optimization for mainnet costs
- Governance: Consider upgradeability patterns
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature
) - Write tests for new functionality
- Ensure all tests pass (
npm test
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT License - see LICENSE file for details
Building the future of decentralized communication π