Source 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)

FunctionAccessArgs
update-scorepublicscore: uint
get-entryread-onlyid: uint
get-totalread-only