Skip to content

Sandijigs/time-auction-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⏰ Time-Based Auction System

An NFT and token auction system with precise timing, anti-sniping protection, and reserve prices, built with Clarity 4.

✅ Project Status

Clarity 4 compatible (Epoch 3.3) ✅ All tests passing (8 comprehensive test cases) ✅ Deployed and verified on testnetEvent logging for monitoring (5 event types) ✅ Best practices .gitignoreComprehensive documentation

🚀 Testnet Deployment

Contract Address: ST384CVPNDTYA0E92TKJZQTYXQHNZSWGCAH0ER64E.time-auction

Transaction ID: 0xd722f1f5bb56d792ca172a2beb864ad7da9c4a2f1ad572fcaff3521b4acdd4e3

Block Height: 3,701,471

Network: Stacks Testnet

Explorer Links:

🎯 Clarity 4 Features Used

Feature Usage
stacks-block-time Precise auction start/end timing
to-ascii? Generate human-readable bid receipts
print Event logging (5 event types)

🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                   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                                  │
│                                                             │
└─────────────────────────────────────────────────────────────┘

🚀 Quick Start

cd 06-time-auction
clarinet check
clarinet test
clarinet console

Console Examples

;; 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)

📋 Contract Functions

Auction Management

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

Read-Only Functions

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

💡 Key Features

Anti-Sniping Protection

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.

Reserve Price

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.

Automatic Refunds

When outbid, the previous highest bidder is automatically refunded from escrow.

Time Constants

Parameter Value
Minimum Duration 1 hour
Maximum Duration 30 days
Extension Time 10 minutes
Extension Threshold 10 minutes before end

🏆 Builder Challenge Points

  • stacks-block-time for auction timing
  • to-ascii? for bid receipts
  • ✅ Anti-sniping mechanism
  • ✅ Complete auction lifecycle
  • ✅ Production-ready system

📜 License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published