Source Code

;; henna-artist -- henna art booking platform
(define-data-var booking-count uint u0)
(define-map bookings uint { artist: principal, client: principal, style: (string-ascii 20), price: uint, done: bool })
(define-map artists principal bool)
(define-public (register-artist)
  (begin (map-set artists tx-sender true) (ok true)))
(define-public (book-henna (artist principal) (style (string-ascii 20)) (price uint))
  (let ((id (+ (var-get booking-count) u1)))
    (var-set booking-count id)
    (map-set bookings id { artist: artist, client: tx-sender, style: style, price: price, done: false }) (ok id)))
(define-public (complete-booking (id uint))
  (let ((b (unwrap! (map-get? bookings id) (err u404))))
    (map-set bookings id (merge b { done: true })) (ok true)))
(define-read-only (get-booking (id uint)) (map-get? bookings id))

Functions (4)

FunctionAccessArgs
register-artistpublic
book-hennapublicartist: principal, style: (string-ascii 20
complete-bookingpublicid: uint
get-bookingread-onlyid: uint