## 5 The Demonstrator
### Multi-Agent System Module  
The MAS module of the demonstrator is composed of two main sub-systems, one internal meant to manage the core functions of the Superbonus 110% processes, and the second external to interface the whole MAS to the Double-DAOs module. The interaction with DAOs happens through two service agents whose functionality is to interface Investor and Operator DAOs with the MAS; they supervise all information on basic operations from/to the DAOs. This part is not implemented at the moment in the demonstrator. Each agent has the relevant logic and internal communication functions integrated; in this way, blockchain interactions happen on a singular basis and are limited to the agent's needs. This part is implemented and described in Section 5.6. Basic features of the MAS module are implemented through several agent roles to model all those defined in the previous section at Table 2. General Contractors, Sub-contractors, suppliers, Design Architects, and Tax Auditors have similar roles as negotiating agents. They are defined by homogeneous data (registry data) and similar functions to perform (checking payments received, verifying docs exchanged, etc.). This agent will react to human requests (e.g., approve a credit certification) and other agents' requests. Clients(homeowners) have the initial function of hiring General Contractors and technicians, while financial institutions fund General Contractors once the client appoints them. In our system, a particular role is given to the workflow agent, a special agent used to model paperwork and evaluate the advances of the works. There are five states modelled (Open, Anticipation, Wps1, Wps2, and Eow), plus the final one for archiving (Archived) as per the workflow described in Section 2.1. The relevant features of agent roles are as follows:  
* The **workflow agent** represents each Superbonus 110% process opened. Once the instance is created, the agent will be on position \((x,0)\); as soon as the work is approved, it will move to position \((x,1)\) corresponding to the **SoW** state. It will move once the state passage condition is met (e.g., the related Tax Auditor agent approves the credit for that stage) until it reaches the final position \((x,5)\). Once the paperwork is complete, the agent will be archived (possibly for five months). The agent logic thus evaluates if the represented paperwork is due to be moved to the next state, i.e., the technicians have asseverated the current SoW, and the General Contractor has paid the anticipation for the next state. When the agents have instantiated, the total value of the work is generated by a random procedure with a value comprised of 1 mln and ten mln microAlgos. To avoid excessive complexity, we model five pieces of paperwork for the demonstrator to handle, thus having five workflow agents. The logic is realised through a smart contract deployed on the Algorand testnet wallets of agents and is activated by opting into such a smart contract. Considering the current state of the workflow agent as \(x_{cur}\), the last asseverated state as \(x_{\_}{\_}{\mathit{ASV}}\), and the previous paid as \(x_{\_}{\mathit{pay}}\), the propositional logic notation for such a constraint evaluation is the following: \[x_{\_}{cur}(i+1)\Longleftarrow-(x(i)_{\_}{cur}=x_{\_}{\mathit{ASV}}(i)) \wedge(x_{\_}{\mathit{ASV}}(i)=x_{\_}{\mathit{pay}}(i))\wedge-x_{\_}{\mathit{ arc}}(i).\] The workflow agents also pay the technician agents once the state is successfully updated; this happens by sending between Algorand wallets the amount calculated as a percentage (adjustable from the specific home page slider) of the state value (adjustable again from relevant sliders); see Figure 12 on Section 5.5. * The **General Contractor agent** has the function of approving, on the financial side, the evolution to the next step of the paperwork. It simulates the passage of state, generating a random number to be checked against a threshold configurable as an input parameter similar to the workflow agent's procedure.