Skip to content

kairos1205/NFT-Auction-Marketplace

Repository files navigation

🎨 Ethereum NFT Digital Art Auction Marketplace

A censorship-resistant NFT auction marketplace that lets anyone upload digital art to IPFS, auction it, and tokenize it as an ERC-721 NFT ($ART) — all without centralized control.


⚙️ Prerequisites

Install all dependencies:

npm install

Required packages:

  • ipfs-http-client@^49.0.2

Solidity compiler version:

  • ^0.6.3

🚀 How to Run the DApp

  1. Connect your MetaMask wallet to Rinkeby Testnet

  2. Start the development server:

    npm run start

🖼️ How It Works

This DApp allows users to:

  • Upload digital artwork to IPFS
  • Start an on-chain auction for the art
  • Set custom auction rules (price, increment, duration)
  • Once sold, mint the artwork as an ERC-721 NFT ($ART)

🛠️ Auction Parameters

When starting an auction, the seller must specify:

  • price: Minimum starting price
  • _bidIncrement: Fixed minimum increment for new bids (prevents spam bidding and bots)
  • tokenURI: IPFS CID hash for the artwork

🆔 Token IDs

There are two types of token IDs tracked:

  • _tokenIds: Unique IDs for tokenized (minted) images
  • _artItemIds: Unique IDs for artworks listed for auction (not yet tokenized)

🧠 Smart Contract Logic

Each artwork's bidding data is mapped as:

mapping(uint256 => mapping(address => uint256)) public fundsByBidder;

Art Item Struct

struct ArtItem {
    address payable seller;
    uint256 minbid;
    string tokenURI;
    bool exists;
    uint bidIncrement;
    uint time;
    uint timePeriod;
    bool cancelled;
    bool auctionstarted;
}

Bidding Struct

struct bidding {
    uint highestBindingBid;
    address payable highestBidder;
}

📈 Bidding Logic Explained

There are two types of bid amounts tracked:

  • highestBid: The max bid submitted
  • highestBindingBid: The max bid that counts (based on increment logic)

Example Scenario

Action Value
Starting price 10 ETH
Bid increment 1 ETH
Bidder A bids 15 ETH
highestBid 15 ETH
highestBindingBid 11 ETH

If Bidder B later bids 12 ETH, Bidder A’s new highestBindingBid becomes 13 ETH, maintaining a fair lead.

When the auction ends, the NFT is minted for the highestBindingBid, and any excess ETH is refunded to the highest bidder.

Bidding Protections

  • Overbidding oneself is prevented
  • Underbidding against the current highestBindingBid is disallowed
  • Edge cases for tied bids or late entries are handled

🔐 Withdrawal Function

This contract uses the withdrawal pattern to securely allow bidders to withdraw excess funds, reducing the risk of reentrancy attacks:

function withdraw() public {
    // safely withdraw user’s available balance
}

🛡️ Censorship Resistance

  • The contract is fully decentralized, with no owner
  • Anyone can list, bid, or mint artwork
  • All art metadata is stored on IPFS
  • Even if the frontend is shut down, the smart contract remains functional and accessible via direct interaction (e.g., Etherscan or scripts)

🧪 Tests

Run a local development environment (e.g., Ganache):

truffle migrate
truffle test

📝 Summary

  • Upload → Auction → Mint → Trade — fully decentralized.
  • Auction is governed by transparent rules and protected from spam or manipulation.
  • IPFS + Ethereum ensures that neither your art nor your marketplace can be taken down.