Skip to content

aryamanm535/ValidNFT

Repository files navigation

ValidNFT Documentation

BACKEND (API) DOCUMENTATION

Configuration & Setup

1. package.json

  • Defines dependencies like express, mongoose, dotenv, etc.
  • Project name updated from "XDC NFT" ➡️ "ValidNFT".

2. .env

  • Stores environment variables: PORT, MONGO_URI, INFURA_API_KEY, etc.
  • No name or color changes here, but critical for setup.

3. config/database.js or db.js

  • Mongoose connection to MongoDB.
  • Infrastructure unchanged, only branding updates.

Core Project Structure (Predicted)

/api
  ├── server.js                # Entry point
  ├── routes/                  # Express route handlers
  ├── controllers/             # Logic for each API route
  ├── models/                  # Mongoose schemas
  ├── middleware/              # Auth, error handling
  └── config/                  # DB and app config

Major Files Changed (Backend)

  • server.js → Updated log/response messages from "XDC NFT" to "ValidNFT"
  • routes/*.js → Adjusted branding text in API endpoints
  • controllers/*.js → Updated JSON responses & log messages
  • models/*.js → Schema definitions & collection names updated
  • README.md → Renamed project description/install instructions

FRONTEND DOCUMENTATION

Key Areas Changed

  • Name: "XDC NFT" ➡️ "ValidNFT"
    • Titles, headers, footers, meta tags, favicon alt text
  • Colors: Purple ➡️ Blue
    • CSS / Tailwind styling
    • Buttons, headers, backgrounds

Frontend Structure

/frontend
  ├── public/                   # Static assets (logos, favicon)
  ├── src/
  │   ├── components/           # UI components
  │   ├── pages/ or views/      # React pages or routes
  │   ├── styles/               # Global CSS or Tailwind config
  │   ├── App.js / App.jsx      # Main component
  │   ├── index.js              # Entry point
  │   └── config.js             # API endpoints, constants

Major Files Changed (Frontend)

  • index.html<title>ValidNFT</title>, updated meta + favicon
  • App.js, Navbar.js, Footer.js, Header.js → Branding updates
  • config.js → Updated constants/network configs
  • *.module.css → Color palette changes
// Tailwind Example
module.exports = {
  theme: {
    extend: {
      colors: {
        primary: '#3B82F6', // blue-500
      }
    }
  }
}
  • public/logo.svg → New branding logo
  • README.md and /docs/ → Updated documentation

Databases cleared for clean deployment.


CONTRACT LOGIC OVERVIEW

  • Network: XDC
  • Tested on: XDC Apothem Testnet
  • Standard: ERC721-compatible (OpenZeppelin-based)

Tech Stack

  • Smart Contracts: Solidity (XRC721 with royalties + pricing)
  • Frontend: React (Material UI, Redux, Web3.js)
  • Backend: Node.js + Express + MongoDB

Smart Contract (XRC721.sol) — Changes Made

Features Implemented

  • ERC721 + Metadata via ERC721URIStorage
  • Royalty Support via ERC2981
  • Ownership Restriction (Ownable)
  • On-chain price mapping

Final Mint Function

function mint(
  string memory tokenURI,
  address royaltyReceiver,
  uint96 royaltyFeeInBips,
  uint256 priceInWei
) public returns (uint256)

Internal Logic

  • Auto-incrementing Token IDs
  • Store tokenURI
  • _setTokenRoyalty() sets royalty details
  • tokenPrices[tokenId] = priceInWei

Modifications Summary

Feature Original After Changes
mint() No price Includes priceInWei
tokenPrices Not defined Added mapping
ABI Updates Static Regenerated
Payable? No Still non-payable

FRONTEND (Create-single.js) — Changes Made

UI Enhancements

  • Full form validation
  • NFT preview section + modals
  • Dynamic price input (supports XDC, BLKZ)
  • Toggles for sale/auction/unlockable

Wallet + Web3 Logic

contract.methods.mint(tokenURI, royaltyReceiver, royaltyFeeInBips, priceInWei)

Mint Flow

  1. Upload file → metadata to IPFS
  2. On success → get tokenURI
  3. Call mint() with metadata + price + royalty
  4. Display success/failure messages

Added Success UI

  • Step-by-step modal: Approve ➜ Mint ➜ (optional) Sign
  • Toast notifications (success, error)

Mint Event Handling

  • Listens for Transfer event
  • Extracts tokenId from logs
  • Pushes minted token to backend DB

BACKEND (MongoDB / Express) — Changes Made

Collections Affected

  • collections → NFT collections
  • tokens → Minted NFT metadata
  • owners → Token ownership & listing

TokenAddItemAction Payload

{
  "Name": "My NFT",
  "ipfsimage": "Qm...",
  "Price": "10",
  "Royalities": "500",
  "Count": 1,
  "Creator": "0x...",
  "ContractAddress": "0x...",
  "collection": "OG Collection"
}

Changes to Support New Mint

  • IPFS metadata stored + saved hash
  • Price field added
  • Royalties stored + enforced
  • getUserCollection() → fetches user NFTs
  • CreateTokenValidationAction() → validates price, royalty %, file size

BEHAVIORAL FLOW

  1. Connect Wallet (MetaMask)
  2. Fill Form → upload media, set royalty %, price, etc.
  3. IPFS Upload → returns ipfsmeta + ipfsimage
  4. Smart Contract → call mint()
  5. Backend Sync → save ownership, metadata, listing
  6. UI Feedback → modal with Approve ➜ Mint ➜ Confirm ➜ Done

VALIDATIONS & LIMITATIONS

Frontend Validation

  • Name must not contain emoji
  • Price > 0, numeric only
  • File size < 30MB
  • Royalties ≤ 20%

Current Limitations

Limitation Reason
Cannot edit minted NFTs No admin update function
Price not enforced on-chain Stored in mapping, read off-chain
Royalty enforcement Depends on marketplace compliance

RECOMMENDATIONS

Security

  • Restrict mint() (admin/onlyOwner optional)
  • Validate royaltyReceiver in frontend

Optimization

  • Compress IPFS images before upload
  • Dropdown for royalties (0%, 5%, 10%, etc.)

Testing


⚙️ Migration Notes

  • To switch XDC ➜ ETH:
    Update network version and chainID fields in config.js

About

NFT Marketplace on the XDC Chain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors