5

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

1

2 Answers 2

1

This should not be possible without any external service.

6
  • 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? Commented Sep 18, 2017 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
    Commented Sep 18, 2017 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.... Commented Sep 18, 2017 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
    Commented Sep 18, 2017 at 15:24
  • I didn't think of that, do you know of any good resources for looking into how to implement that? Commented Sep 18, 2017 at 15:42
1

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 and acknowledge you have read our privacy policy.

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