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.
- 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.
Ensure you have the following installed on your system:
- Node.js (version 14 or higher)
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/yourusername/p2p-auction.git cd p2p-auction
-
Install the required dependencies:
npm install
The application is designed to be run in multiple terminal tabs, where each tab represents a different node in the P2P network.
-
Start the hyperdht:
hyperdht --bootstrap --host 127.0.0.1 --port 30001
-
Start the first node:
npm start
Follow the prompts to open an auction, place a bid, close an auction, or list all auctions.
- 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.
When you start the application, you will be presented with the following options:
-
Open an auction: Opens a new auction for a specified item with an opening price.
-
Place a bid: Places a bid on an existing auction. The bid must be higher than the last bid or the opening price.
-
Close an auction: Closes an auction, but only the creator of the auction can perform this action.
-
Show all auctions: Displays a list of all auctions stored locally on the node.
-
Exit: Exits the application.
- Open an Auction:
- Enter the item you want to auction (e.g., "Artwork").
- Enter the opening price (e.g., "100").
- 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.
- Close an Auction:
- Enter the auction ID to close. Only the auction creator can close the auction.
- List Auctions:
- View all current auctions, including their item name, bids, and status.
Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss any changes or improvements.