Skip to content

Latest commit

 

History

History
245 lines (184 loc) · 4.88 KB

File metadata and controls

245 lines (184 loc) · 4.88 KB

CodedForum Setup Guide

🚀 Quick Start

This guide will help you set up and run the CodedForum Web3 Learn-to-Earn community platform.

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • MetaMask browser extension
  • Git

Installation

1. Clone the Repository

git clone https://github.com/codedforum/CodedForum-community.git
cd CodedForum-community

2. Install Dependencies

Backend Dependencies

npm install

Frontend Dependencies

cd client
npm install
cd ..

Smart Contract Dependencies

cd contracts
npm install
cd ..

Or install all at once:

npm run install-all

3. Environment Configuration

Create a .env file in the root directory:

cp .env.example .env

Edit .env with your configuration:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/codedforum
IPFS_HOST=ipfs.infura.io
IPFS_PORT=5001
IPFS_PROTOCOL=https
JWT_SECRET=your_jwt_secret_here
CONTRACT_ADDRESS=your_contract_address_here
NETWORK_RPC_URL=https://ethereum-sepolia.publicnode.com

Running the Application

Development Mode

Option 1: Run All Services Concurrently

npm run dev-all

Option 2: Run Services Separately

Terminal 1 - Backend:

npm run dev

Terminal 2 - Frontend:

npm run client

The application will be available at:

Smart Contract Deployment

1. Compile Contracts

cd contracts
npm run compile

2. Deploy to Testnet (Sepolia)

First, add your private key to .env:

PRIVATE_KEY=your_private_key_here

Then deploy:

npm run deploy:sepolia

Save the deployed contract address and update .env:

CONTRACT_ADDRESS=deployed_contract_address

3. Deploy to Mainnet

⚠️ Warning: Only deploy to mainnet when ready for production!

npm run deploy

Features Overview

✅ Implemented Features

  1. Web3 Wallet Integration

    • MetaMask connection
    • User authentication via wallet
    • Wallet address display
  2. Forum Functionality

    • Create posts with categories
    • Comment on posts
    • Upvote/downvote system
    • Real-time discussion threads
  3. Learn-to-Earn System

    • Earn reputation for posts (5 points)
    • Earn tokens for comments (1 token + 2 reputation)
    • Earn tokens for upvotes (0.5 tokens + 1 reputation)
    • Leaderboard tracking
  4. Smart Contracts

    • ERC20 token (CodedForum Token - CFT)
    • Reward distribution mechanism
    • On-chain reputation tracking
  5. IPFS Integration

    • Decentralized content storage
    • Permanent post archival
  6. User Profiles

    • View reputation and tokens earned
    • Track activity
    • Claim rewards

Project Structure

CodedForum-community/
├── client/                 # React frontend
│   ├── public/
│   ├── src/
│   │   ├── components/    # React components
│   │   ├── utils/         # Utility functions
│   │   ├── App.js
│   │   └── index.js
│   └── package.json
├── server/                # Express backend
│   ├── index.js          # Main server file
│   └── utils/            # Server utilities
├── contracts/            # Smart contracts
│   ├── CodedForumToken.sol
│   ├── hardhat.config.js
│   └── scripts/
│       └── deploy.js
├── package.json
├── .env.example
└── README.md

API Endpoints

Users

  • POST /api/users/register - Register new user
  • GET /api/users/:walletAddress - Get user profile

Posts

  • GET /api/posts - Get all posts
  • POST /api/posts - Create new post
  • GET /api/posts/:id - Get single post
  • POST /api/posts/:id/comments - Add comment
  • POST /api/posts/:id/vote - Vote on post

Rewards

  • GET /api/rewards/leaderboard - Get top users
  • POST /api/rewards/claim - Claim rewards

Categories

  • GET /api/categories - Get all categories

Troubleshooting

MetaMask Connection Issues

  1. Ensure MetaMask is installed
  2. Switch to correct network (Sepolia testnet for development)
  3. Refresh the page and try reconnecting

Backend Connection Issues

  1. Check if backend is running on port 5000
  2. Verify .env configuration
  3. Check console for errors

Smart Contract Issues

  1. Verify contract is deployed
  2. Check CONTRACT_ADDRESS in .env
  3. Ensure you're on the correct network

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support

For issues and questions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review the troubleshooting section

License

MIT License - see LICENSE file for details