;; tipstream-insurance
;; Tip insurance
(define-data-var total-policies uint u0)
(define-map policies uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (buy-insurance (coverage uint))
(let
(
(id (var-get total-policies))
)
(map-set policies id {
creator: tx-sender,
value: coverage,
at-block: block-height
})
(var-set total-policies (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? policies id)
)
(define-read-only (get-total)
(ok (var-get total-policies))
)