Research Article

A Research on Traceability Technology of Agricultural Products Supply Chain Based on Blockchain and IPFS

Algorithm 3

Commodity trading algorithm.
Input: IDbuyer, IDseller, address_buyer, address_seller, Ppri, Pquan, Pqual, Fine
Output: Transaction result
(1)The seller applies smart contract function: negotiate (IDbuyer, IDseller, Ppri, Pquan, Pqual)//Both parties can negotiate the commodity price, quantity and quality through this function.
(2)if Pay_pri = Ppri × Pquan||Fine = λ·Pay_pri then
(3) Contract status becomes Sell_agree
(4)if Confirm receipt or time stamp > deadline then
(5) Apply smart contract function: Trans_Record (payment, address_buyer, address_seller)
(6)else
(7) Trigger the contract event: Dispute_event (IDbuyer, IDseller, Ppri, Pquan, Pqual, Fine)
(8)end if
(9)else
(10) Contract status becomes Sell_disagree
(11)return (“transaction failed”)
(12)end if