Source Code

;; tipstream-polls
;; Community polls

(define-data-var total-polls uint u0)

(define-map polls uint {
  creator: principal,
  value: uint,
  at-block: uint
})

(define-public (create-poll (poll-type uint))
  (let
    (
      (id (var-get total-polls))
    )
    (map-set polls id {
      creator: tx-sender,
      value: poll-type,
      at-block: block-height
    })
    (var-set total-polls (+ id u1))
    (ok id)
  )
)

(define-read-only (get-entry (id uint))
  (map-get? polls id)
)

(define-read-only (get-total)
  (ok (var-get total-polls))
)

Functions (3)

FunctionAccessArgs
create-pollpublicpoll-type: uint
get-entryread-onlyid: uint
get-totalread-only