This document provides an overview of the Dutch auction marketplace smart contract written in Ink!. A Dutch auction is a type of auction where the price of an asset starts high and gradually decreases over time until a buyer is found or a minimum price is reached.
The smart contract relies on PSP22 implementation.
- Rust programming language with tools installed ([Rust compiler, Cargo package manager](https://doc.rust-lang.org/cargo/getting-started/installation.html))
- Cargo contract (https://github.com/paritytech/cargo-contract)
- Familiarity with smart contract development principles
git clone https://github.com/inkdevhub/dutch_auction.git
cd adutch_auction
cargo contract build --release
cargo test
This smart contract facilitates a Dutch auction for two fungible tokens:
- Asset token: Represents the auctioned assets.
- Payment token: Used by buyers to purchase asset tokens.
- Declining Price: The initial asset price gradually decreases over time until a buyer purchases them, the minimum price is reached or the owner terminates the contract.
- Minimum Price: Serves as a safety net, ending the auction if the decreasing price reaches this point.
- Asset Purchase: Users can dynamically purchase assets with the payment token at the current price.
A brief description of the key components.
Keeps data important for the contract functioning, like current price, minimum price, auction duration, and token addresses.
Emit details to track auction activities, such as ticket purchases, for monitoring and auditing purposes.
- buy_ticket: Allows users to purchase tickets with the ticket token.
- price: Returns the current price of an asset.
- linear_decrease: Takes part in calculating the current asset price.
- Deploy the smart contract, specifying the
asset_token
,andpayment_token
contracts' on chainaccount_id
, assetstart_price
andmin_price
and theend_time
of the auction. - Users can participate in the auction by calling the buy_ticket function, providing the desired amount of tickets.
- The contract automatically calculates the price based on the current auction state and transfers the corresponding reward tokens to the buyer upon successful purchase.
This code serves as a foundational example and requires further enhancements for real-world usage. Consider:
- Security best practices: Implement thorough balance checks, transfer verifications, and access control mechanisms.
- Completeness: Develop functionalities like auction reset and reward token distribution logic.
- Testing and auditing: Rigorously test the contract to identify and address potential vulnerabilities.
This code example is for educational purposes only and should not be used in production environments without proper testing, security audits, and legal considerations.