tipstream-favorites
SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5TSource Code
;; tipstream-favorites
;; Favorite users
(define-data-var total-favs uint u0)
(define-map favorites uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (add-favorite (user-id uint))
(let
(
(id (var-get total-favs))
)
(map-set favorites id {
creator: tx-sender,
value: user-id,
at-block: block-height
})
(var-set total-favs (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? favorites id)
)
(define-read-only (get-total)
(ok (var-get total-favs))
)
Functions (3)
| Function | Access | Args |
|---|---|---|
| add-favorite | public | user-id: uint |
| get-entry | read-only | id: uint |
| get-total | read-only |