tipstream-leaderboard
SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5TSource Code
;; tipstream-leaderboard
;; Leaderboard rankings
(define-data-var total-scores uint u0)
(define-map scores uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (update-score (score uint))
(let
(
(id (var-get total-scores))
)
(map-set scores id {
creator: tx-sender,
value: score,
at-block: block-height
})
(var-set total-scores (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? scores id)
)
(define-read-only (get-total)
(ok (var-get total-scores))
)
Functions (3)
| Function | Access | Args |
|---|---|---|
| update-score | public | score: uint |
| get-entry | read-only | id: uint |
| get-total | read-only |