;; charity-box -- neighborhood sadaqah box tracker
(define-data-var box-count uint u0)
(define-data-var total-amount uint u0)
(define-map boxes uint { keeper: principal, location: (string-ascii 30), balance: uint })
(define-public (register-box (location (string-ascii 30)))
(let ((id (+ (var-get box-count) u1)))
(var-set box-count id)
(map-set boxes id { keeper: tx-sender, location: location, balance: u0 }) (ok id)))
(define-public (add-funds (id uint) (amount uint))
(let ((b (unwrap! (map-get? boxes id) (err u404))))
(var-set total-amount (+ (var-get total-amount) amount))
(map-set boxes id (merge b { balance: (+ (get balance b) amount) })) (ok amount)))
(define-read-only (get-box (id uint)) (map-get? boxes id))
(define-read-only (get-total) (var-get total-amount))