(define-constant ERR-UNAUTHORIZED u1)
(define-constant ERR-ZERO u2)
(define-fungible-token token)
(define-data-var token-uri (optional(string-utf8 256)) none)
(define-constant contract-creator tx-sender)

(impl-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait)

;; SIP-010 ;;

(define-public (transfer (amount uint) (from principal) (to principal) (memo (optional (buff 34))))
	(begin
        	(asserts! (is-eq from tx-sender)
            (err ERR-UNAUTHORIZED))
        (ft-transfer? token amount from to)
    )
)

(define-read-only (get-name)
	(ok "Token Test"))

(define-read-only (get-symbol)
	(ok "TOKE"))

(define-read-only (get-decimals)
    	(ok u6))

(define-read-only (get-balance (user principal))
    	(ok (ft-get-balance token user)))

(define-read-only (get-total-supply)
	(ok (ft-get-supply token)))

(define-public (set-token-uri (value (string-utf8 256)))
    	(if
    		(is-eq tx-sender contract-creator)
           		(ok (var-set token-uri (some value))) 
        	(err ERR-UNAUTHORIZED)))

(define-read-only (get-token-uri)
	(ok (var-get token-uri)))
	
;; fund the treasury
(ft-mint? TOKE 100000000000000 'SP32XCD69XPS3GKDEXAQ29PJRDSD5AR643GNEEBXZ)
