0

I'm accustomed to IPFS as a store of data for the metadata of NFTs. But is it possible for a smart contract to write to ipfs? In my use case, I would like my NFT to pull its metadata, alter a few fields, push that new metadata to IPFS and lastly update its own token URI.

2 Answers 2

3

No, a smart contract cannot write to IPFS because Ethereum smart contracts cannot communicate with any off-chain resources directly, or else different nodes could receive different results every time a transaction is executed, and that would not be possible to achieve consensus in the Ethereum blockchain.

See:

Is there any way to upload to IPFS or Swarm from inside a smart contract?

Writing to IPFS directly from solidity contract

0

You may be able to use Chainlink for this. First use an Any API get request to fetch the metadata, then modify the metadata object accordingly inside your contract, then using a chainlink node setup with an external adapter to upload a JSON file to IPFS containing the new metadata object in your request. The chainlink node should be able to return the new CID which you can use to update your metadata URL. This is all pretty abstract, but should work!

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.