tipstream-staking-v2
SP31PKQVQZVZCK3FM3NH67CGD6G1FMR17VQVS2W5TSource Code
;; tipstream-staking-v2
;; Token staking v2
(define-data-var total-stakes uint u0)
(define-map stakes uint {
creator: principal,
value: uint,
at-block: uint
})
(define-public (stake (tier uint))
(let
(
(id (var-get total-stakes))
)
(map-set stakes id {
creator: tx-sender,
value: tier,
at-block: block-height
})
(var-set total-stakes (+ id u1))
(ok id)
)
)
(define-read-only (get-entry (id uint))
(map-get? stakes id)
)
(define-read-only (get-total)
(ok (var-get total-stakes))
)
Functions (3)
| Function | Access | Args |
|---|---|---|
| stake | public | tier: uint |
| get-entry | read-only | id: uint |
| get-total | read-only |