1

What I am trying to do is make some smart contracts that I am going to sell to my clients giving them ownership of those contracts. A web service using web3 will be available to retrieve some information about these contracts. I would like to give my client to link their contract to an image, that I will retrieve using my web service. Since there is no need of consensus needed for the image data, I prefer to have it stored off-chain using some kind of p2p network. This will avoid fees to store/Modify those images as well. It would be interesting if I can somehow link the client contract in Ethereum with his image in the other network. Is there any tool that I can build this kind of logic with ?

2
  • You can store the URL address or hash of the image in your contract.
    – Ismael
    Jun 5, 2017 at 15:27
  • 1
    URL of what, I don't want to host the clients images, i am looking for a decentralized way to store their files and the two networks linked, so that everyone knows that the contract holder is also the holder of that file Jun 5, 2017 at 16:53

2 Answers 2

2

Swarm or IPFS are solutions for distributed document storage

2

the smart contract can't communicate with the offchain space even with another p2p network unless if you are using an oracle. so in your case, the hint is to use IPFS (distributed file System) with oraclizeit (maybe if you need a TLSnotary).

In a nutshell: store the data in a IPFS node, The IPFS will provide you a unique id(multihash) per file (a Base58 encoded hash) which you could store in your smartcontract storage.

e.g : `Qmd286K6pohQcTKYqnS1YhWrCiS4gz7Xi34sdwMe9USZ7u` //multihash

then you could access outside the smartcontract the picture by using its multihash stored previously. here is a snippet code for nodejs (IPFs module)

https://github.com/ipfs/examples/issues/17

or alternatively you could use ipfs-js

https://github.com/ipfs/js-ipfs

an example of file Manager : https://github.com/tableflip/ipfs-filexp

There is another possibility is to use Storj, but as i know they don't provide any ethereum integration.

2
  • You only need an oracle here if for some reason your users are only allowed to interact with the world through contract calls; If they can use the web3 JavaScript library to send data to the contract, presumably they can also use an IPFS JavaScript library to save their images, then send the resulting IPFS multihash to the contract in a normal contract call. Jun 6, 2017 at 7:01
  • you are right and that's why i said it is a hint, because i am not aware what does he exactly want, but what's sure is to store the multihash linked to its owner in a map. then the user or the application could in the frontend retrieve and display the picture (using ipfs module for nodejs or js-ipfs github.com/ipfs/js-ipfs/tree/master/examples/transfer-files).
    – Badr Bellaj
    Jun 6, 2017 at 9:05

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.