Skip to content

Instantly share code, notes, and snippets.

@ac12644
Created October 3, 2022 23:19
Show Gist options
  • Save ac12644/ac74a795e0a0444fa50286e4199f9915 to your computer and use it in GitHub Desktop.
Save ac12644/ac74a795e0a0444fa50286e4199f9915 to your computer and use it in GitHub Desktop.
// 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,
uint256 itemproductCode,
address ownerID,
address farmerID,
string memory farmName,
string memory farmInformation,
string memory farmLatitude,
string memory farmLongitude,
string memory farmAddress,
uint256 productDate,
uint256 productSliced,
string memory productType,
uint256 productQuantity
)
{
// Assign values to the 8 parameters
Item memory item = items[_productCode];
return (
item.stockUnit,
item.productCode,
item.ownerID,
item.farmerID,
item.farmName,
item.farmInformation,
item.farmLatitude,
item.farmLongitude,
item.farmAddress,
item.productDate,
item.productType,
item.productQuantity,
item.productSliced
);
}
// Define a function 'fetchItemBufferTwo' that fetches the data
function fetchItemBufferTwo(uint256 _productCode)
public
view
returns (
uint256 itemstockUnit,
uint256 itemproductCode,
uint256 productID,
string memory productNotes,
uint256 productPrice,
uint256 productDate,
string memory productType,
uint256 productQuantity,
State itemState,
address distributorID,
address retailerID,
address consumerID
)
{
// Assign values to the 9 parameters
Item memory item = items[_productCode];
return (
item.stockUnit,
item.productCode,
item.productID,
item.productNotes,
item.productPrice,
item.productDate,
item.productType,
item.productQuantity,
item.itemState,
item.distributorID,
item.retailerID,
item.consumerID
);
}
// Define a function 'fetchItemHistory' that fetaches the data
function fetchitemHistory(uint256 _productCode)
public
view
returns (
uint256 blockfarmerToDistributor,
uint256 blockDistributorToRetailer,
uint256 blockRetailerToConsumer
)
{
// Assign value to the parameters
Txblocks memory txblock = itemsHistory[_productCode];
return (txblock.FTD, txblock.DTR, txblock.RTC);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment