;; cc-ft-cxc
;; CrossCheck Token
;; we implement the sip-010
;; In Mainnet Use https://explorer.stacks.co/txid/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-10-ft-standard
(define-fungible-token cxc u19000000000000)

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

;; public functions
;;
;; get the token balance of owner
(define-read-only (get-balance-of (owner principal))
  (ok (ft-get-balance cxc owner))
)

;; returns the total number of tokens
(define-read-only (get-total-supply)
  (ok (ft-get-supply cxc))
)

;; returns the token name
(define-read-only (get-name)
  (ok "CrossCheck")
)

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

;; the number of decimals used
(define-read-only (get-decimals)
  (ok u6)  ;; because we can, and interesting for testing wallets and other clients
)

(define-read-only (get-token-uri)
  (ok (some u"https://paradigma.global/tokens/crosscheck.json"))
)
;; {
;;   "name":"CrossCheck",
;;   "description":"CrossCheck token, used as a token",
;;   "image":"https://paradigma.global/tokens/crosscheck.png",
;;   "vector":"https://paradigma.global/tokens/crosscheck.svg"
;; }


;; (transfer (uint principal principal) (response bool uint))
;; amount sender recipient
;; Transfers tokens to a recipient

(define-public (transfer (amount uint) (sender principal) (recipient principal))
  (if (>= (ft-get-balance cxc sender) amount)
     (begin
       (print "crosscheck.transfer")
       (print amount)
       (print tx-sender)
       (print recipient)
       (asserts! (is-eq tx-sender sender) (err u255)) ;; too strict?
       (print (ft-transfer? cxc amount sender recipient))
       )
     (err u0)
   )
)
