## 4 BIMcontracts Approach
### Initialization of the Smart Contract  
The initialization phase is split into two steps: _(2.1) Linking Billing Plans and Smart Contracts_ and _(2.2) Smart Contract Generation and Deployment_ (see Figure 2). In these two steps, all required information and contractual details will be gathered, agreed upon, and then converted into a format suitable for saving and executing on a blockchain. The goal of the first step is to upload all digital contractual elements and create the SCC. It consists of three types of data: (i) details about the contractual participants, related companies, and people, (ii) digital contractual elements, each with their hash values, and (iii) the customized execution details, referred to as billing arrangements. This allows the configuration of payment intervals, partial payment options, confirmation and payment deadlines for progress payments, security deposits, and other payment-related conditions. An example for billing arrangements is shown in the case study (see Section 6.3). It can be specified, e.g., that the reporting only occurs in a certain time interval or that partial payments for larger tasks are also enabled above a certain stage of completion (e.g., 50%). Default billing arrangements can be initially set for all billing units, but can still be customized for each unit separately. The resulting SCC serves as the basis for generating and deploying the smart contract in the next step.  
Figure 3: File structure of the BIMcontracts Container (BCC).  
To make the system ready for the execution phase, the smart contract must first be created and activated on the blockchain. The SCC is used to generate and customize a specific smart contract based on pre-defined templates. Figure 4 shows a simplified example of the SCC using the JavaScript Object Notation (JSON) format. Each billing unit contains one or many billing unit items representing a single item from the BoQ or a quantity split from the QTO. To track the status of each item of the billing plan (billing unit or billing unit item), reusable code templates are defined and implemented as state machines (see Section 5.2). State machines represent a set of valid states and specific transitions between those states based on pre-defined conditions. While generating smart contracts, each item in the billing plan is mapped to a smart contract representing a certain state machine template.  
The overall process for smart contract generation and deployment is shown in Figure 5. First, the contract configuration is created in the Client application and the Management Backend and is then sent to the Blockchain Communication Backend to generate smart contract templates based on the SCC. These templates are converted into raw smart contract deployment transactions, which are signed by the Signing Backend and sent to the blockchain (based on the meta-transaction concept [35] and off-chaining design patterns [36]). The smart contract code to be deployed is prepared with details from the SCC, such as the project ID, client, contractor, and references to all contractual documents. The contract creation on the blockchain returns a public smart contract address that is stored in the internal database of the Blockchain Communication Backend and linked to the corre  
Figure 4: Example of a smart contract configuration, which is sent to the generator via the REST API.  
sponding contractual agreement. Both contracting parties must give their agreement to the use of the smart contract for reporting and payment processing. Two steps are required for this. First, the customer initializes the smart contract and, thereby, gives their agreement. Then, the contractor sends a signed approval transaction to the smart contract, officially confirming the bilateral agreement.