Define Non Fungible Token - Stacks Clarity Smart Contract

56 views Asked by At

Question, the two functions "define-non-fungible-token" and "define-trait" are unrelated... right? The function "define-non-fungible-token" is used to create an NFT. While the function "define-trait" is used so that another contract can utilize that "trait" via dependency in the .toml file.

Can the function "define-non-fungible token" be used within the "define-trait" function? If so the snippet with "define-n-f-t" would have to come after "define-trait" right

1

There are 1 answers

0
Kenny On

define-trait allows you to define a set of public functions that any contract which complies to this trait must have. And by public I mean function defined with define-public and functions defined with define-read-only that returns result type.

Here's a good walkthrough of traits: https://book.clarity-lang.org/ch09-00-traits.html

define-non-fungible-token is a built-in function that can't be called from the outside world. It is also a top-level function that does not return anything. Because of that you shouldn't use it in your trait definition.

It is only used to define a new NFT.