I am going to develop a new nft marketplace but not sure what sort of data to be stored on chain. I think most data should be stored in a database and only owner infos could be stored on chain.
Forget about databases when you are dealing with blockchain. The whole purpose of blockchain is immutability and decentralization. (in marketplace you might store user's information on database)
When you create an nft, you do not store anything on blockchain related to content. You store the image on ipfs, create a JSON data to describe your nft attributes, and also store this JSON on ipfs using the image link. for example
For example this is a json data stored on ipfs
{
"name": "my new nft",
"description": "random",
// this image also stored on ipfs and its link is passed here
"image": "https://gateway.pinata.cloud/ipfs/QmRs3FropRTZv4e6TPd9WsTFDbpHXRhaCuWivNhA2nSBos",
"attributes": [
{
"trait_type": "attack",
"value": "12"
},
{
"trait_type": "health",
"value": "12"
},
{
"trait_type": "speed",
"value": "23"
}
]
}
when you mint an NFT, you actually pass the URL of this json data to the contract mint
function. An NFT structure for a marketplace can be like this:
struct NftItem{
uint tokenId;
uint price;
// creator and owner are not same. creator someone who minted. creator does not change
address creator;
// when someone purchase NFT, its not listed anymore
bool isListed;
}
Those nft's store in an array on blokchain. Also you need to create other data structres to store different information about the nft on blockchain.