Below is the original UML diagrams for the project. During the project some changes have been made, the changes are noted in each of the diagram section.
After consideration, during buying from brewer and distributor, it is impractical to use Ether to pay. As such, the requirement isPaidEnough
is removed from both the brewer and distributor.
Everyone can also be a consumer, anyone should be able to buy the end product. As such, the restriction of isConsumer
is removed.
After consideration, it might seem that the Core contract is redundant as it only contains inheritance from OpenZeppelin Secondary, Pausable and Ownable. As we also need the function onlyOwner
in the AccessControl, the inheritance is done in the AccessControl.
Instead of separate contract, members
and grapes
mapping are implemented to keep track of roles and grapes.
AccessControl is Ownable, Pausable, Secondary
Base is AccessControl
Truffle v5.0.13 (core: 5.0.13)
Solidity - 0.5.2 (solc-js)
Node v8.10.0
Web3.js v1.0.0-beta.37
openzeppelin-solidity ^2.2.0
OpenZeppelin library is used as it simplifies the development of common access control, it has been tested by many and is believed to be stable.
- Only owner can add roles (however, for the purpose of testing, another function is created so anyone can add role)
- 1 address can only have 1 role
- Download/clone this repo
git clone https://github.com/albertsundjaja/dapp_wine_supplychain.git
- init and install npm
npm install
- for running using the deployed contract on Rinkeby,
change the address part in app/src/index.js
as below
// get contract instance
const networkId = await web3.eth.net.getId();
const deployedNetwork = baseArtifact.networks[networkId];
this.meta = new web3.eth.Contract(
baseArtifact.abi,
//deployedNetwork.address
"0xD7629d97D1866bDD462877319Ee4ef0cAd7cC486"
);
for running using local blockchain, see running blockchain locally below
- go to the app folder
cd dapp_wine_supplychain/app
- init and install npm
npm install
- run the dev server
npm run dev
- use your browser to access the frontend
http://localhost:8080
- (optional) For testing your own deployment in Rinkeby, put in your infura and mnemonic in truffle-config.js
const mnemonic = "YOUR MNEMONIC";
const infuraUrl = "YOUR INFURA URL";
then do truffle migrate --reset --network rinkeby
-
Run Ganache. The setting is expecting ganache to be running on localhost port 7545
-
go to the cloned folder and use truffle to deploy
truffle migrate --reset --network ganache
note: it has been found that sometimes we need to delete the build folder containing the abi for proper frontend functionality. build/contracts
- run the dev server
npm run dev
- use your browser to access the frontend
http://localhost:8080
contract address
0xD7629d97D1866bDD462877319Ee4ef0cAd7cC486
view it on etherscan
https://rinkeby.etherscan.io/address/0xD7629d97D1866bDD462877319Ee4ef0cAd7cC486