This repository containts an Ethereum DApp that demonstrates a Supply Chain flow between a Seller and Buyer. The user story is similar to any commonly used supply chain process. A Seller can add items to the inventory system stored in the blockchain. A Buyer can purchase such items from the inventory system. Additionally a Seller can mark an item as Shipped, and similarly a Buyer can mark an item as Received.
The Farmer can/must include a picture of the good which will be stored on the IPFS server using the infura API. The Hash of the image will be included in the struct of the good.
It now includes the usage of access control which means that the owner of the contract has first to set the different roles (Farmer, Distributor, Retailer), and only these addresses can now execute their respective functions:
-
Farmer can only: HARVEST, PROCESS, PACK, SELL
-
Distributor can only: BUY, SHIP
-
Retailer can only: RECEIVE
CURRENT: live version of contract: ETHERSCAN
OTHER UPDATES COMING SOON
- Unique Product Code Generator
- Include OpenZeppelin structures
- User Interface Design
- Code optimization
These instructions will get you a copy of the supply chain and lets you run the client on the local machine and deploys your own supply chain contract to the love test network rinkeby.
Please make sure you've enabled MetaMask extension in your browser and gulp installed.
-
Clone this repository:
$ git clone https://github.com/Userrick/Simple-Supply-Chain-Udacity
-
Install all requisite npm packages (as listed in
package.json
):$ npm install
-
Create a new file in the project folder with the name migration-secrets.js:
$ touch migration-secrets.js
-
Copy the following into it (attention to https://):
const secrets = { mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT", ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY" } module.exports = secrets;
-
Follow this guide to reveal your seed words from your METAMASK account.
a) Be sure to be on the rinkeby testnetwork
b) Copy your seed words from your METAMASK into the respective marked section of the secrets-migration.js file
-
Visit the infura website
a) login or create account
b) create a new project
c) COPY the endpoint from the project to clipboard
d) PASTE it into the respective field in the secrets-migration.js file
-
Now launch your personal supply chain to the network by following these commands:
$ truffle compile $ truffle migrate --reset --network rinkeby
-
Now launch the client by the following command:
$ npm run dev
Now you should be able to interact with your contract at LOCALHOST via METAMASK on the rinkeby test network.
If you encounter some issues let me know!
Enjoy!
-
Install ganache-cli
$ npm install -g ganache-cli
-
Open a seperate terminal window and run ganache-cli:
ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster"
-
Run the tests:
truffle test
- Ethereum - Ethereum is a decentralized platform that runs smart contracts
- IPFS - IPFS is the Distributed Web | A peer-to-peer hypermedia protocol to make the web faster, safer, and more open. Is used via the API of INFURA ipfs.infurs.io to save the image.
- Truffle Framework - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.
- Gulp - Is used as building tool for e.g. to minify, convert ES6 to ES5, etc
- truffle-hdwallet-provider - HD Wallet-enabled Web3 provider. Use it to sign transactions for addresses derived from a 12-word mnemonic.
- NODE + NPM
- Truffle v5.0.17 (core: 5.0.16)
- Solidity v0.5.0 (solc-js)
- Node v10.15.3
- Web3.js v1.0.0-beta.37
Starter code was provided by Udacity
- Solidity
- Truffle
- IPFS