;; tipstream-affiliates
;; Affiliate program
(define-data-var total-affiliates uint u0)
(define-map affiliates uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (register-affiliate (ref-code uint))
(let
(
(id (var-get total-affiliates))
)
(map-set affiliates id {
creator: tx-sender,
value: ref-code,
at-block: block-height
})
(var-set total-affiliates (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? affiliates id)
)
(define-read-only (get-total)
(ok (var-get total-affiliates))
)