Skip to content

SL177Y-0/CosmicChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Cosmic Chat - Web3 Messaging Application

Cosmic Chat is a decentralized messaging application built on blockchain technology, allowing users to communicate securely via smart contracts and IPFS.

Features

  • Web3 wallet connection with MetaMask
  • Blockchain-powered chat rooms and messaging
  • IPFS integration for decentralized file sharing
  • Real-time message updates
  • ENS name resolution
  • Beautiful dark mode UI with cosmic theme

Project Structure

CosmicChat/
│
├── contract/
│   ├── CosmicChatContract.sol    # Main smart contract
│   ├── compile.js                # Contract compilation script
│   ├── deploy.js                 # Deployment script using ethers
│   ├── package.json              # Contract dependencies
│   └── build/                    # Compiled contract artifacts
│
├── frontend/
│   ├── app/                      # Next.js app directory
│   │   ├── chat/                 # Chat page
│   │   ├── layout.tsx            # Root layout
│   │   └── page.tsx              # Home page
│   │
│   ├── components/               # React components
│   │   ├── ui/                   # UI components
│   │   ├── FileUpload.tsx        # File upload component
│   │   └── ...                   # Other components
│   │
│   ├── contracts/                # Contract ABIs
│   │   └── CosmicChatContract.json
│   │
│   ├── hooks/                    # Custom React hooks
│   │   ├── useChatMessages.ts    # Chat message hook
│   │   ├── useIPFS.ts            # IPFS file handling hook
│   │   └── ...                   # Other hooks
│   │
│   ├── lib/                      # Utility functions and contexts
│   │   ├── context/              # React contexts
│   │   │   └── Web3Context.tsx   # Web3 provider context
│   │   └── ...                   # Other utilities
│   │
│   ├── pages/                    # Pages directory for API routes
│   │   ├── api/                  # API routes
│   │   │   ├── chat/             # Chat API endpoints
│   │   │   └── ipfs/             # IPFS API endpoints
│   │   └── ...                   # Other pages
│   │
│   ├── public/                   # Static assets
│   ├── styles/                   # CSS styles
│   ├── next.config.mjs           # Next.js configuration
│   ├── package.json              # Frontend dependencies
│   └── .env.local                # Environment variables
│
└── README.md                     # Project documentation

Setup and Installation

Prerequisites

  • Node.js (v18 or higher)
  • MetaMask wallet
  • Infura account for IPFS and Ethereum API access

Smart Contract Setup

  1. Install dependencies:

    cd contract
    npm install
  2. Create a .env file in the contract directory:

    PRIVATE_KEY=your_wallet_private_key
    SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/your_infura_key
    
  3. Compile the smart contract:

    npm run compile
  4. Deploy to Sepolia testnet:

    npm run deploy

Frontend Setup

  1. Install dependencies:

    cd frontend
    npm install
  2. Create a .env.local file in the frontend directory:

    NEXT_PUBLIC_CONTRACT_ADDRESS=your_deployed_contract_address
    SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/your_infura_key
    INFURA_IPFS_PROJECT_ID=your_infura_ipfs_project_id
    INFURA_IPFS_PROJECT_SECRET=your_infura_ipfs_project_secret
    PRIVATE_KEY=your_wallet_private_key
    
  3. Prepare contract artifacts:

    • Copy the compiled contract ABI from contract/build/CosmicChatContract.json to frontend/contracts/CosmicChatContract.json
  4. Start the development server:

    npm run dev
  5. Open your browser at http://localhost:3000

Usage

  1. Connect your MetaMask wallet to the application
  2. Create a new chat room or join an existing one
  3. Start sending messages and sharing files
  4. Files are automatically uploaded to IPFS and shared in the chat

Technology Stack

  • Smart Contract: Solidity
  • Blockchain: Ethereum (Sepolia testnet)
  • Frontend: Next.js, React, TypeScript
  • Web3 Integration: ethers.js
  • File Storage: IPFS via Infura
  • Styling: Tailwind CSS, shadcn/ui
  • Development: Node.js

License

MIT License

About

Cosmic Chat is a decentralized messaging application built on blockchain technology, offering secure, censorship-resistant communication through smart contracts and IPFS. Users can connect seamlessly using MetaMask to join blockchain-powered chat rooms for real-time, encrypted messaging. The integration of IPFS enables decentralized file sharing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors