tipstream-lottery
SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5TSource Code
;; tipstream-lottery
;; Tip lottery
(define-data-var total-entries uint u0)
(define-map entries uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (enter-lottery (ticket-type uint))
(let
(
(id (var-get total-entries))
)
(map-set entries id {
creator: tx-sender,
value: ticket-type,
at-block: block-height
})
(var-set total-entries (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? entries id)
)
(define-read-only (get-total)
(ok (var-get total-entries))
)
Functions (3)
| Function | Access | Args |
|---|---|---|
| enter-lottery | public | ticket-type: uint |
| get-entry | read-only | id: uint |
| get-total | read-only |