Application case for the IC blockchain programming workshop at KTH summer school (https://cysep.conf.kth.se/).
A simple auction platform that allows to:
- Open and view auctions
- Bid within defined deadline
- Authenticate by Internet Identity
You can choose from the following programming languages for the implementation:
- Motoko (recommended)
- Typescript (code name Azle on the IC)
- Rust
Running the application:
dfx start --clean --background
npm run setup
npm start
Local frontend: http://localhost:3000/
You can focus on the backend development:
- For Motoko:
src/motoko_backend/AuctionServer.mo
- For Typescript:
src/typescript_backend/src/index.ts
- For Rust:
src/rust_backend/src/lib.rs
Functionality to add:
- Storing and retrieving the auction data in the actor.
- Implementing the public functions of the actor.
- Associating an id (
Nat
) to each stored auction for later retrievel. - Using a periodic timer (library
mo:base/Timer
,Timer.recurringTimer
) to terminate the auctions. For example, a second-interval-timer could decrement the remaining time of each open auction.
Particular checks needed for a bid:
- The auction must not be ended.
- The price needs to be higher than the last bid (or it needs to be the first bid).
- The user needs to be authenticated, i.e. it is not anonymous (using
Principal.isAnonymous()
).
Optional: Support canister upgrades:
- In Motoko: Use
stable
variables in the actor. - In Rust/Typescript: This is more complicated. See the documentation for "stable data structures".
- IC Blockchain Programming Tutorial Slides
- Motoko Language
- Motoko Base Library
- TypeScript Development Kit for IC (Azle)
- Rust Development Kit for IC
- An example solution with a working backend implementation in Motoko, Typescript, and Rust is available in the Git branch
solution
. (Note: The Rust and Typescript backend do not yet support canister upgrades.)