forked from udacity/nd1309-Project-6b-Example-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kylesf
committed
Jan 26, 2019
0 parents
commit 5b2e6e9
Showing
32 changed files
with
10,832 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Ganache CLI v6.1.3 (ganache-core: 2.1.2) | ||
|
||
Available Accounts | ||
================== | ||
(0) 0x27d8d15cbc94527cadf5ec14b69519ae23288b95 | ||
(1) 0x018c2dabef4904ecbd7118350a0c54dbeae3549a | ||
(2) 0xce5144391b4ab80668965f2cc4f2cc102380ef0a | ||
(3) 0x460c31107dd048e34971e57da2f99f659add4f02 | ||
(4) 0xd37b7b8c62be2fdde8daa9816483aebdbd356088 | ||
(5) 0x27f184bdc0e7a931b507ddd689d76dba10514bcb | ||
(6) 0xfe0df793060c49edca5ac9c104dd8e3375349978 | ||
(7) 0xbd58a85c96cc6727859d853086fe8560bc137632 | ||
(8) 0xe07b5ee5f738b2f87f88b99aac9c64ff1e0c7917 | ||
(9) 0xbd3ff2e3aded055244d66544c9c059fa0851da44 | ||
|
||
Private Keys | ||
================== | ||
(0) 9137dc4de37d28802ff9e5ee3fe982f1ca2e5faa52f54a00a6023f546b23e779 | ||
(1) 18911376efeff48444d1323178bc9f5319686b754845e53eb1b777e08949ee9b | ||
(2) f948c5bb8b54d25b2060b5b19967f50f07dc388d6a5dada56e5904561e19f08b | ||
(3) fad19151620a352ab90e5f9c9f4282e89e1fe32e070f2c618e7bc9f6d0d236fb | ||
(4) 19d1242b0a3f09e1787d7868a4ec7613ac4e85746e95e447797ce36962c7f68b | ||
(5) 3bb675f8c07099816e23a3e283090cfb0f793ab625b73ca51a2d027a3c1f2d0e | ||
(6) 0faf45306c7daf14d86c266690ce54490e8c0104154cafa87d9e93724efc239d | ||
(7) f2a921dee0ebd7bfaba1a271bcd48c99baa6341a1cdf84ba843521a5555e0273 | ||
(8) 62734594840dade92a24448c8f676cc3c59fd68909837303417295f2c0f27963 | ||
(9) c29afb730456eb83415046550faf8065c8531765396156db8d97fd1fd64c6a6e | ||
|
||
HD Wallet | ||
================== | ||
Mnemonic: spirit supply whale amount human item harsh scare congress discover talent hamster | ||
Base HD Path: m/44'/60'/0'/0/{account_index} | ||
|
||
Gas Price | ||
================== | ||
20000000000 | ||
|
||
Gas Limit | ||
================== | ||
6721975 | ||
|
||
Listening on localhost:8545 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Supply chain & data auditing | ||
|
||
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 DApp User Interface when running should look like... | ||
|
||
![truffle test](images/ftc_product_overview.png) | ||
|
||
![truffle test](images/ftc_farm_details.png) | ||
|
||
![truffle test](images/ftc_product_details.png) | ||
|
||
![truffle test](images/ftc_transaction_history.png) | ||
|
||
|
||
## Getting Started | ||
|
||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | ||
|
||
### Prerequisites | ||
|
||
Please make sure you've already installed ganache-cli, Truffle and enabled MetaMask extension in your browser. | ||
|
||
``` | ||
Give examples (to be clarified) | ||
``` | ||
|
||
### Installing | ||
|
||
A step by step series of examples that tell you have to get a development env running | ||
|
||
Clone this repository: | ||
|
||
``` | ||
git clone https://github.com/udacity/nd1309/tree/master/course-5/project-6 | ||
``` | ||
|
||
Change directory to ```project-6``` folder and install all requisite npm packages (as listed in ```package.json```): | ||
|
||
``` | ||
cd project-6 | ||
npm install | ||
``` | ||
|
||
Launch Ganache: | ||
|
||
``` | ||
ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster" | ||
``` | ||
|
||
Your terminal should look something like this: | ||
|
||
![truffle test](images/ganache-cli.png) | ||
|
||
In a separate terminal window, Compile smart contracts: | ||
|
||
``` | ||
truffle compile | ||
``` | ||
|
||
Your terminal should look something like this: | ||
|
||
![truffle test](images/truffle_compile.png) | ||
|
||
This will create the smart contract artifacts in folder ```build\contracts```. | ||
|
||
Migrate smart contracts to the locally running blockchain, ganache-cli: | ||
|
||
``` | ||
truffle migrate | ||
``` | ||
|
||
Your terminal should look something like this: | ||
|
||
![truffle test](images/truffle_migrate.png) | ||
|
||
Test smart contracts: | ||
|
||
``` | ||
truffle test | ||
``` | ||
|
||
All 10 tests should pass. | ||
|
||
![truffle test](images/truffle_test.png) | ||
|
||
In a separate terminal window, launch the DApp: | ||
|
||
``` | ||
npm run dev | ||
``` | ||
|
||
## Built With | ||
|
||
* [Ethereum](https://www.ethereum.org/) - Ethereum is a decentralized platform that runs smart contracts | ||
* [IPFS](https://ipfs.io/) - IPFS is the Distributed Web | A peer-to-peer hypermedia protocol | ||
to make the web faster, safer, and more open. | ||
* [Truffle Framework](http://truffleframework.com/) - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier. | ||
|
||
|
||
## Authors | ||
|
||
See also the list of [contributors](https://github.com/your/project/contributors.md) who participated in this project. | ||
|
||
## Acknowledgments | ||
|
||
* Solidity | ||
* Ganache-cli | ||
* Truffle | ||
* IPFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"server": { | ||
"baseDir": ["./","./src", "./project-6/build/contracts"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pragma solidity ^0.4.23; | ||
|
||
contract Migrations { | ||
address public owner; | ||
uint public last_completed_migration; | ||
|
||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
modifier restricted() { | ||
if (msg.sender == owner) _; | ||
} | ||
|
||
function setCompleted(uint completed) public restricted { | ||
last_completed_migration = completed; | ||
} | ||
|
||
function upgrade(address new_address) public restricted { | ||
Migrations upgraded = Migrations(new_address); | ||
upgraded.setCompleted(last_completed_migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// Import the library 'Roles' | ||
import "./Roles.sol"; | ||
|
||
// Define a contract 'ConsumerRole' to manage this role - add, remove, check | ||
contract ConsumerRole { | ||
|
||
// Define 2 events, one for Adding, and other for Removing | ||
|
||
// Define a struct 'consumers' by inheriting from 'Roles' library, struct Role | ||
|
||
// In the constructor make the address that deploys this contract the 1st consumer | ||
constructor() public { | ||
|
||
} | ||
|
||
// Define a modifier that checks to see if msg.sender has the appropriate role | ||
modifier onlyConsumer() { | ||
|
||
_; | ||
} | ||
|
||
// Define a function 'isConsumer' to check this role | ||
function isConsumer(address account) public view returns (bool) { | ||
|
||
} | ||
|
||
// Define a function 'addConsumer' that adds this role | ||
function addConsumer(address account) public onlyConsumer { | ||
|
||
} | ||
|
||
// Define a function 'renounceConsumer' to renounce this role | ||
function renounceConsumer() public { | ||
|
||
} | ||
|
||
// Define an internal function '_addConsumer' to add this role, called by 'addConsumer' | ||
function _addConsumer(address account) internal { | ||
|
||
} | ||
|
||
// Define an internal function '_removeConsumer' to remove this role, called by 'removeConsumer' | ||
function _removeConsumer(address account) internal { | ||
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
project-6/contracts/coffeeaccesscontrol/DistributorRole.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// Import the library 'Roles' | ||
import "./Roles.sol"; | ||
|
||
// Define a contract 'DistributorRole' to manage this role - add, remove, check | ||
contract DistributorRole { | ||
|
||
// Define 2 events, one for Adding, and other for Removing | ||
|
||
// Define a struct 'distributors' by inheriting from 'Roles' library, struct Role | ||
|
||
// In the constructor make the address that deploys this contract the 1st distributor | ||
constructor() public { | ||
|
||
} | ||
|
||
// Define a modifier that checks to see if msg.sender has the appropriate role | ||
modifier onlyDistributor() { | ||
|
||
_; | ||
} | ||
|
||
// Define a function 'isDistributor' to check this role | ||
function isDistributor(address account) public view returns (bool) { | ||
|
||
} | ||
|
||
// Define a function 'addDistributor' that adds this role | ||
function addDistributor(address account) public onlyDistributor { | ||
|
||
} | ||
|
||
// Define a function 'renounceDistributor' to renounce this role | ||
function renounceDistributor() public { | ||
|
||
} | ||
|
||
// Define an internal function '_addDistributor' to add this role, called by 'addDistributor' | ||
function _addDistributor(address account) internal { | ||
|
||
} | ||
|
||
// Define an internal function '_removeDistributor' to remove this role, called by 'removeDistributor' | ||
function _removeDistributor(address account) internal { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// Import the library 'Roles' | ||
import "./Roles.sol"; | ||
|
||
// Define a contract 'FarmerRole' to manage this role - add, remove, check | ||
contract FarmerRole { | ||
using Roles for Roles.Role; | ||
|
||
// Define 2 events, one for Adding, and other for Removing | ||
event FarmerAdded(address indexed account); | ||
event FarmerRemoved(address indexed account); | ||
|
||
// Define a struct 'farmers' by inheriting from 'Roles' library, struct Role | ||
Roles.Role private farmers; | ||
|
||
// In the constructor make the address that deploys this contract the 1st farmer | ||
constructor() public { | ||
_addFarmer(msg.sender); | ||
} | ||
|
||
// Define a modifier that checks to see if msg.sender has the appropriate role | ||
modifier onlyFarmer() { | ||
require(isFarmer(msg.sender)); | ||
_; | ||
} | ||
|
||
// Define a function 'isFarmer' to check this role | ||
function isFarmer(address account) public view returns (bool) { | ||
return farmers.has(account); | ||
} | ||
|
||
// Define a function 'addFarmer' that adds this role | ||
function addFarmer(address account) public onlyFarmer { | ||
_addFarmer(account); | ||
} | ||
|
||
// Define a function 'renounceFarmer' to renounce this role | ||
function renounceFarmer() public { | ||
_removeFarmer(msg.sender); | ||
} | ||
|
||
// Define an internal function '_addFarmer' to add this role, called by 'addFarmer' | ||
function _addFarmer(address account) internal { | ||
farmers.add(account); | ||
emit FarmerAdded(account); | ||
} | ||
|
||
// Define an internal function '_removeFarmer' to remove this role, called by 'removeFarmer' | ||
function _removeFarmer(address account) internal { | ||
farmers.remove(account); | ||
emit FarmerRemoved(account); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// Import the library 'Roles' | ||
import "./Roles.sol"; | ||
|
||
// Define a contract 'RetailerRole' to manage this role - add, remove, check | ||
contract RetailerRole { | ||
|
||
// Define 2 events, one for Adding, and other for Removing | ||
|
||
// Define a struct 'retailers' by inheriting from 'Roles' library, struct Role | ||
|
||
// In the constructor make the address that deploys this contract the 1st retailer | ||
constructor() public { | ||
|
||
} | ||
|
||
// Define a modifier that checks to see if msg.sender has the appropriate role | ||
modifier onlyRetailer() { | ||
|
||
_; | ||
} | ||
|
||
// Define a function 'isRetailer' to check this role | ||
function isRetailer(address account) public view returns (bool) { | ||
|
||
} | ||
|
||
// Define a function 'addRetailer' that adds this role | ||
function addRetailer(address account) public onlyRetailer { | ||
|
||
} | ||
|
||
// Define a function 'renounceRetailer' to renounce this role | ||
function renounceRetailer() public { | ||
|
||
} | ||
|
||
// Define an internal function '_addRetailer' to add this role, called by 'addRetailer' | ||
function _addRetailer(address account) internal { | ||
|
||
} | ||
|
||
// Define an internal function '_removeRetailer' to remove this role, called by 'removeRetailer' | ||
function _removeRetailer(address account) internal { | ||
|
||
} | ||
} |
Oops, something went wrong.