;; rfnft
;; contractType: public
(impl-trait 'SP36VJX4FWS2C90AE58S6SNZ76VTXEVT1Y1Z4G03X.nft-trait')

(define-non-fungible-token rfnft uint)

(define-data-var last-id uint u0)
(define-constant contract-owner tx-sender)
(define-constant err-owner-only (err u100))

(define-public (transfer (token-id uint) (sender principal) (recipient principal))
  (begin
     (asserts! (is-eq tx-sender sender) (err u403))
     (nft-transfer? rfnft token-id sender recipient)))

(define-read-only (get-owner (token-id uint))
  (ok (nft-get-owner? rfnft token-id)))

(define-read-only (get-last-token-id)
  (ok (var-get last-id)))

(define-read-only (get-token-uri (token-id uint))
  (ok (some "https://gateway.pinata.cloud/ipfs/QmZY5m1uTV7pgpExEbEacJeN4EdgpAtmjxeXvk59se4Bgv")))

(define-public (burn (token-id uint))
  (begin 
    (asserts! (is-owner token-id tx-sender) (err ERR-NOT-AUTHORIZED))
    (nft-burn? rfnft token-id tx-sender)))

(define-public (mint (new-owner principal))
    (let ((next-id (+ u1 (var-get last-id))))
      (var-set last-id next-id)
	(asserts! (is-eq contract-caller contract-owner) err-owner-only)
      (nft-mint? rfnft next-id new-owner)))
