Storage dApp with IPFS + Ethereum

in dapp •  7 years ago  (edited)

This article is about how to run IPFS Ethereum Storage dApp at https://github.com/llSourcell/IPFS_Ethereum_Storage

Most of time, following ReadMe from the git is enough but you need to know a little bit about Web Console of FireBox.

Install IPFS

Download binary from https://ipfs.io/docs/install/

Initialize an Ethereum node for mining

Why? Because we need to mine Ethereum to fetch uploaded file.

$ geth --datadir="./" account new

To run a private blockchain, you need to have a genesis node (the very first block of your private blockchain!)

Save follow json data as genesisblock.json

{
    "config": {
        "chainID"       : 10,
        "homesteadBlock": 0,
        "eip155Block":    0,
        "eip158Block":    0
    },
    "nonce": "0x01",
    "difficulty": "0x20000",
    "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x00",
    "gasLimit": "0x2FEFD8",
    "alloc": {
    } 
}

Then, initiate Ethereum blockchain:
$ geth --datadir="./" init genesisblock.json

Load the geth console:
$ geth --datadir="./" --networkid 23422 --rpc --rpccorsdomain="*" --rpcport="8545" --minerthreads="1" --mine --nodiscover --maxpeers=0 --unlock 0 console

Initialize IPFS

$ ipfs init
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
$ ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'

CORS configuration to access remote content from ipfs.

run ipfs daemon:
$ ipfs daemon

Run IPFS dApp

Now, open storage.html file with FireFox and

Tools > Web Developer > Web Console

Screen Shot 2018-04-01 at 5.57.46 PM.jpg

Type commands in the command line

  • deployStorage()
    Screen Shot 2018-04-01 at 5.59.50 PM.jpg
  • storeContent("https://upload.wikimedia.org/wikipedia/commons/e/e4/160618_MBC_Thank_You_Festival_%E2%80%93_Red_Velvet.jpg")
  • storeAddress("QmbWQBKEaVBBc42sVbCUwJc294awGeb17aUEf6ijXxcVTk")
  • fetchContent()

Screen Shot 2018-04-01 at 6.07.07 PM.jpg

To check your uploaded file, open the ipfs url from your browser: http://localhost:8080/ipfs/QmbWQBKEaVBBc42sVbCUwJc294awGeb17aUEf6ijXxcVTk or
https://gateway.ipfs.io/ipfs/QmbWQBKEaVBBc42sVbCUwJc294awGeb17aUEf6ijXxcVTk

[wikemedia & MBC]

IPFS (InterPlanetary File System) is a distributed file system inspired by years of research into distributed systems that content addresses data. It stores data in a distributed hash table, transfer it via a bit torrent like mechanism, and structures it in the form of a merkleDAG. To give it all a human readable address by using a naming system called IPNS.

image.png)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!