From 71d5b548dd9b36aa9270fb0034b5a6f634018ca3 Mon Sep 17 00:00:00 2001 From: ChinmayNakwa Date: Sat, 25 Oct 2025 15:40:16 +0530 Subject: [PATCH 1/2] docs: add contribution guide --- CONTRIBUTING.md | 151 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 45 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd202bb..c390321 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,72 +1,133 @@ # Contributing to BugChan -Thanks for contributing! This guide covers local setup, project structure, envs, deploys, and useful scripts. +This guide provides all the information you need to get started with local setup, understanding the project structure, managing environment variables, and following our development workflow. -## Monorepo layout -- packages/hardhat – Solidity contracts, deploy scripts, tests -- packages/nextjs – Next.js frontend (App Router) +## Monorepo Layout + +The project is a Yarn monorepo, separating the on-chain and off-chain logic into two main packages: + +- `packages/hardhat` – Contains all Solidity smart contracts, deployment scripts, tests, and local blockchain configuration. +- `packages/nextjs` – The complete Next.js frontend application, built with the App Router and leveraging Wagmi for blockchain interaction. ## Prerequisites -- Node.js 20+ -- Yarn 3 (Corepack) -- A wallet (e.g., MetaMask) -## Setup +Before you begin, please ensure you have the following installed: + +- **Node.js:** v20.0 or higher. +- **Yarn:** v3.x +- A Web3 wallet extension for your browser (e.g., MetaMask). + +## 1. Initial Setup + +Clone the repository and install all dependencies from the root directory. + ```bash git clone https://github.com/swarooppatilx/bug-chan.git cd bug-chan yarn install ``` -## Environments +## 2. Environment Configuration -Frontend: `packages/nextjs/.env` -- NEXT_PUBLIC_LIGHTHOUSE_API_KEY -- NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID -- NEXT_PUBLIC_ALCHEMY_API_KEY +You'll need to set up environment variables for both the Hardhat backend and the Next.js frontend. -Backend: `packages/hardhat/.env` -- ALCHEMY_API_KEY -- ETHERSCAN_V2_API_KEY -- DEPLOYER_PRIVATE_KEY_ENCRYPTED (generated by scripts) +#### Frontend (`packages/nextjs/.env.local`) -Generate/import keys: -```bash -yarn generate -yarn account -yarn account:import -``` +Copy the example file and fill in the required API keys. -## Local development ```bash -yarn chain # start Hardhat -yarn deploy # deploy to localhost and generate ABIs/addresses -yarn deploy --reset # if contarct code is changed -yarn start # start Next.js http://localhost:3000 +cp packages/nextjs/.env.example packages/nextjs/.env.local ``` -Run tests & lint: +- `NEXT_PUBLIC_LIGHTHOUSE_API_KEY`: **Required.** Your API key from [Lighthouse Storage](https://lighthouse.storage/) for uploading and managing encrypted reports on IPFS. +- `NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID`: **Required.** Your project ID from [WalletConnect Cloud](https://cloud.walletconnect.com/). +- `NEXT_PUBLIC_ALCHEMY_API_KEY`: **Required.** Your API key from [Alchemy](https://www.alchemy.com/) for connecting to Ethereum networks. + +#### Backend (`packages/hardhat/.env`) + +Copy the example file. The deployer key will be generated in the next step. + ```bash -yarn test -yarn lint -yarn format +cp packages/hardhat/.env.example packages/hardhat/.env ``` -## Deploy (testnet) +- `ALCHEMY_API_KEY`: **Required.** Your Alchemy API key (can be the same as the frontend one). +- `ETHERSCAN_V2_API_KEY`: **Optional.** Your Etherscan API key, needed for contract verification on testnets/mainnet. +- `DEPLOYER_PRIVATE_KEY_ENCRYPTED`: This will be generated automatically. **Do not fill this in manually.** + +#### Generating Your Deployer Wallet + +From the root of the project, run the `generate` script. You will be prompted to create a password, which will be used to encrypt your new wallet's private key. + ```bash -yarn deploy --network sepolia -# Commit the updated packages/nextjs/contracts/deployedContracts.ts +yarn generate ``` -Host the frontend (Vercel): -- Root Directory: `packages/nextjs` -- Build Command: `yarn build` -- Install Command: `yarn install` -- Add NEXT_PUBLIC_* env vars in Vercel dashboard -- Add VERCEL_PROJECT_PRODUCTION_URL +This command creates a new deployer account and securely saves its encrypted private key to `packages/hardhat/.env`. **Remember your password!** You will need it every time you deploy to a live network. + +You can also import an existing private key using `yarn account:import`. + +## 3. Local Development Workflow + +The local development process involves running three key components in separate terminals. + +1. **Start the Local Blockchain:** + ```bash + yarn chain + ``` + This command starts a local Hardhat node, providing a simulated Ethereum environment for development and testing. + +2. **Deploy Smart Contracts:** + ```bash + yarn deploy + ``` + This script compiles your smart contracts and deploys them to the local Hardhat node. Crucially, it also **automatically generates TypeScript ABI and address files** for the frontend, ensuring your UI is always in sync with your contracts. + +3. **Start the Frontend:** + ```bash + yarn start + ``` + This starts the Next.js development server, accessible at `http://localhost:3000`. The frontend will automatically connect to your local Hardhat node. + +## 4. Testing & Linting + +- **Run Smart Contract Tests:** + ```bash + yarn test + ``` +- **Run Linters:** + ```bash + yarn lint + ``` +- **Format Code:** + ```bash + yarn format + ``` + +A pre-commit hook is configured with Husky to automatically lint and format your code before each commit. + +## 5. Deploying to a Testnet + +1. **Fund Your Deployer Wallet:** Ensure the address generated by `yarn generate` has enough testnet ETH (e.g., Sepolia ETH) to pay for gas fees. +2. **Run the Deploy Command:** + ```bash + yarn deploy --network sepolia + ``` + You will be prompted for the password you created for your encrypted deployer key. +3. **Commit the Contract Artifacts:** After a successful deployment, the `packages/nextjs/contracts/deployedContracts.ts` file will be updated with the new live contract addresses. **You must commit this updated file to your repository.** This ensures that your deployed frontend will interact with the correct contracts. + +## 6. Hosting the Frontend (Vercel) + +To deploy the frontend to Vercel, use the following configuration in your project settings: + +- **Root Directory:** `packages/nextjs` +- **Build Command:** `yarn build` +- **Install Command:** `yarn install` +- **Environment Variables:** Add all the `NEXT_PUBLIC_*` variables from your `.env.local` file to the Vercel dashboard. ## Troubleshooting -- Missing contracts on frontend: re-run `yarn deploy --network ` and commit the updated `deployedContracts.ts`. -- Wallet/connect issues: verify WalletConnect Project ID and RPC availability. -- Lighthouse upload: ensure `NEXT_PUBLIC_LIGHTHOUSE_API_KEY` is set; accept the signature prompt. -- Etherscan verify: set `ETHERSCAN_V2_API_KEY` and confirm network support. + +- **Missing Contracts on Frontend:** If the app shows errors about missing contracts, it means the frontend is out of sync with your deployments. Re-run `yarn deploy` (or `yarn deploy --network `) and ensure the `packages/nextjs/contracts/deployedContracts.ts` file is up to date. +- **Wallet/Connection Issues:** Verify that your `NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID` and `NEXT_PUBLIC_ALCHEMY_API_KEY` are correct and that the RPC service is available. +- **Lighthouse Upload Fails:** Ensure your `NEXT_PUBLIC_LIGHTHOUSE_API_KEY` is correctly set in `.env.local`. You must also approve the signature request from your wallet when prompted to authenticate with Lighthouse. +- **Etherscan Verification Fails:** Make sure your `ETHERSCAN_V2_API_KEY` is set in `packages/hardhat/.env` and that the network you're deploying to is supported by Etherscan. \ No newline at end of file From 5cbf7b23e95dfdbdf493e273cbb89404e83fdd52 Mon Sep 17 00:00:00 2001 From: ChinmayNakwa Date: Sun, 26 Oct 2025 18:31:52 +0530 Subject: [PATCH 2/2] chore: update UI of about page --- packages/nextjs/app/about/page.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/nextjs/app/about/page.tsx b/packages/nextjs/app/about/page.tsx index 548d426..bd3bd2d 100644 --- a/packages/nextjs/app/about/page.tsx +++ b/packages/nextjs/app/about/page.tsx @@ -20,7 +20,7 @@ export const metadata: Metadata = getMetadata({ function Feature({ title, description, children }: { title: string; description?: string; children: React.ReactNode }) { return ( -
+
{children} {title} @@ -45,13 +45,13 @@ export default function AboutPage() {
Start a Program Explore Bounties @@ -91,7 +91,7 @@ export default function AboutPage() {
{/* Technology */} -
+
@@ -116,7 +116,7 @@ export default function AboutPage() { {/* Security Model */}
-
+

Security Model

@@ -128,7 +128,7 @@ export default function AboutPage() {
  • Stake mechanism deters spam submissions.
  • -
    +

    Requirements

    @@ -136,7 +136,12 @@ export default function AboutPage() {
    • Sepolia testnet wallet with ETH for gas fees.
    • - + Install MetaMask
    • @@ -145,7 +150,7 @@ export default function AboutPage() { href="https://cloud.google.com/application/web3/faucet/ethereum/sepolia" target="_blank" rel="noreferrer" - className="underline" + className="underline hover:text-[var(--color-secondary)] transition-colors duration-300" > Get Sepolia ETH @@ -158,7 +163,7 @@ export default function AboutPage() {

      How It Works

      -
      +

      For Project Owners

      @@ -169,7 +174,7 @@ export default function AboutPage() {
    • Close bounty for automatic reward distribution.
    -
    +

    For Researchers

    @@ -184,7 +189,7 @@ export default function AboutPage() {
    {/* Rewards & Incentives */} -
    +

    Rewards & Incentives