0

IM new to the Blockchain/DAPP/NFT thing and need to get the process straight

Assuming my smart contract is setup and pretty standard, I need users to login to the dapp and buy an NFT; IE not on Opensea

Iv created the artwork and stored it on the server where the DAPP resides.

How do I correlate the ID of the unique NFT to the ID and address on the smart contract? All the contracts Iv reviewed, the NFT ID is just stepped on incrementally. Does the contracts ID have to correlate to the image ID?

Stefanpt
  • 77
  • 9

1 Answers1

0

How do I correlate the ID of the unique NFT to the ID and address on the smart contract?

You can have a mapping of token IDs to the image IDs.

mapping (uint256 => string) public tokenIdToImageId;

function mint(uint256 _tokenId, string _imageId) external {
    tokenIdToImageId[_tokenId] = _imageId;
    // TODO rest of your mint function
}

The token ID can be incremental, or it can also be based on your input. When you're minting a new token, you just need to pass it the image ID, and map it to the correct token ID.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100