So everything makes sense so far, just wanted to ask a few question on what’s the recommended way of creating an NFT marketplace on algorand.
As I understand NFTokens live on the algorand blockchain as opposed to smart contracts (Ethereum). On this tutorial the asset creator will create a smart contract (from our dapp) that will handle putting an NFT for sale and allowing a buyer to buy etc. So if I wanted to create a dapp where users can put up certain assets for sale the users would have to deploy a smart contract like this per NFT on the network is that correct?
Is that how most people build NFT marketplaces on Algorand? (I was used on doing it on just one smart contract that stores many tokens (Ethereum) instead).
Additionally let’s say I want to display all the NFTs that are up for sale associated with my dapp. Since every creator deploys their own contract how can I keep track of all the NFT tokens without storing their ids on a server? Is there a way to get all these just from the algorand network using the SDK?
We can separate the creation of the NFT from the selling/buying.
Let’s suppose the NFTs are already created.
I’m assuming you are very familiar with ASA, smart contract, local storage, global storage, opt-in, minimum balance, indexer, …
If not, please read in details all the Get Started section of Algorand Developer Docs - Algorand Developer Portal as this is quite advanced.
Now, there are two options for the marketplace:
a smart contract created for each NFT that need to be sold (as I understand https://developer.algorand.org/tutorials/creating-an-nftmarketplace/ is doing - but I did not check the details). In that case, you need to have a way to register these smart contracts to list them. One solution is to add a special note in the application creation and then have the marketplace use the indexer to get all the application creation transactions with this note. For security reason, it would then need to check the application code is the expected one.
a global smart contract. Currently (but this may change soon), the global storage of a smart contract is limited to 64 key/values. So to be able to have as many NFTs as possible you will most likely want to use the following trick:
For each NFT, create a fresh account A and fund it with minimum balance, opt in to the NFT, and then transfer the NFT
Then, make an opt-in application call to the smart contract from A and rekeying it to the application account. This will essentially give full control of the smart contract to A. Now the smart contract owns A and the NFT inside. Rekeying is explained there: Rekeying - Algorand Developer Portal
The advantage of the second solution is that you really have a single smart contract and you can easily list all the NFTs being sold by listing all the accounts opted in to the smart contract.