# Blockchain Solution for Buildings' Multi-Energy Flexibility Trading Using Multi-Token Standards
## 3 Materials and Methods
As detailed in the previous sections, our solution makes the process of trading heat and electricity among buildings connected to a shared multi-energy grid within a community more efficient and cost-effective by enabling smart contracts to hold tokens of different types, to execute simultaneous trades in heat and electricity markets, and to process batches of energy transactions transferring multiple independent tokens between the addresses of senders and receivers. We generated multiple scenarios with different numbers of prosumers, orders on markets, and types of transfer trades (see Table 5). Given the solution's features of combining heat and electricity orders using multi-energy tokens and their processing in batches, the results show a significant cost reduction. In comparison with the preliminary results on the transfer of energy tokens individually with two markets and a three-energy token type, the gas cost was over three times the cost of the batch transfer. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \



The batch transfer offers a decreased cost compared with transferring per energy token type and, at the same time, can ease the interaction with heterogeneous markets. In our scenarios, we varied the building prosumers up to 20, with a ratio of 1:4 producers to consumers. The number of trades per producer was varied between one and five, meaning some producers traded with just one consumer, while others traded with up to five consumers. In each case, we assessed the number of transactions, the type of energy tokens traded, and the overall token transfer count. As depicted in Table 6, the increase in the number of energy tokens decreases the cost per transaction, making this approach suitable for working with higher volumes. Moreover, the number of transfer trades is significantly lower compared with the initial orders submitted by prosumers. To better understand the costs associated with each market level operation, we split it into the main components (see Table 7): minting the initial money token deposit, registering a buy or sell order, and trading (transferring the energy and money tokens). The scenario involved 20 participants in both the energy and heat markets with 12 hourly tokens per market (a total of 24 energy token types), an order quantity between 100 and 500 per energy token, and a cost per token between 10 and 15 money tokens. By comparing to the results provided by [30] for batch minting and transferring for only 10 tokens, we can observe that our approach provides more cost-efficient minting and transferring in batch based on the cost per transaction, energy token types, and token quantities while maintaining a full on-chain solution. ## 6 Conclusions

In this paper, we propose a solution for digitizing heat and electricity flexibility using multi-energy tokens and smart contracts to enable buildings to trade them in different markets. We adapt and use ERC-1155 for the energy case, allowing the smart contracts to hold tokens of different types during market trading, such as fungible used for money-like operations and non-fungible for energy exchanges. The solution enables digitizing multi-carrier energy using the same token and a single transaction to transfer both heat and electricity and the processing of energy transactions in batches between the senders and receivers with the same blockchain address. \begin{table}
\begin{tabular}{p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt}} \hline \hline
**Energy** **Tokens** & **Operation** & **Quantity** & **Transactions/ Prosumers** & **Markets Level Aggregated Costs (Gas)** & **Cost/Transactions** \\ \hline
1 & Register orders & 15 & 30/10 & 8,691,137 & 289,704 \\
3 & Register orders & 15 & 90/15 & 17,130,596 & 190,339 \\
6 & Register orders & 15 & 180/20 & 29,512,337 & 163,957 \\
1 & Transfer trades & 10 & 21/10 & 3,157,370 & 150,350 \\
3 & Transfer trades & 10 & 61/15 & 8,066,255 & 132,233 \\
6 & Transfer trades & 10 & 121/20 & 15,430,220 & 127,522 \\ \hline \hline \end{tabular}
\end{table}