chore: backup testnet contracts

This commit is contained in:
Thomas Osmonson
2021-07-12 11:04:38 -05:00
parent 1d22687c39
commit e20232e9a1
4 changed files with 136 additions and 0 deletions

View 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

View 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))
)
)

View 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))
)
)

View 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))
)