shivamdawer / ethereum-ipfs-storage

Save and fetch data using ethereum blockchain and IPFS storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ethereum-ipfs-storage

Form to save/fetch file on IPFS storage, and hash on ethereum blockchain. Blockchain simulated using ethereumjs testrpc.

  1. Install testrpc v3.0.5
  2. Clone repository on localhost with PHP installed
  3. npm install -g truffle@2.1.2 (Install truffle v2)
  4. In terminal 1, testrpc -l 10000000000 (High gas limit),
    or geth --unlock=<address> --rpc --rpccorsdomain = "*" --rpcport="8545" console (Explained below)
  5. In terminal 2, start IPFS daemon
  6. In terminal 3, cd ethereum-ipfs-storage && truffle migrate && truffle build (Open clone, compile contracts and scripts)

TESTRPC

A Node.js based Ethereum client for testing and development, testrpc is written in javascript. By default, it simulates 10 ethereum accounts on localhost on port 8545.

It is also possible to use a local ethereum node using geth. Set up with one or more accounts unlocked (e.g, --unlock 0), RPC enabled (--rpc) and the proper RPC CORS set up (e.g, --rpccorsdomain = "*")
Check out this guide if you want to run a local Ethereum node.
Create account using

$ geth account new

Create node using custom genesis file

$ geth init /full/path/to/CustomGenesis.json
$ geth --unlock=<address> --rpc --rpccorsdomain = "*" --rpcport="8545" console

Local IPFS node

First, install IPFS on your machine.

I suggest you don't override the IPFS directory associated to your localhost's user (normally at ~/.ipfs), so the first thing you want to do is set up an IPFS directory specific for development. You can define one under the current project's root, after you check out this repo:

$ export IPFS_PATH=.ipfs
$ ipfs init

After that, you need to loosen your IPFS node's CORS restrictions:

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

You can now start the IPFS daemon:

$ ipfs daemon

Localhost

Generally, truffle creates a server using truffle serve (default port: 8080). Since IPFS daemon runs on port 8080, this could be configured to run on a different port, e.g. truffle serve -p 8081. This can be accessed using following url : http://localhost:8081
However, this port does not supprt PHP. Hence, project should be cloned in root of localhost (LAMP or XAMPP). This can be accessed using following url : http://localhost/ethereum-ipfs-storage/build/

About

Save and fetch data using ethereum blockchain and IPFS storage


Languages

Language:JavaScript 99.8%Language:HTML 0.1%Language:CSS 0.0%Language:PHP 0.0%