;; soap-craft -- halal handmade soap workshop
(define-data-var soap-count uint u0)
(define-map soaps uint { maker: principal, scent: (string-ascii 20), weight-g: uint, price: uint, sold: bool })
(define-public (list-soap (scent (string-ascii 20)) (weight-g uint) (price uint))
(let ((id (+ (var-get soap-count) u1)))
(var-set soap-count id)
(map-set soaps id { maker: tx-sender, scent: scent, weight-g: weight-g, price: price, sold: false }) (ok id)))
(define-public (buy-soap (id uint))
(let ((s (unwrap! (map-get? soaps id) (err u404))))
(map-set soaps id (merge s { sold: true })) (ok true)))
(define-read-only (get-soap (id uint)) (map-get? soaps id))
(define-read-only (get-count) (var-get soap-count))