Skip to content

Supply chain management on test blockchain - Project done at Santa Clara University

Notifications You must be signed in to change notification settings

tarangdave/supply-chain-blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Supply Chain Dapp

Goal

To provide a secured and public access to all the transactions over blockchain network. Implementation of a supply chain management smart contract deployed on a test blockchain running on a local network.

Required dependencies

A running node

You must run a node on your computer, whether its a real or virtual one. For development speed reasons, the best choice is to use testrpc because you have as much ether as you want and don't need to mine transactions.

Install instructions

Install following packages to get started -

  • Install MetaMask 3.5.2 Chrome Extension. Github Releases
  • Install Node JS. NodeJS
  • npm install -g node-gyp
  • npm install -g ethereum-testrpc
  • npm install -g truffle
  • npm install express@4.16.4
  • npm install cors@2.8.4
  • npm install fs@0.0.1-security
  • npm install path@0.12.7
  • npm install solc@0.4.25
Windows

The ethereumjs-testrpc package needs much more things to be installed on your machine to work on Windows.

If you can't afford this, we've covered you with Vagrant. This piece of software allows you to run a lightweight linux virtual machine in the terminal. Thus, it uses much less power than a full VM and you can still enjoy your Windows environment and tools you are used to, while providing you linux compatibility for terminal tools.

To do so, it's as easy as:

  • Downloading and installing Vagrant
  • Run vagrant up in a terminal opened at the project root. It may take some time as it must download an ubuntu ISO the first time it runs.
  • Then run vagrant ssh. If it doesn't work (it probably won't in fact) you can use Git bash if you already have it on your computer. If you don't, follow those instructions.

And that's it ! Now you can run testrpc and you should see your node running.

Truffle - Compile & Migrate contracts to the blockchain

sudo npm install -g truffle

Note : npm install -g truffle on Windows.

Instructions

Setting up the devTools and client dependencies

npm install

Note : If install fails on windows (particularly if node-gyp is the issue), run Powershell as administrator and run npm install -g windows-build-tools. It will allow you to install and use native node packages.

Run your ethereum node

With testrpc

  • testrpc --account="0x....., 10000000000000000000" you can get account address from MetaMask Extenstion
  • truffle compile and node server.js from contract-server dir

Visit http://localhost:3000 to view the compiled smart contract.

With Geth

Locally
  • Install Ethereum on your machine
  • npm run geth to initialize and run the ethereum node with geth console
  • personal.unlockAccount("ACCOUNT_TO_UNLOCK_ADDRESS", "pass") (see Note if you don't get it)
  • miner.start()

Note : At least the first time, you need to run those commands to create an account to mine on

  • personal.newAccount("pass")
  • personal.unlockAccount("ACCOUNT_ADDRESS", "pass")

Deploy the smart contracts to the node

In another terminal, run truffle compile and then truffle migrate --reset

Warning here: You have to re-run those commands when you modify your contracts so that they are re-deployed to the blockchain.

Note : There is an experimental watcher that launch these commands when you save a contract. It may not work but it's worth the shot : npm run watch-contracts

Running the client app

With your node running and the smart contracts deployed to it, run in terminal npm run start from contract-client dir.

You're done !

Visit http://localhost:8080 to interact with web application.

FAQ

  • Why is there both a truffle.js file and a truffle-config.js file?

    Truffle requires the truffle.js file be named truffle-config on Windows machines. Feel free to delete the file that doesn't correspond to your platform.

  • How can I create app with react and truffle?

    You can recreate this project with truffle-box-react which is a marriage of Truffle and a React setup created with create-react-app. Either one would be a great place to start!

About

Supply chain management on test blockchain - Project done at Santa Clara University

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published