(define-trait nft-trait
(
;; Last token ID, limited to uint range
(get-last-token-id () (response uint uint))
;; URI for metadata associated with the token
(get-token-uri (uint) (response (optional (string-ascii 256)) uint))
;; Owner of a given token identifier
(get-owner (uint) (response (optional principal) uint))
;; Transfer from the sender to a new principal
(transfer (uint principal principal) (response bool uint))
)
)
;; define a new NFT. Make sure to replace MY-OWN-NFT
(define-non-fungible-token BNS-BILL uint)
;; Store the last issues token ID
(define-data-var last-id uint u0)
;; Claim a new NFT
(define-public (claim)
(mint tx-sender))
;; SIP009: Transfer token to a specified principal
(define-public (transfer (token-id uint) (sender principal) (recipient principal))
(begin
(asserts! (is-eq tx-sender sender) (err u403))
;; Make sure to replace MY-OWN-NFT
(nft-transfer? BNS-BILL token-id sender recipient)))
(define-public (transfer-memo (token-id uint) (sender principal) (recipient principal) (memo (buff 34)))
(begin
(try! (transfer token-id sender recipient))
(print memo)
(ok true)))
;; SIP009: Get the owner of the specified token ID
(define-read-only (get-owner (token-id uint))
;; Make sure to replace MY-OWN-NFT
(ok (nft-get-owner? BNS-BILL token-id)))
;; SIP009: Get the last token ID
(define-read-only (get-last-token-id)
(ok (var-get last-id)))
;; SIP009: Get the token URI. You can set it to any other URI
(define-read-only (get-token-uri (token-id uint))
(ok (some "https://bafybeib3dzo5hyhqt4kiccq7e2umymum6nafwgzy63di65pqhukr3mimim.ipfs.nftstorage.link/{id}.json")))
;; Internal - Mint new NFT
(define-private (mint (new-owner principal))
(let ((next-id (+ u1 (var-get last-id))))
(var-set last-id next-id)
(nft-mint? BNS-BILL next-id new-owner)))