LUPA is a Solidity implementation of a sealed-bid auction where the lowest unique bid wins. It uses a commit-reveal scheme to ensure bid privacy and prevent manipulation. The contract implements a specialized auction mechanism where bidders submit sealed bids, and the winner is determined by having the lowest bid amount that no other participant matched.
- Commit-Reveal Scheme: Two-phase bidding process to ensure bid privacy
- Automated Winner Selection: Smart contract automatically determines the lowest unmatched bid
- Deposit System: Required deposits to prevent spam and ensure serious participation
- State Management: Clear auction phases (Bid, Reveal, Finished)
- Security Measures: Built-in protection against common attack vectors
- Gas Optimization: Uses custom errors and efficient data structures
The project consists of three main contracts:
- LUPA.sol: Main auction contract
- SimpleCommit.sol: Library for handling bid commitments
- HashGenerator.sol: Helper contract for generating bid commitments
- Solidity ^0.8.19
- Ethereum development environment (Remix IDE, Hardhat, or Truffle)
- MetaMask or similar Web3 wallet for testing
-
Clone the Repository:
git clone https://github.com/IgorAugust0/tesi.git cd lab/lupa
-
Deploy Contracts:
- Deploy SimpleCommit library first
- Deploy LUPA contract with parameters:
_biddingDuration
: Number of blocks for bidding phase_requiredDeposit
: Minimum deposit amount in wei
// Deploy with 100 blocks duration and 1 ETH deposit requirement
LUPA auction = new LUPA{value: 10 ether}(100, 1 ether);
-
Bidding Phase:
// Generate commitment bytes32 commitment = keccak256(abi.encodePacked(nonce, bidValue)); // Submit bid with required deposit auction.bid{value: 1 ether}(commitment);
-
Reveal Phase:
// Reveal bid auction.revealBid(nonce, bidValue);
-
After Auction:
// Non-winners can withdraw deposits auction.withdrawDeposit();
- Lowest Unmatched Price: The winning bid is the lowest amount that no other bidder matched
- Commit-Reveal: Two-phase process prevents bid manipulation:
- Commit: Submit encrypted bid
- Reveal: Disclose actual bid value
- Deposits: Required to participate, returned to non-winners
DepositReceived
: Tracks received depositsCommitmentStored
: Records bid commitmentsAttemptedReveal
: Logs bid revealsBidCounted
: Tracks bid processingAuctionFinished
: Announces winner
- Sealed bids prevent front-running
- Required deposits prevent spam
- Time-based phases prevent manipulation
- Gas-efficient error handling
- Secure commitment scheme
For detailed testing instructions, please refer to the Testing Guide.
This project is licensed under the GPL-3.0 LICENSE.