Solidity IPFS – How Can a Contract Write Data to IPFS

ipfssolidity

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.

Best Answer

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

Related Topic