An NFT and token auction system with precise timing, anti-sniping protection, and reserve prices, built with Clarity 4.
✅ Clarity 4 compatible (Epoch 3.3) ✅ All tests passing (8 comprehensive test cases) ✅ Deployed and verified on testnet ✅ Event logging for monitoring (5 event types) ✅ Best practices .gitignore ✅ Comprehensive documentation
Contract Address: ST384CVPNDTYA0E92TKJZQTYXQHNZSWGCAH0ER64E.time-auction
Transaction ID: 0xd722f1f5bb56d792ca172a2beb864ad7da9c4a2f1ad572fcaff3521b4acdd4e3
Block Height: 3,701,471
Network: Stacks Testnet
Explorer Links:
| Feature | Usage |
|---|---|
stacks-block-time |
Precise auction start/end timing |
to-ascii? |
Generate human-readable bid receipts |
print |
Event logging (5 event types) |
┌─────────────────────────────────────────────────────────────┐
│ Time-Based Auction │
├─────────────────────────────────────────────────────────────┤
│ │
│ Create Auction → Accept Bids → Auto-Extend → Settle │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ stacks-block-time │ │
│ │ (Real-time auction management) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌───────────┐ ┌───────────┐ ┌───────────────┐ │
│ │ Start │ │ Bid │ │ Anti-Snipe │ │
│ │ Time │ │ Tracking │ │ Extension │ │
│ └───────────┘ └───────────┘ └───────────────┘ │
│ │
│ Features: │
│ • 1 hour min to 30 day max duration │
│ • 10 minute anti-sniping extension │
│ • Reserve price protection │
│ • Automatic bid refunds │
│ │
└─────────────────────────────────────────────────────────────┘
cd 06-time-auction
clarinet check
clarinet test
clarinet console;; Create an auction (1 day duration)
(contract-call? .time-auction create-auction
"NFT" ;; item type
u1 ;; item ID
u100000000 ;; starting price (100 STX)
u150000000 ;; reserve price (150 STX)
u10000000 ;; min increment (10 STX)
u86400) ;; duration (1 day in seconds)
;; Place a bid
(contract-call? .time-auction place-bid u1 u100000000)
;; Check time remaining
(contract-call? .time-auction get-time-remaining u1)
;; Get minimum next bid
(contract-call? .time-auction get-minimum-bid u1)
;; Settle auction after it ends
(contract-call? .time-auction settle-auction u1)| Function | Description |
|---|---|
create-auction |
Create a new timed auction |
place-bid |
Place a bid (auto-refunds previous) |
settle-auction |
Settle after auction ends |
cancel-auction |
Cancel if no bids yet |
| Function | Description |
|---|---|
get-auction |
Get auction details |
get-time-remaining |
Seconds until auction ends |
is-auction-active |
Check if bidding is open |
get-minimum-bid |
Get minimum valid bid amount |
generate-bid-receipt |
Human-readable receipt |
If a bid is placed within 10 minutes of auction end, the auction automatically extends by 10 minutes. This prevents last-second sniping and ensures fair bidding.
Sellers can set a reserve price. If the highest bid doesn't meet the reserve, the item is returned to the seller and the bidder is refunded.
When outbid, the previous highest bidder is automatically refunded from escrow.
| Parameter | Value |
|---|---|
| Minimum Duration | 1 hour |
| Maximum Duration | 30 days |
| Extension Time | 10 minutes |
| Extension Threshold | 10 minutes before end |
- ✅
stacks-block-timefor auction timing - ✅
to-ascii?for bid receipts - ✅ Anti-sniping mechanism
- ✅ Complete auction lifecycle
- ✅ Production-ready system
MIT License