Source Code

;; tipstream-follows
;; Follow system

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

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

(define-public (follow-user (target-id uint))
  (let
    (
      (id (var-get total-follows))
    )
    (map-set follows id {
      creator: tx-sender,
      value: target-id,
      at-block: block-height
    })
    (var-set total-follows (+ id u1))
    (ok id)
  )
)

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

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

Functions (3)

FunctionAccessArgs
follow-userpublictarget-id: uint
get-entryread-onlyid: uint
get-totalread-only