Research Article

SESCF: A Secure and Efficient Supply Chain Framework via Blockchain-Based Smart Contracts

Algorithm 4

Payment() for and .
(1)open channel: inputs (open, C, , )
(2)Smart contract sends (C, , txhash) to
(3) inputs to C,
(4).account := 
(5)assert txhash.price
(6) inputs to C,
(7).account := 
(8)assert txhash.LD
(9)t := tx.hash.
(10) and sign C ,
(11)payment: after and sign the channel
(12) pays txhash.PD to
(13).account := .account—txhash.PD
(14).account :=  .account + txhash.PD
(15)if did not deliver the goods before t then
(16) pay txhash.LD to
(17).account := .account + txhash.LD
(18).account := .account—txhash.LD
(19)else
(20) txhash.balance :=  .price—txhash.PD
(21) pay txhash.balance to
(22).account := .account − txhash.balance
(23).account := .account + txhash.balance
(24)end if
(25) or call to close channel
(26)close channel: on input (close, C , , txhash) from and
(27).wallet := .wallet + .account
(28).wallet := .wallet + .account
(29) and sign off