Implementing a Complex Arbitrator
Smart contracts in this tutorial are not intended for production but educational purposes. Beware of using them on main network.
We will refactor
SimpleCentralizedArbitrator to add appeal functionality and dynamic costs.
First, let's implement the appeal:
We first define
appealWindow constant, which is the amount of time a dispute stays appealable.
appealPeriod function of the ERC-792 interface, we define two additional variables in
DisputeStatus function is also updated to handle the case where a dispute has
DisputeStatus.Appealable status, but the appeal window is closed, so actually it is
The important change is we divided proxy
rule function into two parts.
giveRuling: Gives ruling, but does not enforce it.
executeRulingEnforces ruling, only after the appeal window is closed.
Before, there was no appeal functionality, so we didn't have to wait for appeal and ruling was enforced immediately after giving the ruling. Now we need to do them separately.
appeal function checks whether the dispute is eligible for appeal and performs the appeal by setting
status back to the default value,
Now let's revisit cost functions:
We implemented a setter for arbitration cost and we made the appeal cost as exponentially increasing.
We achieved that by counting the number of appeals with
appealCount variable, which gets increased each time
appeal is executed.
This concludes our implementation of a centralized arbitrator with appeal functionality.