a proof of concept of LikeCoin content footprint
- Prepare a ethereum wallet in rinkeby testnet, make sure you have eth for running smart contracts
- Replace
address
andprivateKey
field in config/accounts.js - Run
docker-compose up -d
. It will create a ipfs container, a nginx container and build thelike-server
container. Thelike-server
container contains the production build of the frontend and the nodejs api server.
POST endpoint for uploading new image file with metadata
- The image fingerprint is generated by puting the uploaded image into
sha256()
function. - The image is then added to local ipfs by
ipfs.add()
, yielding its ipfs address. - The fingerprint, ipfs address and other metadata are then written to the smart contract by calling
ethjs-signer
andsendRawTransaction
. - The result eth transaction hash is then sent back to frontend for tracking.
GET endpoint for query metadata given its fingerprint
- Using
ethjs-contract
, we calllikeContract.get()
with the input key(fingerprint) as the param. - The result in array format is converted into key-value mapping, then returned to frontend.
POST endpoint for creating meme image base on another existing image with fingerprint
- Similar to query,
likeContract.get()
is called to extract metadata from the fingerprint. - The actual image data is retrieved by calling
ipfs.cat()
with the ipfs address stored in metadata. - The image data is then pass to
imageMagick
for annotating text. - The result of
imageMagick
is then pass tosha256()
andipfs.add()
again for yielding fingerprint and ipfs address. - The new fingerprint and ipfs address, together with the parent fingerprint contained in the metadata is written into smart contract by
sendRawTransaction()
. - The result eth transaction hash is then sent back to frontend for tracking.