Skip to content

Commit 7889d4a

Browse files
committed
update
1 parent 870aa5a commit 7889d4a

File tree

1,066 files changed

+177213
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,066 files changed

+177213
-12
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
;; sip-010-trait-ft-standard-v-1-1
3+
4+
(define-trait sip-010-trait
5+
(
6+
(transfer (uint principal principal (optional (buff 34))) (response bool uint))
7+
(get-name () (response (string-ascii 32) uint))
8+
(get-symbol () (response (string-ascii 32) uint))
9+
(get-decimals () (response uint uint))
10+
(get-balance (principal) (response uint uint))
11+
(get-total-supply () (response uint uint))
12+
(get-token-uri () (response (optional (string-utf8 256)) uint))
13+
)
14+
)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
;; token-stx-v-1-1
3+
4+
(impl-trait .sip-010-trait-ft-standard-v-1-1.sip-010-trait)
5+
6+
(define-constant ERR_NOT_AUTHORIZED (err u1001))
7+
(define-constant ERR_INVALID_AMOUNT (err u1002))
8+
(define-constant ERR_INVALID_PRINCIPAL (err u1003))
9+
(define-constant ERR_INVALID_TOKEN_URI (err u3008))
10+
11+
(define-data-var token-uri (string-utf8 256) u"")
12+
13+
(define-data-var contract-owner principal tx-sender)
14+
15+
(define-read-only (get-name)
16+
(ok "Stacks")
17+
)
18+
19+
(define-read-only (get-symbol)
20+
(ok "STX")
21+
)
22+
23+
(define-read-only (get-decimals)
24+
(ok u6)
25+
)
26+
27+
(define-read-only (get-total-supply)
28+
(ok stx-liquid-supply)
29+
)
30+
31+
(define-read-only (get-balance (address principal))
32+
(ok (stx-get-balance address))
33+
)
34+
35+
(define-read-only (get-token-uri)
36+
(ok (some (var-get token-uri)))
37+
)
38+
39+
(define-read-only (get-contract-owner)
40+
(ok (var-get contract-owner))
41+
)
42+
43+
(define-public (set-token-uri (uri (string-utf8 256)))
44+
(let (
45+
(caller tx-sender)
46+
)
47+
(begin
48+
(asserts! (is-eq caller (var-get contract-owner)) ERR_NOT_AUTHORIZED)
49+
(asserts! (> (len uri) u0) ERR_INVALID_TOKEN_URI)
50+
(var-set token-uri uri)
51+
(print {action: "set-token-uri", caller: caller, data: {uri: uri}})
52+
(ok true)
53+
)
54+
)
55+
)
56+
57+
(define-public (set-contract-owner (address principal))
58+
(let (
59+
(caller tx-sender)
60+
)
61+
(begin
62+
(asserts! (is-eq caller (var-get contract-owner)) ERR_NOT_AUTHORIZED)
63+
(asserts! (is-standard address) ERR_INVALID_PRINCIPAL)
64+
(var-set contract-owner address)
65+
(print {action: "set-contract-owner", caller: caller, data: {address: address}})
66+
(ok true)
67+
)
68+
)
69+
)
70+
71+
(define-public (transfer
72+
(amount uint)
73+
(sender principal) (recipient principal)
74+
(memo (optional (buff 34)))
75+
)
76+
(let (
77+
(caller tx-sender)
78+
)
79+
(begin
80+
(asserts! (is-eq caller sender) ERR_NOT_AUTHORIZED)
81+
(asserts! (is-standard sender) ERR_INVALID_PRINCIPAL)
82+
(asserts! (is-standard recipient) ERR_INVALID_PRINCIPAL)
83+
(asserts! (> amount u0) ERR_INVALID_AMOUNT)
84+
(try! (stx-transfer? amount sender recipient))
85+
(match memo to-print (print to-print) 0x)
86+
(print {
87+
action: "transfer",
88+
caller: caller,
89+
data: {
90+
sender: sender,
91+
recipient: recipient,
92+
amount: amount,
93+
memo: memo
94+
}
95+
})
96+
(ok true)
97+
)
98+
)
99+
)

0 commit comments

Comments
 (0)