Skip to main content
. 2022 Sep 5;11(17):2716. doi: 10.3390/foods11172716
Algorithms A3. Smart Contract 3: Product Purchase2
Input: product name, product id, product type, batch number, product quantity, addr, seller, buyer
1. if addr is valid && addr has authentication
2. distributor_details=getDistributor(buyer)
3. x[]=getProduct_Adulteration_Info(product id)
4. y[]=getProduct_Contamination_Info(product id)
5. if x.quality ==1 && y.quality==1
6. Proceed with the purchase
7. Initiate the payment to the distributor
8. z=addBilling_Info(addr, seller, distributor_details, product id, product quantity, product name, product type, batch number, price)
9. if z==1
10. Payment Successful
11. updateProduct_Quantity(product id, product quantity, product name, product type)
12. addProduct_Sales_Info(seller, batch number, product id, product quantity, product name, product type)
13. end
14. else
15. Payment Unsuccessful
16. go to step 7
17. end
18. else
19. Product not fit for purchase due to lower quality standards
20. end
21. else
22. Invalid or authorised address
23. go to step 1 and enter a valid address
24. end