1

I would like to create an HTML5 NFT that can interact with the smart contract. Like if I press a button in the HTML5 NFT, I can save data to a contract Array or Hashmap thru a gas powered transaction.

My question; How does the HTML NFT identify/reference itself being decentralized?

From what I understand, you create the NFT minting contract. Once you mint an NFT, you are provided with an ID that points to the NFT on the blockchain. Since the ID is provided AFTER the HTML file is uploaded to a decentralized file storage, there's no internal reference ID that can be stored as an HTML variable. Is there a code snippet that can be used via web3js or ethers.js where the HTML NFT can reference itself to call functions on it's own contract in a decentralized way?

One centralized solution I see is to store the HTML docs on my own server. When I get the provided ID after minting, I can store that NFT ID in the HTML doc and resave the HTML doc. This defeats the purpose of being decentralized and if my server eventually goes down, those NFT's are rugged.

Another partly decentralized (but still centralized) solution would be to create a unique ID stored in each HTML file prior to storing the HTML file on a decentralized service like IPFS. When ready to interact, the HTML uses this unique ID to call a centralized database service to retrieve the actual NFT ID and continue from there. If the database server goes down, those NFT's are rugged.

Any thoughts on a possible decentralized solution? Thank you.

1 Answer 1

1

You could create the contract before the html, put the contract address in html, store html in ipfs then update contract with the ipfs CID. Am I missing something?

2
  • 1
    The unique NFT token ID is created (minted) AFTER first having an ipfs CID of the uploaded JSON (that points to the HTML file). I need to access that unique NFT token ID in the HTML (js) code in order to interact with the original contract and store data in the contract based on that unique NFT token ID. It would be great to be able to do this in a decentralized manner without storing data on my own server. On my own server, I could change the HTML contents and add the unique ID at any time. But if the server goes down, so do the NFT's. For what I want, my own server may be the only way.
    – TFGems
    Jun 15, 2022 at 2:06
  • It depends what your NFT Id is. You could have the Uri updatable after mint. Jun 19, 2022 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.