# Dutch Auction (Anchor) In a Dutch auction, the seller sets a starting price. The price decreases over time until the buyer buys. Complete all tasks below - Implement a Dutch auction program - Test locally # Update program id ```shell anchor keys sync ``` # Task 1 - Implement [`init`](https://github.com/Cyfrin/solana-course/blob/main/apps/auction/anchor/exercise/programs/auction/src/lib.rs) - Check sell token != buy token - Check start price >= end price - Check current timestamp <= start time < end time - Check sell amount > 0 - Send sell token to `auction_sell_ata` Call `lib::transfer` to send tokens - Store Auction state # Task 2 - Implement [`buy`](https://github.com/Cyfrin/solana-course/blob/main/apps/auction/anchor/exercise/programs/auction/src/lib.rs) - Check auction has started - Check auction has not ended - Calculate price Price should decrease linearly over time from `start_price` to `end_price`. - Check current price is greater than or equal to `end_price` - Check current price is less than or equal to `max_price` - Calculate amount of buy token to send to seller - Send buy token to seller - Send sell token to buyer Call `lib::transfer_from_pda` to send token to buyer - Close `auction_sell_ata` ```shell close_account(CpiContext::new_with_signer( ctx.accounts.token_program.to_account_info(), CloseAccount { account: ctx.accounts.auction_sell_ata.to_account_info(), destination: ctx.accounts.seller.to_account_info(), authority: ctx.accounts.auction.to_account_info(), }, &[seeds], ))?; ``` # Task 3 - Implement [`cancel`](https://github.com/Cyfrin/solana-course/blob/main/apps/auction/anchor/exercise/programs/auction/src/lib.rs) - Send sell token to seller - Close `auction_sell_ata` # Build ```shell anchor build ``` # Test ```shell anchor test ```
In a Dutch auction, the seller sets a starting price.
The price decreases over time until the buyer buys.
Complete all tasks below
Implement a Dutch auction program
Test locally
initCheck sell token != buy token
Check start price >= end price
Check current timestamp <= start time < end time
Check sell amount > 0
Send sell token to auction_sell_ata
Call lib::transfer to send tokens
Store Auction state
buyCheck auction has started
Check auction has not ended
Calculate price
Price should decrease linearly over time from start_price to end_price.
Check current price is greater than or equal to end_price
Check current price is less than or equal to max_price
Calculate amount of buy token to send to seller
Send buy token to seller
Send sell token to buyer
Call lib::transfer_from_pda to send token to buyer
Close auction_sell_ata
cancelSend sell token to seller
Close auction_sell_ata
A practical guide to Dutch Auction (Anchor) - Engineer a decreasing-price sales contract that utilizes linear time decay logic to determine asset value. Learn to validate complex auction constraints, manage escrowed tokens within Program Derived Addresses, and handle secure settlements involving automated account closures.
Previous lesson
Previous
Next lesson
Next
Course Overview
About the course
Native Rust & Anchor framework
PDAs, CPIs, and SPL Tokens
DeFi builds: oracles, auctions, AMMs
Last updated on January 12, 2026
Rust Developer
SolanaDuration: 8min
Duration: 23min
Duration: 4min
Duration: 2min
Duration: 4min
Duration: 11min
Duration: 4min
Duration: 0min
Duration: 0min
Course Overview
About the course
Native Rust & Anchor framework
PDAs, CPIs, and SPL Tokens
DeFi builds: oracles, auctions, AMMs
Last updated on January 12, 2026