Research Article

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

Algorithm 6

Abort function.
1:  function ABORT()
2:   Transfer tokens from the function caller to the block producer.
3:   if is Route Requested and the function caller is then
4:    Transfer tokens back to the function caller
5:   end if
6:   if is Route Offered then
7:    if the function caller is then
8:     Transfer tokens back to the function caller
9:     Transfer Offer tokens of all intermediary devices back to them
10:   end if
11:   if the function caller is then
12:    Transfer Offer tokens back to the function caller
13:   end if
14:  end if
15:  if is Route Accepted then
16:   if the function caller is or then
17:    Transfer of the and tokens back to
18:   end if
19:   if the function caller is then
20:    Transfer of the and tokens back to
21:   end if
22:  end if
23: end function