Skip to content

A decentralized peer-to-peer (P2P) auction system.

Notifications You must be signed in to change notification settings

cynic123/p2p-auction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P2P Auction System

This project is a decentralized peer-to-peer (P2P) auction system implemented using Hyperswarm, Hypercore, and Hyperbee. The system allows users to open auctions, place bids, and close auctions in a distributed manner. Each node in the network acts as both a server and a client, enabling seamless communication and data synchronization between peers.

Features

  • Decentralized Architecture: The system uses a P2P architecture where each node is both a server and a client. There is no central server.
  • Auction Management: Users can open auctions with an item and an opening price. Auctions can be bid on, and only the creator of the auction can close it.
  • Bid Placement: Users can place bids on open auctions. Each bid must be higher than the previous one or the opening price.
  • Event Propagation: Auction creation, bid placements, and auction closure events are propagated across all connected nodes.

Getting Started

Prerequisites

Ensure you have the following installed on your system:

  • Node.js (version 14 or higher)
  • npm (Node Package Manager)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/p2p-auction.git
    cd p2p-auction
  2. Install the required dependencies:

    npm install
    

Running the Application

The application is designed to be run in multiple terminal tabs, where each tab represents a different node in the P2P network.

  1. Start the hyperdht:

    hyperdht --bootstrap --host 127.0.0.1 --port 30001 
    
  2. Start the first node:

    npm start
    

         Follow the prompts to open an auction, place a bid, close an auction, or list all auctions.

  1. Start additional nodes:
    Open a new terminal tab or window and repeat the npm start command to start additional nodes. These nodes will automatically connect to each other.

Usage

When you start the application, you will be presented with the following options:

  1. Open an auction: Opens a new auction for a specified item with an opening price.

  2. Place a bid: Places a bid on an existing auction. The bid must be higher than the last bid or the opening price.

  3. Close an auction: Closes an auction, but only the creator of the auction can perform this action.

  4. Show all auctions: Displays a list of all auctions stored locally on the node.

  5. Exit: Exits the application.

Example Workflow

  1. Open an Auction:
    • Enter the item you want to auction (e.g., "Artwork").
    • Enter the opening price (e.g., "100").
  2. Place a Bid:
    • Enter the auction ID you want to bid on.
    • Enter your bid amount. It must be higher than the current highest bid or the opening price.
  3. Close an Auction:
    • Enter the auction ID to close. Only the auction creator can close the auction.
  4. List Auctions:
    • View all current auctions, including their item name, bids, and status.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss any changes or improvements.

Releases

No releases published

Packages

No packages published