Does anyone know how to add a file to IPFS directly from a solidity contract?


This should not be possible without any external service.

  • Can you do it using a Oracle service like oraclize.it. You can use this service to query urls and APIs: oraclize_query("URL", "https://api.kraken.com/0/public/Ticker?pair=ETHXBT") I know IPFS have a API that you can access but I dont know how to add files to it from solidity contracts? – Simon Mullaney Sep 18 '17 at 14:35
  • 1
    Yes - but this is basically an external service. Perhaps you should describe what you want to do - but somehow directly adding a file to IPFS from a solidity contract sounds really wrong to me. – ligi Sep 18 '17 at 15:02
  • Sorry, I should have been clearer, I want my smart contract to be able to monitor data from an API using the oraclize service and write this data then to IPFS instead of storing it on the blockchain.... – Simon Mullaney Sep 18 '17 at 15:07
  • 1
    If you are using an external service anyway - why not add to IPFS from there? Don't see this as a good fit in the contract - also will be really expensive .. – ligi Sep 18 '17 at 15:24
  • I didn't think of that, do you know of any good resources for looking into how to implement that? – Simon Mullaney Sep 18 '17 at 15:42

No. And why would you want to? Seems like it could be a huge security hole. Just call your contract from an application, wait for the receipt, and then upload the information to IPFS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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