I wanted to create a website and upload it onto the IPFS for users to upload data (like their picture, name etc.).
But how exactly can I capture all details user upload, get the IPFS Hash produced and then put down the hash in my solidity contract to store the hash on the ethereum blockchain?
Any links, or comments will be greatly appreciated. Sorry if the question is a bit dumb.
Best Answer
What about user information, it can be very convinient to store it in JSON format. I have example how to interact with JSON object in ipfs, how to get hash, store it and then retrieve it from smart contract:
MyContract.sol
test.js
You can store ipfs hash in
bytes
type in Solidity, but I prefer to store it instring
because I won't have to make any convertion while retrieving value frombytes
.What about images, you will have to create buffer of the image and then simply upload it to ipfs using
.add
. It will return hash which you can store as in example above.