Research Article

A Blockchain-Based Contractual Routing Protocol for the Internet of Things Using Smart Contracts

Algorithm 5

Expire function.
1:  function EXPIRE()
2:   Transfer tokens from the function caller to the block producer.
3:   if is Route Requested then
4:    if current time is more than then
5:     Transfer tokens back to
6:     Transfer Offer tokens back to
7:    end if
8:   end if
9:   if is Route Offered then
10:   if current time is more than Offer then
11:    Transfer tokens back to
12:    Transfer Offer tokens back to
13:   end if
14:  end if
15:  if is Route Accepted then
16:   if the function caller is or then
17:    Transfer and Offer tokens to
18:   end if
19:   if the function caller is then
20:    Transfer and Offer tokens to
21:   end if
22:  end if
23: end function