Skip to content

MathisDulieu/ChainForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChainForge — Web3 RPG Forge DApp

ChainForge is a Web3 decentralized application developed as part of the 5BLOC – Advance Your Skills in the Blockchain program.

The application allows users to own, manage, and forge weapon NFTs on the Ethereum blockchain.
Weapons are implemented as ERC-721 tokens, forged through a gameplay mechanic where four weapons of the same tier can be burned to create a stronger one.

The smart contract is deployed on Ethereum Sepolia, metadata and images are stored on IPFS, and the frontend is built with Next.js.


Project Overview

ChainForge combines blockchain fundamentals with a simple RPG-style forging system:

  • Each weapon is an NFT with a tier and damage value
  • Players can hold a limited number of weapons
  • Weapons can be forged into higher-tier weapons
  • Forging burns existing NFTs and mints a new one
  • Metadata and images are decentralized via IPFS

This project demonstrates smart contract development, frontend Web3 integration, and decentralized storage usage.


Features

  • ERC-721 NFT smart contract based on OpenZeppelin
  • Weapon tiers with increasing damage
  • Forge mechanism (burn 4 weapons → mint 1 higher-tier weapon)
  • Cooldown and lock system to prevent abuse
  • Wallet connection using MetaMask / WalletConnect
  • Fully on-chain inventory
  • IPFS-hosted metadata and images
  • Modern Web3 frontend with Next.js and TailwindCSS
  • Automated tests with Hardhat

Weapon Tiers

Tier Name Damage
0 Bronze 10
1 Silver 25
2 Gold 50
3 Platinum 100

Technology Stack

Blockchain

  • Solidity
  • Hardhat
  • OpenZeppelin Contracts
  • Ethereum Sepolia Testnet

Frontend

  • Next.js
  • React
  • TailwindCSS
  • wagmi
  • RainbowKit
  • viem

Storage

  • IPFS
  • Pinata

Prerequisites

Before running or deploying this project, you must have the following:

1. Node.js and npm

  • Node.js version 18 or higher
  • npm (comes with Node.js)

Check installation: node -v npm -v


2. MetaMask Wallet (Required)

A MetaMask account is mandatory to interact with the application.

You must:

  • Install the MetaMask browser extension
  • Create or import a wallet
  • Enable test networks
  • Switch to Sepolia test network

MetaMask Chrome extension: https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn


3. SepoliaETH (Test ETH)

You need SepoliaETH to deploy the contract and interact with it (minting, forging).

You can obtain SepoliaETH using one of the following methods:

Option A — Mining Faucet

You can mine SepoliaETH using this faucet: https://sepolia-faucet.pk910.de/#/mine/2aeba069-3eea-4ef8-9a67-de5d033d83c8

This method requires leaving the browser open while mining.

Option B — Google Cloud Faucet

You can request SepoliaETH here: https://cloud.google.com/application/web3/faucet/ethereum/sepolia

This method requires a Google account.


Installation

Clone the repository and install dependencies:

git clone https://github.com/MathisDulieu/ChainForge.git cd chainforge-project npm install

Then install frontend dependencies:

cd frontend npm install


Smart Contract Deployment

Environment Variables (Root)

Create a .env file at the project root:

SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY PRIVATE_KEY=0xYOUR_PRIVATE_KEY

The private key must belong to your MetaMask test account.


Compile and Deploy

npx hardhat compile npx hardhat run scripts/deploy.js --network sepolia

After deployment, copy the contract address.


Frontend Configuration

Create frontend/.env.local:

NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=YOUR_PROJECT_ID NEXT_PUBLIC_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY NEXT_PUBLIC_CHAIN_ID=11155111 NEXT_PUBLIC_IPFS_GATEWAY=https://gateway.pinata.cloud/ipfs/ NEXT_PUBLIC_CONTRACT_ADDRESS=DEPLOYED_CONTRACT_ADDRESS


Running the Frontend Locally

cd frontend npm run dev

Open: http://localhost:3000


Minting Weapons

Only the contract owner can mint weapons.

Run the mint script:

npx hardhat run scripts/mint.js --network sepolia

This will mint initial Bronze weapons using IPFS metadata.


Testing

Smart contract tests are written using Hardhat and Chai.

Run tests:

npx hardhat test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published