Source Code

;; fig-farm -- halal fig farming cooperative
(define-data-var harvest-count uint u0)
(define-data-var total-kg uint u0)
(define-map harvests uint { farmer: principal, variety: (string-ascii 20), kg: uint, season: (string-ascii 10), block: uint })
(define-public (log-harvest (variety (string-ascii 20)) (kg uint) (season (string-ascii 10)))
  (let ((id (+ (var-get harvest-count) u1)))
    (var-set harvest-count id)
    (var-set total-kg (+ (var-get total-kg) kg))
    (map-set harvests id { farmer: tx-sender, variety: variety, kg: kg, season: season, block: stacks-block-height }) (ok id)))
(define-read-only (get-harvest (id uint)) (map-get? harvests id))
(define-read-only (get-total-kg) (var-get total-kg))

Functions (3)

FunctionAccessArgs
log-harvestpublicvariety: (string-ascii 20
get-harvestread-onlyid: uint
get-total-kgread-only