Skip to content

Instantly share code, notes, and snippets.

@ac12644
Created October 3, 2022 22:35
Show Gist options
  • Save ac12644/8902f16ddcb11e490f43e7796aac249c to your computer and use it in GitHub Desktop.
Save ac12644/8902f16ddcb11e490f43e7796aac249c to your computer and use it in GitHub Desktop.
// 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)
verifyCaller(items[_productCode].farmerID) // check _msgSender() is originFarmID
{
items[_productCode].itemState = State.ShippedByFarmer; // update state
emit ShippedByFarmer(_productCode);
}
// 5th step in supply chain process
function receivedItemByDistributor(uint256 _productCode)
public
onlyDistributor // check _msgSender() belongs to DistributorRole
shippedByFarmer(_productCode)
verifyCaller(items[_productCode].ownerID) // check _msgSender() is owner
{
items[_productCode].itemState = State.ReceivedByDistributor; // update state
emit ReceivedByDistributor(_productCode);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment