Skip to main content

Running the Project

Get 5BLOCK running on your local machine.


Prerequisites

Before you begin, ensure you have:

  • Node.js 18+ - Download
  • pnpm - Install with npm install -g pnpm
  • MetaMask - Browser extension for wallet management

Installation

1. Clone and Install

git clone https://github.com/naikibro/5BLOCK.git
cd 5block
pnpm install

2. Start Local Blockchain

Open a terminal and run:

pnpm run node

This starts a local Hardhat node at http://127.0.0.1:8545.

Keep this terminal open - it's your local blockchain.

3. Deploy Contracts

In a new terminal, deploy the smart contracts:

pnpm run deploy:local

Copy the displayed contract addresses - you'll need them for the frontend.

4. Configure Frontend

Navigate to the frontend directory:

cd frontend

Create a .env.local file:

NEXT_PUBLIC_POKEMON_CARDS_ADDRESS=<paste_contract_address>
PINATA_JWT=skip

Install dependencies and start:

pnpm install
pnpm dev

The app will be available at http://localhost:3000.


MetaMask Setup

Add Hardhat Network

  1. Open MetaMask
  2. Click the network dropdown
  3. Select "Add Network"
  4. Enter these details:
FieldValue
Network NameHardhat Local
RPC URLhttp://127.0.0.1:8545
Chain ID31337
Currency SymbolETH

Import Test Account

Hardhat provides test accounts with 10,000 ETH each. Import one:

  1. In MetaMask, click your account icon
  2. Select "Import Account"
  3. Paste a private key from the Hardhat node output

Available Commands

CommandDescription
pnpm run nodeStart Hardhat local node
pnpm run deploy:localDeploy to local node
pnpm run deploy:sepoliaDeploy to Sepolia testnet
pnpm testRun contract tests
cd frontend && pnpm devStart frontend dev server

App Routes

RouteDescription
/Home & wallet connection
/catalogBrowse and mint cards
/inventoryYour collection
/tradeMarketplace

Troubleshooting

MetaMask shows wrong nonce

Reset your account in MetaMask: Settings > Advanced > Reset Account

Contracts not found

Ensure the contract address in .env.local matches the deployed address.

Transaction fails

Check that you're connected to the correct network (Hardhat Local or Sepolia).