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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import '@openzeppelin/contracts/access/Ownable.sol'; | |
import '@openzeppelin/contracts/utils/math/SafeMath.sol'; | |
contract Fundraiser is Ownable { | |
using SafeMath for uint256; | |
} |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
function addFarmer(address account) public onlyFarmer { | |
_addFarmer(account); | |
} | |
function renounceFarmer() public { | |
_removeFarmer(_msgSender()); |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// Define a function 'fetchItemBufferOne' that fetches the data | |
function fetchItemBufferOne(uint256 _productCode) | |
public | |
view | |
returns ( | |
uint256 itemstockUnit, |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// 12th step in supply chain process | |
function sellItemByRetailer(uint256 _productCode, uint256 _price) | |
public | |
onlyRetailer // check _msgSender() belongs to RetailerRole | |
receivedByRetailer(_productCode) | |
verifyCaller(items[_productCode].ownerID) // check _msgSender() is ownerID |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// 9th step in supply chain process | |
function purchaseItemByRetailer(uint256 _productCode) | |
public | |
payable | |
onlyRetailer // check _msgSender() belongs to RetailerRole | |
forSaleByDistributor(_productCode) | |
paidEnough(items[_productCode].productPrice) |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// 6th step in supply chain process | |
function processedItemByDistributor(uint256 _productCode, uint256 slices) | |
public | |
onlyDistributor // check _msgSender() belongs to DistributorRole | |
receivedByDistributor(_productCode) | |
verifyCaller(items[_productCode].ownerID) // check _msgSender() is owner |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// 4th step in supply chain process | |
function shippedItemByFarmer(uint256 _productCode) | |
public | |
payable | |
onlyFarmer // check _msgSender() belongs to FarmerRole | |
purchasedByDistributor(_productCode) |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
//2nd step of suppply chain process | |
function sellItemByFarmer(uint256 _productCode, uint256 _price) | |
public | |
onlyFarmer // check _msgSender() belongs to farmerRole | |
producedByFarmer(_productCode) // check items state has been produced | |
verifyCaller(items[_productCode].ownerID) // check _msgSender() is owner |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
// 1st step in supply chain process | |
function produceItemByFarmer( | |
uint256 _productCode, | |
string memory _originFarmName, |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
... | |
//Item State Modifiers | |
modifier producedByFarmer(uint256 _productCode) { | |
require(items[_productCode].itemState == State.ProduceByFarmer); | |
_; | |
} |