# Blockchain Solution for Buildings' Multi-Energy Flexibility Trading Using Multi-Token Standards
## 3 Materials and Methods
By adhering to this approach and this environment, each scenario run can be compared to the same state of the blockchain, and any further developments can be compared directly. We aim to evaluate our solution effectiveness in managing both the heat and electricity orders of building prosumers, creation of heterogenous trades, and processing in batches. We constructed the trading scenario using the different types of electricity and heat prosumers presented in Figure 5.

The heat and electricity producers can place their entire orders through a single transaction without needing a fixed price and the energy tokens will be minted. Table 2 shows the ERC-1155 encoding of flexibility orders for both heat and electricity in our scenario using encoding with different token IDs. As can be seen in Table 2, at each hour, the flexibility order is encoded by a different token. Algorithm 9 shows an encoding example for the orders placed by prosumers as buyers and sellers. ```
let order1= {  orderSide: OFFER,  prosumerAddress: producerA,  tokenIds: [MORNING_ELECTRICITY_TOKEN, MORNING_HEAT_TOKEN,  EVENING_ELECTRICITY_TOKEN, EVENING_HEAT_TOKEN],  quantities: [100,100,100,200],  prices: [10,15,10,15]  let order2= {  orderSide: BID,  prosumerAddress: Consumer1,  tokenIds: [MORNING_ELECTRICITY_TOKEN, EVENING_ELECTRICITY_TOKEN],  quantities: [10,10],  prices: [15, 15] }
```
**Algorithm 9** Flexibility bids and offers using ERC-115. Upon submitting orders, the consumers will lock fungible tokens as a guarantee of their solvability during settlement. They are determined considering the amount of heat or electricity energy submitted in the bid and the reference price. Table 3 shows the consumers' orders and their deposits for a market session in our scenario. \begin{table}
\begin{tabular}{l l l l l l l l} \hline \hline
**Order ID** & \begin{tabular}{l} **Market** \\ **Participant** \\ \end{tabular} & **Order Type** & **Hour** & **Energy Type** & **Token ID** & \
\begin{tabular}{l} **Quantity** \\ **(kWh)** \\ \end{tabular} &
\begin{tabular}{l} **Order Price in** \\ **Fungible Token** \\ \end{tabular} \\ \hline
1 & Producer A & Sell & 10 a.m. & Electricity & 10 AME & 100 & 10 \\
1 & Producer A & Sell & 10 a.m. & Heat & 10 AMH & 100 & 15 \\
1 & Producer A & Sell & 6 p.m. & Electricity & 6 PME & 100 & 10 \\
1 & Producer A & Sell & 6 p.m. & Heat & 6 PMH & 200 & 15 \\
2 & Producer B & Sell & 10 a.m. & Electricity & 10 AME & 20 & 5 \\
2 & Producer B & Sell & 6 p.m. & Electricity & 6 PME & 10 & 5 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: ERC1155 tokens for producers’ orders of heat and electricity. Figure 5: Buildings’ heat and electricity trading scenario. ```
Algorithm 10 shows examples of successful minting of heat and electricity tokens and the orders' registration. ``` ERC1155.TransferSingle( _operator: <indexed> 0x627306090 abaB3A6e1400e9345 bC60c78a8 BEE57 (type: address), _from: <indexed> 0x000000000000000000000000000000000000000000000000000000



Our solution allows for having all energy tokens as well as the fungible currency transfer carried out once with the total due, rather than having multiple transfers between the same partners (once for each session market). As a result, it provides better support for building prosumers in trading heat and electricity flexibility at the same time, increasing their interoperability with energy markets. ## 5 Discussion

In this section, we discuss the benefits of our solution in terms of reducing the number of transactions, as well as decreasing the amount of gas needed to execute those transactions in peer-to-peer energy trading.