No pitfalls are highlighted in the tests for this example.
API Reference
Overview
Dutch auction with descending price and encrypted reserve.
Developer Notes
Example for fhEVM Examples - Auctions Category
In a Dutch auction, the price starts high and decreases over time. The first bidder to accept the current price wins. The reserve price is encrypted so bidders cannot know the seller's minimum.
seller
The seller receiving payment
paymentToken
Confidential payment token
nftContract
NFT contract for the prize
tokenId
Token ID of the prize
prizeDeposited
Whether the prize has been deposited
auctionStartTime
Auction timing
auctionEndTime
Auction end timestamp
startingPrice
Price parameters (cleartext for price calculation)
priceDecrement
Price decrement per interval
decrementInterval
Seconds between price decrements
winner
Winner address (set when auction completes)
finalPrice
Final sale price
TooEarlyError
TooLateError
InvalidAuctionTime
PrizeNotDeposited
PrizeAlreadyDeposited
OnlySeller
AuctionAlreadyEnded
BidTooLow
ReservePriceNotSet
onlyDuringAuction
getCurrentPrice
Calculate the current price based on elapsed time.
Return Values
Name
Type
Description
[0]
uint256
The current asking price
constructor
Create a Dutch auction.
Parameters
Name
Type
Description
nftContractAddress
address
ERC721 prize contract
paymentTokenAddress
address
ERC7984 payment token
prizeTokenId
uint256
Token ID of the prize
startTime
uint256
Auction start timestamp
endTime
uint256
Auction end timestamp
startPrice
uint256
Starting price (highest)
decrement
uint256
Price decrease per interval
interval
uint256
Seconds between price decreases
depositPrize
Deposit the NFT prize into the auction.
setReservePrice
Set the encrypted reserve price (seller only).
Parameters
Name
Type
Description
encReserve
externalEuint64
Encrypted reserve price handle
inputProof
bytes
Proof for the encrypted input
buy
Accept the current price and buy the item.
Uses FHE.select to handle reserve price check without revealing it. The bid succeeds only if current price >= reserve price.