Form to save/fetch file on IPFS storage, and hash on ethereum blockchain. Blockchain simulated using ethereumjs testrpc.
- Install testrpc v3.0.5
- Clone repository on localhost with PHP installed
npm install -g truffle@2.1.2
(Install truffle v2)- In terminal 1,
testrpc -l 10000000000
(High gas limit),
orgeth --unlock=<address> --rpc --rpccorsdomain = "*" --rpcport="8545" console
(Explained below) - In terminal 2, start IPFS daemon
- In terminal 3,
cd ethereum-ipfs-storage && truffle migrate && truffle build
(Open clone, compile contracts and scripts)
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
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
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/