Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 2.66 KB

File metadata and controls

27 lines (16 loc) · 2.66 KB

Non-fungible token

Non-fungible tokens or NFTs are digital assets registered on a blockchain with unique identifiers and properties that distinguish them from each other.

This contract example implements a basic NFT collection that conforms to the SIP-009 NFT standard. Be sure to change the placeholder name of the collection and its max supply.

SIP-009 Standard Trait Definition for Non-Fungible Tokens

In Stacks Improvement Proposal 009 (SIP-009), the Stacks community proposed and approved a standard set of functions that every NFT contract is to implement to qualify as a compliant Stacks NFT. This creates uniformity and predictability in contract interactions, as well as enables a handful of built-in Clarity functions accessible only to SIP-009 contracts (such as nft-transfer?, etc.)

Those functions are specified in the SIP and must be implemented in each contract. Trait conformance is then asserted with an impl-trait declaration at the top of the contract pointing to the relevant trait reference published on the Stacks mainnet.

You can see this nft-trait reference in the Hiro Stacks Explorer.

Test your contract

You can manually test your contract in the Clarinet console. After entering the console with clarinet console you can make contract function calls like (contract-call? .nft claim) (contract-call? .nft get-last-token-id)

You can programmatically test your contracts with unit tests. See the tests/ folder where you will find a unit test that ensures the claim function returns the proper response and that the read-only functions work as expected.

Resources and Inspiration