mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-04-29 13:15:32 +08:00
chore: backup testnet contracts
This commit is contained in:
45
test-app/contracts/rocket-token.clar
Normal file
45
test-app/contracts/rocket-token.clar
Normal file
@@ -0,0 +1,45 @@
|
||||
(impl-trait 'ST2PABAF9FTAJYNFZH93XENAJ8FVY99RRM4DF2YCW.sip-10-ft-standard.ft-trait)
|
||||
|
||||
;;;; Rocket-Token
|
||||
|
||||
(define-fungible-token rocket-token)
|
||||
|
||||
(define-constant err-min-transfer u10)
|
||||
|
||||
(define-public (get-total-supply)
|
||||
(ok (ft-get-supply rocket-token))
|
||||
)
|
||||
|
||||
(define-read-only (get-balance (account principal))
|
||||
(ok
|
||||
(ft-get-balance rocket-token account)
|
||||
)
|
||||
)
|
||||
|
||||
(define-read-only (get-decimals) (ok u0))
|
||||
|
||||
(define-read-only (get-name) (ok "Rocket Token"))
|
||||
|
||||
(define-read-only (get-symbol) (ok "RKT"))
|
||||
|
||||
(define-read-only (get-token-uri) (ok none))
|
||||
|
||||
(define-public (transfer (amount uint) (sender principal) (receiver principal))
|
||||
(begin
|
||||
(if (> amount u0)
|
||||
(match (ft-transfer? rocket-token amount sender receiver)
|
||||
success (ok success)
|
||||
error (err (+ err-min-transfer error)))
|
||||
(err err-min-transfer)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define-public (buy (amount uint))
|
||||
(match (stx-burn? amount tx-sender)
|
||||
success (ft-mint? rocket-token amount tx-sender)
|
||||
error (err error)))
|
||||
|
||||
;; Initialize the contract
|
||||
(ft-mint? rocket-token u20 'ST33GW755MQQP6FZ58S423JJ23GBKK5ZKH3MGR55N) ;; alice
|
||||
(ft-mint? rocket-token u10 'ST33GW755MQQP6FZ58S423JJ23GBKK5ZKH3MGR55N) ;; bob
|
||||
26
test-app/contracts/sip-010-old.clar
Normal file
26
test-app/contracts/sip-010-old.clar
Normal file
@@ -0,0 +1,26 @@
|
||||
;; THIS IS OUTDATED
|
||||
;; does not contain memo
|
||||
(define-trait ft-trait
|
||||
(
|
||||
;; Transfer from the caller to a new principal
|
||||
(transfer (uint principal principal) (response bool uint))
|
||||
|
||||
;; the human readable name of the token
|
||||
(get-name () (response (string-ascii 32) uint))
|
||||
|
||||
;; the ticker symbol, or empty if none
|
||||
(get-symbol () (response (string-ascii 32) uint))
|
||||
|
||||
;; the number of decimals used, e.g. 6 would mean 1_000_000 represents 1 token
|
||||
(get-decimals () (response uint uint))
|
||||
|
||||
;; the balance of the passed principal
|
||||
(get-balance (principal) (response uint uint))
|
||||
|
||||
;; the current total supply (which does not need to be a constant)
|
||||
(get-total-supply () (response uint uint))
|
||||
|
||||
;; an optional URI that represents metadata of this token
|
||||
(get-token-uri () (response (optional (string-utf8 256)) uint))
|
||||
)
|
||||
)
|
||||
24
test-app/contracts/sip-010-trait.clar
Normal file
24
test-app/contracts/sip-010-trait.clar
Normal file
@@ -0,0 +1,24 @@
|
||||
(define-trait sip-010-trait
|
||||
(
|
||||
;; Transfer from the caller to a new principal
|
||||
(transfer (uint principal principal (optional (buff 34))) (response bool uint))
|
||||
|
||||
;; the human readable name of the token
|
||||
(get-name () (response (string-ascii 32) uint))
|
||||
|
||||
;; the ticker symbol, or empty if none
|
||||
(get-symbol () (response (string-ascii 32) uint))
|
||||
|
||||
;; the number of decimals used, e.g. 6 would mean 1_000_000 represents 1 token
|
||||
(get-decimals () (response uint uint))
|
||||
|
||||
;; the balance of the passed principal
|
||||
(get-balance (principal) (response uint uint))
|
||||
|
||||
;; the current total supply (which does not need to be a constant)
|
||||
(get-total-supply () (response uint uint))
|
||||
|
||||
;; an optional URI that represents metadata of this token
|
||||
(get-token-uri () (response (optional (string-utf8 256)) uint))
|
||||
)
|
||||
)
|
||||
41
test-app/contracts/stella.clar
Normal file
41
test-app/contracts/stella.clar
Normal file
@@ -0,0 +1,41 @@
|
||||
(impl-trait 'STR8P3RD1EHA8AA37ERSSSZSWKS9T2GYQFGXNA4C.sip-010-trait-ft-standard.sip-010-trait)
|
||||
|
||||
(define-fungible-token stella-token)
|
||||
|
||||
;; get the token balance of owner
|
||||
(define-read-only (get-balance (owner principal))
|
||||
(begin
|
||||
(ok (ft-get-balance stella-token owner))))
|
||||
|
||||
;; returns the total number of tokens
|
||||
(define-read-only (get-total-supply)
|
||||
(ok (ft-get-supply stella-token)))
|
||||
|
||||
;; returns the token name
|
||||
(define-read-only (get-name)
|
||||
(ok "SteLLa the Cat"))
|
||||
|
||||
;; the symbol or "ticker" for this token
|
||||
(define-read-only (get-symbol)
|
||||
(ok "CAT"))
|
||||
|
||||
;; the number of decimals used
|
||||
(define-read-only (get-decimals)
|
||||
(ok u9)) ;; 9 lives
|
||||
|
||||
;; Transfers tokens to a recipient
|
||||
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
|
||||
(if (is-eq tx-sender sender)
|
||||
(begin
|
||||
(try! (ft-transfer? stella-token amount sender recipient))
|
||||
(print memo)
|
||||
(ok true)
|
||||
)
|
||||
(err u4)))
|
||||
|
||||
(define-public (get-token-uri)
|
||||
(ok (some u"https://example.com")))
|
||||
|
||||
(define-public (faucet)
|
||||
(ok (ft-mint? stella-token u12345678 tx-sender))
|
||||
)
|
||||
Reference in New Issue
Block a user