-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnot-incinerator.clar
38 lines (29 loc) · 1.36 KB
/
not-incinerator.clar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
;; Constants ;;
(define-constant ERR-ERROR-UNWRAP u400)
(define-constant ERR-ERROR-TRANSFER u401)
(define-constant ERR-YOU-POOR u402) ;; for the culture
(define-constant CONTRACT_OWNER tx-sender)
;; Public variables ;;
(define-data-var tot-burned-amount uint u0)
(define-data-var tot-burns uint u0)
(define-map burns-list uint {maker: principal, amount: uint})
;; Functions ;;
(define-read-only (get-burned-amount)
(ok (var-get tot-burned-amount)))
(define-read-only (get-tot-burns)
(ok (var-get tot-burns)))
(define-read-only (get-burns-list (index uint))
(ok (map-get? burns-list index)))
(define-private (increase-burned-amount (amount uint))
(var-set tot-burned-amount (+ (var-get tot-burned-amount) amount)))
(define-private (increase-tot-burns)
(var-set tot-burns (+ (var-get tot-burns) u1)))
(define-public (burn-nothing (amount uint))
(begin
(asserts! (> amount u0) (err ERR-YOU-POOR))
(unwrap! (contract-call? 'SP32AEEF6WW5Y0NMJ1S8SBSZDAY8R5J32NBZFPKKZ.nope unwrap amount) (err ERR-ERROR-UNWRAP))
(unwrap! (contract-call? 'SP32AEEF6WW5Y0NMJ1S8SBSZDAY8R5J32NBZFPKKZ.micro-nthng transfer (as-contract tx-sender) amount) (err ERR-ERROR-TRANSFER))
(map-insert burns-list (var-get tot-burns) {maker: tx-sender, amount: amount})
(increase-burned-amount amount)
(increase-tot-burns)
(ok true)))