Example of NFT in PyTeal

Hi there! I am an Algorand newbie and I would like to make an NFT using pyTeal (as long as the ASA does not have additional place to place mutable information, and I am not fully convinced to use the note field in Txs).

I’ve found some pyTeal example for fungible tokens but not for NFT! Is there pyTeal code example for this?

Thanks in advance!


I don’t think you can create an NFT with Teal.
Teal is for smart contracts, an NFT is not a smart contract but an ASA.

I’m quite sure that you can create a NFT via smart contract. Not because I’ve done it (in fact, i am asking for help), but because I have read it in official documentation: [here] (Building NFTs on Algorand | Algorand Developer Portal)
Or maybe I am missing something…

Thanks for the quick response!

Ok, that’s interesting, i never read this page before :+1:

What it’s saying is you can imitate an NFT by using statefull smart contracts.
Statefull smart contracts can write/update/delete values on the chain, this will give you this mutable touch you need. The main idea is if the NFT is not owned by anyone yet, the data must reside into the global storage. To give the property of this NFT to an account, you would remove this data from the global storage to the owner’s account local storage. So who owns the data owns the NFT.

Tho, i’m not certain this is a good design because done this way, the NFT cannot be transfered easily from one wallet to another like ASAs can. It won’t be compatible with services like NFTs marketplaces, and also algorand accounts can not opt-in to more than 10 statefull smart contracts while they are no limitations on ASAs.
I guess they are no concrete examples because it all depends what you really want to do.
But if you read about “Statefull smart contracts” you’ll find that writing values on the chain is trivial and to move the data from the global storage to an account’s local storage too.

1 Like