Blockchain application in P2P energy markets: social and legal aspects

Flexible and distributed energy markets are a reality that is progressively reaching many regions. Despite their clear benefits, they should be accepted by the prosumers. Additionally, blockchain technology and smart contracts have been characterised as a technological enabler for the energy sector and P2P Energy Markets (PEM). However, little research has been done to explore blockchain's user-centred perspective. Therefore, this paper analyses the reluctance and/or concerns of prosumers regarding smart contracts, and investigates their perception on blockchain within PEMs. The authors present the results of a survey conducted across several European countries addressing the implementation of automated trading systems and analysing the adoption of smart contracts. Considering that the main survey outcomes are related to the regulation and legislation uncertainty around blockchain usage, this paper explores also the fit of smart contracts from a legal perspective. Additionally, a set of recommendations to be used as the basis for the design and development of PEMs is delivered, aiming to adopt blockchain and smart contracts. As a key take-away, the authors confirm the crucial role that blockchain will play in the deployment of fair, secure, flexible and distributed energy markets by ensuring transparency in the exchange of information between prosumers and energy stakeholders.


Motivation and problem statement
The nature of business transactions is constantly evolving and is driven by a wide variety of socio-economic and legal factors. Over the past few decades, globalisation and industrialisation have had a significant impact on how people do business across the globe and how they interact with the adoption and integration of emerging technologies. In this context, energy markets are not an exception, since they become more and more complex. Energy distribution is the consequence of transmission across many grid levels and the interaction of numerous entities across several interconnected infrastructures. Additionally, the growing usage of renewable energy, as well as the variable power supply, only increases the aforementioned complexity (Ante et al., 2021), shifting away the energy sector from the traditional and centralised structure into more distributed schemes (Bouckaert et al., 2021).
Towards the aforementioned distribution and decentralisation of energy, several countries have made steps to promote local energy generation and consumption, based on blockchain and smart contracts (Andoni et al., 2019). The usage of blockchain can possibly bring a significant improvement in the way energy systems function by providing a decentralised and secure communications systems (Kumari et al., 2020). Due to the nature of blockchain, a reliable, open and decentralised record for all data and transactions linked to energy generation and consumption could be developed (Andoni et al., 2019;Brilliantova & Thurner, 2019). Considering the technology's decentralised and digital character, blockchain may be utilised to make data flow more secure and transparent between different participants and components in the energy system while simplifying operations. Kumari et al. (2020) is a good example of how blockchain technologies can be used in smart grid data flows to detect changes in the energy demand through digital communications and to reduce peak loads.
As blockchain technology progressed, Nick Szabo introduced smart contracts as a component of the blockchain's decentralised network. Smart contracts make use of blockchain technology to check, validate, record and enforce conditions agreed upon by at least two parties. The usage of blockchain-enabled smart contracts has already started to revolutionise the energy markets and provide significant improvements (Kounelis et al., 2017). Furthermore, smart contracts enabled by blockchain can provide transparent and immutable transactions on P2P Energy Markets (PEMs) while also promoting inter-connectivity among prosumers in a decentralised and fault-tolerant context . Towards this direction, several blockchain-based initiatives are sprouting in this sector, as well as start-ups and national governments are looking into the technology's possibilities. In line with this trend, many blockchain technology specialists analyse the system's complicated characteristics and unique structure, which has prompted the study of new related research topics.
Even though blockchain technology and smart contracts have the potential to change some key operations in PEMs (e.g. peer to peer energy transactions, billing), the technology is not yet advanced enough to address all of the issues associated with the energy transition. Blockchain functionalities are currently tested and evaluated only in small-scale applications as most of the researchers and industry experts are focusing on the technological aspects and possible use cases, and not on releasing final products. Moreover, there are extremely few academic studies that include the end users' point of view. Taken into consideration the future prosumers point of view, we based our work in the following assumptions. Firstly, the legislation and standardisation are essential concerns, followed by social impacts, technological design and user experiences (Albayati et al., 2020). Secondly, end users believe that risk is the most concerning aspect of blockchain technology, so trust and security are key aspects that should be also considered. To avoid this, blockchain technology must be reliable enough to advance in a highly competitive market, such as the energy market and the upcoming PEMs (Hamilton, 2020). As a result, it is unrealistic assessing the PEM capabilities with the technological innovation of blockchain-based smart contracts without taking the end-user perspective into account.

Contributions and innovative insights
Social effect is interpreted differently by various people, but it typically refers to how actions and activities influence individuals and communities. Often, social impact is defined as meeting a social challenge or having a good impact on others. Blockchain has the potential to not only track but also shape societal effect. There is significant discussion about public and private bodies declaring what they will do, but it is difficult to show whether or not this occurs. Thus, the goal of this work is to investigate the prosumers' perception (social aspects) on blockchain application, especially smart contracts, and how legal aspects affect the wide adoption of blockchain within PEMs. Specifically, the current study aims to follow a user-centred approach to analyse the acceptance of smart contracts for automated trading systems, such as PEM. At the same time, the authors aim to investigate the legal enforcement of smart contracts, trying to address the main social concerns about regulation and legislation. Therefore, the work conducted in this article is based on the following hypothesis: Social acceptance and standardized regulation/legislation of smart contracts could lead to the wider adoption of blockchain technology in PEM.
Based on their quantitative and qualitative results, the authors will provide a set of recommendations to be used as the basis for the design and development of PEMs that wish to adopt the blockchain and smart contract functionalities. Considering the aforementioned innovative insights, the contribution of this article is three-fold: (1) A user-centred assessment is provided addressing the automated trading systems based on a qualitative analysis of fictional futures that 832 participants have provided in a series of online questionnaires. (2) A description is done about how far the smart contract technology can be leveraged for a legally compliant and automated operation of a PEM. Moreover, which aspects have to be tackled in a traditional form of contractual agreements are analysed considering mainly legal aspects. (3) A set of recommendations are provided for the design and development of PEMs that wish to adopt blockchain and smart contract.
Furthermore, the current work underlies industrial significance as well. The analysis of the social and legal aspects presented in this article has been made in the context of the European project called PARITY (Parity Consortium, 2019). PARITY will go beyond the traditional "top-down" grid management practices by delivering a unique local flexibility market platform through the seamless integration of IoT and blockchain technologies. By delivering a market for automated flexibility exchange based on smart contracts and blockchain, PARITY will facilitate efficient and transparent P2P flexibility transactions and reward flexibility in a cost-reflective and symmetric manner, through price signals based on real-time grid operational constraints and available distributed energy recourses (DER) flexibility (Pressmair et al., 2021). One of the main objectives of the project is to promote the adoption of PEMs through knowledge transfer of the project's outcomes towards the targeted stakeholders, analysing the current and future regulatory and socio-economic context for LFM proliferation.

Article structure
The structure of this research paper is as follows: in Section 2, the research methodology followed by the authors is presented. Blockchain fundamentals and related work are summarised in Section 3, and in Section 4, the prosumers' perception on automated trading systems within PEMs is discussed. In Section 5, the legal and regulatory aspects of smart contracts are explained, while in Section 6 ,a set of recommendations for the design of PEMs is presented. Finally, Section 7 concludes the paper and discusses the future work.

Research methodology
This research work has been arisen as the first phase of the design, development and deployment of several flexible energy market pilots. It complements other studies that are necessary for the implementation of this type of markets, which are focused on the prosumers of the energy value chain and the technology providers that are intended to adopt blockchain and smart contract technologies. The methodology is therefore based on a holistic analysis of the social and legal aspects that must be analysed to address the deployment of flexible and distributed energy markets. In particular, the perception of the final prosumers, as well as the legal framework of the smart contracts that should give a legal security to the commercial relationship between them , are analysed. Three sequential lines of work have been carried out, as depicted in Figure 1, in order to reach the aim of the current study.
The first step of the research starts with a study of the state of the art regarding what other works have been carried out regarding the end users' perception of flexible and distributed energy markets. The absence of a rigorous and current analysis motivates the design of this novel assessment with the aim of covering a sufficient diversity of potential end prosumers. This assessment follows a user-centred approach through speculative design, design fiction or design probes (Auger, 2013), taking into account that our genre of study is related to contemporary smart contracts for automated trading systems. The rationale behind this approach is to address the design of future energy contracts informed from the insights that emerged from a qualitative analysis of fictional futures that participants provided in a series of online questionnaires.
Participants in the questionnaire were introduced to automatic trading systems via a use case fictional scenario that illustrated a Peer to Peer (P2P) energy trading system. The key actor in a P2P energy trading system is the prosumer, which generates and consumes energy, as well as swaps the surplus electricity with other prosumers. P2P energy trading occurs in small distributed energy resources (DERs), such as homes, industries, schools, or workplaces. Smart contracts, even if they are a sound and mature technology, might be misconceived as a disruptive technology and their acceptance by the end users should be further investigated. In order to assess any potential social barrier, a survey targeting potential prosumers was devised and carried out. As smart contracts are a highly technical concept that regular citizens are not familiar with, the surveys use a simile on a water distribution system (speculative scenario). This way not only their opinion on smart contract technology is hidden but also the relation with the energy utilities, which sometimes has a negative bias, is removed from their answers (Watson et al., 2002).
The second line of investigation lies in the integration of smart contracts within PEMs. The outcomes of the survey feed in our investigation since legal and regulation aspects are one of the key concerns to the market participants. Even though smart contracts can overcome issues, such as trust, security and confidentiality, they still have some drawbacks related to legal frameworks. When it comes to the legal aspects, the major question is related to how we can actually translate the legal terms into code without mistakes, and which entity is going to be responsible in case of conflicts. Another issue refers to the immutability of the smart contracts and their general data protection regulation (GDPR) compliance. Thus, some good practices for legally enforceable smart contracts are presented, and many arguments supporting the human intervention for interpretation of the differences between the spirit and letter of the law are provided.
Finally, the third line analyses and delivers a set of recommendations to be used as a basis for the design and development of P2P energy markets that wish to adopt the blockchain and smart contract functionalities.

Blockchain and smart contracts fundamentals
Blockchain was first introduced in 2008 (Bitcoin Cryptocurrency) by a person or a group of people called "Satoshi Nakamoto" (Nakamoto, 2008). Since then, blockchain has attracted several industry experts and research institutes due to its special capabilities for offering security, privacy, transparency and traceability performance (Zheng et al., 2017). Blockchain is considered as a distributed ledger as it is a system for recording information that makes it difficult to alter or hack. Information in a blockchain is exchanged through transactions, while a set of transactions formulate a new block of information. These blocks are attached to each other like a chain when the new block is validated by the majority of the network participants. In 2013, the Ethereum blockchain was initially described in a white paper (Buterin, 2013) by its founder Vitalik Buterin with the goal of using this concept to the decentralised applications that were not feasible in the Bitcoin blockchain. Towards that goal, smart contracts were introduced on top of the Ethereum blockchain, forming the so-called Distributed Applications (dApps).
A smart contract in simple terms is a piece of code, which stands on top of a blockchain and executes exactly what it is programmed to do. Also, smart contracts are the back-end of the dApps since they give the logic of executing and/or altering the state of the dApp. One of the most important characteristics of smart contracts is their immutability: once a smart contract is created, there is no way to modify it, which makes it an unbreakable contract among the blockchain participants. The usage of blockchain and smart contracts can make peer-to-peer power distribution networks more efficient and provide several advantages, such as accuracy, speed and security (Nzuva, 2019).

Related work
In recent years, industries, academics and researchers have been experimenting with blockchain technology, which has the potential to decentralise the complex energy market's networks and P2P energy trading (Kostmann & Härdle, 2019). Since the Brooklyn Microgrid completed the first energy transaction through blockchain in April 2016 (Mengelkamp et al., 2018), the research of energy trading at the distribution level utilising a blockchain has significantly increased (Meeuw et al., 2020). In that sense, to achieve trusted P2P energy transactions, several studies used blockchain technology in PEMs (Hamouda et al., 2021;Okwuibe et al., 2020;Pradhan et al., 2022;Zheng et al., 2021). For example, the authors in Hamouda et al. (2021) clearly state that blockchains are becoming increasingly popular among planners as a means of securing transactions. Moreover, transactive energy markets built on blockchain offer flexibility, transparency, security, competitiveness and superior low-cost dependability. Thus, they discussed the development of a full transactive energy market architecture with integrated blockchain and power system layers, as well as case study validation. Another significant work was presented in Pradhan et al. (2022), where the authors -because of the prosumers' privacy and security threats in these environments -introduced using the Orion and Metamask wallets, a flexible permissioned ascription (FPA) mechanism that employs on-chain and off-chain permissioning scheme. Also, after their evaluation, they have observed that their proposed framework when compared to alternative consensus algorithms, provides an efficient performance for establishing, transmitting and querying energy transactions to a P2P energy trading blockchain network. Furthermore, in the work conducted in Okwuibe et al. (2020), the authors have presented an open-sourced blockchainbased peer-to-peer energy trading platform. Their solution provided several possibilities such as simulations within a fraction of the real time, variations of the number of participants, etc. Finally, the usefulness and efficacy of the P2P energy market on the blockchain network have been confirmed through their simulations for several microgrid setups.
In the industry front, a large number of companies, including Grid+ 1 , Power Ledger 2 and LO3 Energy 3 , have begun to provide novel metering and billing solutions based on blockchain technology and market systems such as P2P trading (Consensys, 2018). Goranovic et al. offer a list of initiatives for microgrids that use both academic and commercial blockchain technology (Goranovié et al., 2017), where the blockchain's potential and limitations for decentralised PEM deployment were emphasised. Moreover, a three-tier distributed ledger technology (DLT)-based transactive management architecture was created for controlling PEMs. Several papers present blockchain-based transaction methods and PEM models for overcoming centralised markets with traditional pricing structures (Cheng et al., 2017) or a continuous double auction . Moreover, the authors in Etukudor et al. (2020) present a P2P bargaining model in the PEM with randomised supplier and buyer matching and no central authority. Trading takes occur on a bilateral basis between directly impacted parties. Also, as reviewed in Zhou et al. (2020), the bibliography on P2P market design includes studies on the extent of decentralisation, market segmentation, the interaction with existing centralised markets, and game theoretic approaches on trading. Furthermore, the authors of Kang et al. (2017) suggested a P2P Electricity Trading system based on a consortium Blockhchain (PETCON) architecture for conducting secure private P2P energy trading amongst plugin hybrid electric cars. The study focused on creating trust and leveraged blockchains' anonymous characteristics to protect the user's privacy.
However, none of the above-mentioned studies consider the underlying social and user perspective nor the prosumers' acceptance of the emerging blockchain technology within PEMs, and these are relatively new concepts that need to be well understood in order for them to be used. The previous experiences of an end user may influence the acceptance of using new technology. According to studies, consumers' experience and acceptance of new technology boost interaction and make it simpler to use (Alalwan et al., 2018). Fazio and Zanna performed an exploratory study back in 1978 in order to quantify and evaluate the experience as a variable. Their viewpoint was based on linear behavioural experience: the more often a perspective predicts subsequent behaviour, the more it influences individuals' experience, the wider their range of rejection and the more certain they are of their viewpoints (Kanwal & Rehman, 2017). Concluding, the amount of experience with a specific technology has a strong influence and effect on the acceptance associated with new technologies. Any technological system built on an innovative application that is subject to user experience, knowledge and behaviour can influence the system's trust, belief and acceptance (Fazio & Zanna, 1978). Thus, in the following sections, we are trying to investigate the potential prosumers' perception on blockchain application within PEM, and to identify their main concerns.

Prosumers perception on blockchain application within PEMs
This section provides the prosumers' perception on blockchain application within PEMs. A user-centric survey analyses the acceptance of smart contracts for automated trading systems, such as PEM. The survey was disseminated to the participants in a series of online questionnaires and was divided into three parts. The first part was related to a speculative scenario describing an automatic trading system like this: Imagine that you are someone who harvests water from rain and you have created a system to store the water you are not using. Sometimes, you have surpluses and sometimes you might find yourself with less water than you need. Fortunately, you are not isolated but you belong to a community of other people that also harvest water and all of you have decided to establish a trading system. As the community is constantly doing exchanges (overall in rainy and dry seasons) all of you agree that this is a very time-consuming task. Therefore, the community decides to establish a mechanism to automatically trade water through innovative technologies. In a nutshell, the trading system is working as follows: (1) Everyone sets up their preference for trading (e.g. to what level of water they consider a surplus or a shortage so the trade can start) (2) The system is monitoring each water-tank within the neighbourhood in real-time.
(3) Whenever one of the preferences from the members is met, the system publishes an offer for buying or selling water. (4) The rest of the monitoring systems analyse the offer and take an autonomous decision on the basis of the current level of water, their potential necessities for the rest of the day, the weather forecast, or the price (cost-benefit). (5) If the deal is accepted, the transaction of water starts (ideally all the houses are connected with pipes).
The second part consisted of a questionnaire based on the previous speculative scenario to explore the perception of users on automatic trading systems. It includes the following questions: • Would you be willing to participate in such a market?
• Do you feel comfortable relaying the burden of trading to an autonomous system? • Would you increase your participation in such a market if it is hosted/regulated by reliable third parties? Who is reliable for you? • What are the risks and threats associated with this trading system? Finally, the last part of the study was devoted to obtaining several demographic information to control the answers to previous sections. Participants were recruited through Prolific (Palan & Schitter, 2018), a popular crowd-sourcing platform for academic studies. Only two prerequisites were determined for participation: being over 18 years of age and living in one of the countries assessed in PARITY project: Greece, Spain, Cyprus, Belgium, Sweden, Switzerland and Austria. Furthermore, some socio-economic information was obtained, such as gender, socio-economic status, employment status, whether they are or not students, type of household where they live, whether it was owned by them or rented and finally, two questions about emerging technologies and energy sector literacy. A study completion time of 6 min was estimated and a £1 incentive for participation (£7.53/ h) was offered. The final survey could be found in Annex A and the micro data with all the answers is accessible in Borges and Casado-Mansilla (2021) The final sample consisted of 832 answers fairly balanced in terms of gender: 62% Male, 38% Female. The distribution per climate region was a little bit unbalanced towards the Mediterranean and Continental climate citizens: Cold (Denmark, Finland, Norway, Sweden) 15%; Continental (Austria, Germany, The Netherlands, Switzerland) 35%, Mediterranean (Spain, Italy, Greece) 45% and Other 5%. It is worth noting that the regions with cold climate have far less population so this imbalance was expected.
The age distribution was skewed towards the young people: the mean age of the participants was 30 years old, while, according to Eurostat, in 2018 the mean age in EU was 13 years more. The distribution of the main occupation seemed correct (Strandell & Wolff, 2019).
The main group was the employed and self-employed that combined account for 62% of the answers and the next group are the students that represent the 30%. A majority of the persons surveyed live in flats (57%). Houses represented 31% of the respondents. Moreover, half of the participants rented the place where they live. Finally, it is worth to say that the people self-described themselves as neutral in knowledge about the energy sector and blockchain technology.

Quantitative outcomes
The future potential prosumers seem to be mostly in favour of participating in PEMs (66%) but a non-negligible 30% would have some concerns. A more comprehensive view can be seen in the qualitative results section. A large majority of the respondents (52%) would like to supervise each decision taken by the system and around 38% would trust the system as it is (although 40% would like to have a trial period). With respect to the market operator, the potential prosumers prefer a private but neutral company (e.g. third-party market operator), hired by all parties or by a public authority. Please note that only 15% of the surveyed people would like to have a fully decentralised system. Regarding the fee that would have to be paid to the market operator, the majority of participants (75%) would be willing to pay less than a 10% fee, which should be taken into account when designing business models. In fact, the median is 5% and the mean value is around 7%.
More than 60% of the surveyed people think that an automatic trading system should trade both surpluses and needs. In fact, the 49% opine that before any energy trading the system should optimise the consumption (both energy efficiency and demand response) in line with the Energy Efficiency First directive. Finally, the 57% of the participants will mostly complain under failures of the system but will not leave the program. In fact, a nonnegligible amount of people (34%) would be willing to change their behaviour in order to reduce the possibility of a system failure next time.

Qualitative outcomes
The results obtained in the qualitative section of the questionnaire refer to the risks and threats associated with automatic trading systems. The participants were asked to provide risks and threats for an autonomous system based on blockchain technology. From the 832 responses 1291 unitary risks were obtained (i.e. respondents provided more than one threat per entry).
The unitary risks were analysed via thematic analysis (Braun & Clarke, 2006), a qualitative method in which codes are generated from the data rather than relying on pre-existing categories. Initially, the codes started to emerge from the data. However, at one point of the analysis showed that the codes were pretty similar when it came to analyse P2P Energy and Flexibility Markets (Zabaleta et al., 2020). Therefore, it was decided to use these categories and subcategories to tag each risk associated with blockchain-enabled smart energy contracts. The label "Other" is used if a barrier in the taxonomy below did not fit with that risk, and "None" is used if a participant did not provide any risk (Figure 2).
In Figure 3, it is provided an overview of the codes extracted under the two categories. Thus, each risk is labelled with the main level of barriers (Current Lifestyles, Administrative, Standardization, Trust, Technical and Cost) and the second level (all the labels under the  first category's branch). This plot shows that the main risks associated with autonomous systems and smart contracts are related to their technical feasibility followed by concerns on trust on autonomous systems and how these can be fairly managed to avoid abuse or resources hoarding. In a lower position, some concerns arise related to the system cost or how these new smart systems impact on current lifestyles. When breaking down each of the different main risks in their specific second-order risks, more insights come to the floor ( Figure 4). Still, the overarching risk is associated with the technical feasibility. Specifically, it can be observed that the main threat is related to the biases the trading algorithms may have in their conception and development phases ("no information about how the system makes the decisions"), as well as the risk related to system failures such as errors in the distribution equipment. For example, one participant reports: "First of all, if it's all automatic there is always the risk of irregular consumption so the system might buy water when it's not actually needed" or "Selling a surplus that I actually needed thus not having enough water". In some cases, participants are concerned on how the autonomous system will deal with unexpected circumstances: "Inability to modify your need for water according to differences in consumption (for example, you may be having overnight visitors and hence need more water at some point". Such a threat is very connected with the system's reliability. As can be observed in the Figure 4, 173 comments refer to the stability of the overall system. Overall, the concerns are related to ensuring always have "water" when needed: "Participants get frustrated with possible water shortages and pull out of the trading system before giving it a chance to optimise its parameters or make changes to be more stable". In this regard, many respondents voice the geographical factor as a risk for a system that relies on the environmental conditions to work: "Everyone has a deficit at the same time if we all live in the same area".
The lack of regulation of the system is a recurring concern among participants from all member states. Through the obtained quantitative data, it has been observed that people preferred a system managed form a private and external contractor. However, 225 excerpts are related to system abuse, hoarding, monopoly, corruption or non-neutrality. Interestingly for the proposal of blockchain use for smart contracts, some respondents report that a risk could be: "Not transparent transactions", "The possible corruption of the company which is in charge of the trade" or "If everyone goes automated, with very strict decision making, this market could easily be gamed by someone with enough capital".
As it is observed in the main risks plot, Trust in the system is identified as a major risk. Specifically, the risks are related to Confidence (Security and Privacy) and Cooperation between end users/prosumers. The former refers to all threats related to system compromise because of hackings, anonymisation or bugs. One respondent reports: "Main risk would be a cyber-attack that messes with the prices of the trades for someone's advantage" also there are concerns related to system openness: "Lack of transparency on the mechanism". The latter refers to the trust that peers have on other peers and neighbours with whom they will share the autonomous trading system. In this case, distrust appears with voices such as Respondent 48 pointing out: "Someone might want to profit more than other participants and try to exploit the system" or Quote 1033: "Homeowners with larger surface area (wealthy homeowners) collect and sell more water compared to small-home owners so the price per litre of water is not equal for everyone which creates social issues". When their society is more habituated to centralised systems or they live in individualist societies, a factor that emerges in some comments is: "you are dependent on others", "lack of oversight by some members", or "neighbour loyalty".
The majority of risks associated with Cost are related to the Return of Investment, the high price of entry into the system and the low margins it may bring. The pecuniary comments are very related to the reliability on the system: "If there is a smart contract error in the system it could all go wrong and my water could be sold for a very low price or I would be buying at a very high price", "Ending up with a huge bill because the system bought super-expensive water during an unexpected circumstance such as a drought" or "Assuming the system doesn't take into account the amount of income for the transaction, you can find yourself with a debt you didn't expect".
Finally, there are several risks associated with the impact of autonomous systems in Current Lifestyles, overall concerning the lack of control over the system (Involvement and Reluctance): "Do not have fully control of the process", "Automation without human error management" or not being able to adjust the system manually: "It's not clear whether you can change the system to temporarily to reflect your new needs". Again, sometimes participants report concerns when it comes to unexpected situations that they cannot control: "if the sellers or buyers themselves cannot check the system and everything runs automatically this could lead to problems when there are certain unforeseen situations holidays, increase of people in one of the households, etc.". Also, over-reliance in technology is identified as a risk for some participants: "People could become too reliant on an automated system and if something goes wrong the threat will be serious" or "Relying too much on a technical system without backups or emergency plans".

Legally enforceable smart contracts
As described in the current section, one of the main concerns of the prosumers is the legal and regulatory aspects of blockchain-enabled smart contracts. These concerns arise mainly due to the lack of standardised regulations as well as due to the fact that blockchain technology and smart contracts have not yet been mature enough in the legal field. Towards addressing the lack of regulation and policies over smart contracts and considering the public acceptance of them within PEMs, the authors raised the following questions that need further investigation: (a) What makes a contract legally enforceable?, (b) What variables are getting affected by legally binding smart contracts?, (c) Are there any jurisdictional variations? and (d) Are smart contracts GDPR compliant? All these questions are investigated in the following section, describing how far smart contracts can be leveraged for a legally compliant and automated operation of a P2P energy market.
Even though there are some steps towards regulating cryptocurrencies ) (i.e. the primary focus of blockchain), a little effort has been given to the legal and regulatory aspects of smart contracts. Businesses need legally binding agreements for secure operations. Contractual agreements are especially important when dealing with parties with whom you do not have a direct relationship. Conventional contracts are written up, verified and enforced by objective third parties. These could be lawyers, banks, insurance firms and others. Yet, legally enforceable smart contracts allow direct communication between the transacting parties (O'Shields, 2017). Smart contracts are increasing in popularity because they can save time, money and they also reduce the human intervention during the fulfilment of contractual obligations. Conventional and smart contracts are fundamentally varied in the way they are developed and presented. Conventional contracts are written in legal or legible human languages. Yet, smart contracts are written in code, as it will be described in Subsection 3.1

What makes a contract legally enforceable?
Even though a smart contract has a legally binding force, the technology in which it is implemented may often give rise to legal enforceability problems (i.e. especially in the case of a permission-less distributed ledger). A key feature of a smart contract is that once the code is entered on the blockchain, it becomes irreversible, and once a trigger event has been fulfilled, its output cannot be arbitrarily prevented or varied by any party. The novel problem of smart contracts is what happens when an arrangement can be executed not by enforcers of public law but by the terms and conditions laid down in the contract itself (Raskin, 2017). The accused party would need to go to court with a smart contract to resolve a contract that has either been or is in the process of being enforced. This is because a smart contract is already being executed by definition, or in the process of being executed by the time the court hears the case.
In order to understand how smart contracts could be placed within the law, formation, performance, and breach should be taken into consideration. A contract is an agreement between two or more parties with mutual obligations that can be enforced by law (Kim & Gilkis, 2019). Legally enforceable contracts are validated on the presence of the following elements: (i) Mutual assent, (ii) Expression and acceptance of a valid offer, (iii) Adequate consideration, (iv) The capacity to enter a binding contract and (v) Legality. Even if, the incorporation of smart contracts within business brings several benefits, there are also practical and legal considerations to be considered by the parties when developing and implementing smart contracts on a blockchain. To be legally enforceable, smart contracts must meet the primary attributes of a conventional written contract (Raskin, 2017). The use of legal terms and language when developing conventional contracts ensures compliance with the above requirements. Yet, smart contracts are written using computer codes that are read and carried out by computers. As such, broader considerations go into the interpretation and compliance requirements to make smart contracts legally enforceable.
Two regulatory authorities considered for this study are (i) The Rome I Regulations for contracts in the EU (European Parliament, 2008) and (ii) The United States Contract Law (Kim & Gilkis, 2019). The US contract law simplifies the requirements for an agreement to qualify as a legally binding contract into the following three considerations: (i) There must be a meeting of the minds, (ii) There must be an offer and acceptance and (iii) There must be an exchange of consideration.

Legal and regulatory aspects
The usage of smart contracts can offer technical benefits due to their highly automated behaviour, and the reduction of needs of intermediaries. However legal and regulatory aspects have to be considered. To be legally enforceable, smart contracts must meet the primary attributes of a conventional written contract (Giancaspro, 2017). The following challenges have been identified: • Jurisdiction: blockchain by its decentralised nature is not tied to a specific national or regional authority. • Anonymity: courts need to be able to precisely identify the disputing parties.
• Immutability: if not designed for upgradability blockchain smart contracts are immutable by their nature. If dispute resolution protocols are not built-in the smart contract itself litigation and disputes could be challenging to be resolved. • Legal consideration: smart contracts should include all the characteristics that uphold conventional contracts to be legally enforceable.
The best practices for legally enforceable smart contracts present several arguments in support of hybrid smart contracts over stand-alone smart contracts. Human intervention is necessary for the interpretation of the variations between the spirit and letter of the law. While smart contracts are rigid and inflexible, conventional contracts offer room for reason in their interpretation. Hybrid smart contracts can use traditional documentation to cater for areas of contracts that may not be translated easily in computer code. These include features such as the governing laws, dispute resolution, force majeure, fallback mechanisms and indemnification for coding errors and other issues.

Blockchain enabled smart contracts and GDPR
In the near future, smart contracts are expected to evolve and develop to take automated decisions that may be driven by data from EU residents. As a result, decisions and measures made under the GDPR law may be challenged. In the case of a stored smart contract within a public blockchain, which does not contain any programmability to deal with the reversal of the decisions it will take, consequentially it will not comply with GDPR, and the smart contract issuer could be held liable (Corrales et al., 2019). In order to resolve this issue, one could assume that the personal data of EU residents could not be included within a smart contract. Following this solution though, the context moves away from the legally enforceable smart contract, since this could reduce the usefulness of the smart agreement, such as energy transactions tracking, supply chain tracking and more. To resolve the abovementioned issue, it should be ensured that all stored personal data within a smart contract are encrypted. At this point, a question arises, whether encrypted and hashed data are still personal data. This analysis highlights the difficulty in determining whether data that was once personal data can be "anonymized" enough in order to meet the GDPR threshold.
Although the issues mentioned before are under debate, blockchain technology and smart contracts might be a suitable tool to achieve some of the GDPR's underlying objectives. Blockchain and DLTs can be built to allow data sharing without the need for a third party and provide transparency to the accessed data. Moreover, smart contracts can also automate data sharing, thus reducing transaction costs Rieger et al., 2019). It should be emphasised that, even if the automated decision-making process is necessary to verify or execute a contract between the data subject and the data controller, the controller is obliged to take some necessary measures: (i) Ensure that the data subject is able to receive human input (thus violating full process automation), (ii) Express different point of views on the relevant results and (iii) Contest decisions that may arise from the proceedings.

Smart contract's regulation in Europe
The European Union (EU) is persuaded that blockchain technology will play a crucial role in developing the Single Digital Market for Europe, driving important developments in the industry. It is important to note that currently "smart contracts" actually have no legal consequences, they are not enforced by the law. It is only a piece of code recorded on the blockchain that will auto-execute once it has been deployed. Thus, the interaction of blockchain, smart contracts, and law is essential. In order to harmonise those technologies, there are some points to be considered to create a holistic European regulatory framework.

Based on the European blockchain Observatory and Forum those include Lyons et al. (2019):
• Create simple and usable definitions of blockchain technology and smart contracts that can be used as shared definitions for EU and Member State regulators. • Widely communicate legal definitions, in order to have a mutual understanding among regulators such as IDAS (Electronic Identification, Authentication and Trust Services) and the GDPR. • Blockchain and smart contracts' regulation should harmonise the law and interpretations in all European countries. • Develop a common understanding of the technology, to train accordingly the regulators and policy makers. • Focus on mature smart contract use cases.
With these in mind, United Kingdom has taken some significant steps towards this direction. In November 2019, Geoffrey Vos, Chancellor of the UK High Court announced the launch of a "Legal Statement on Crypto Assets and Smart Contracts", which he described as a "watershed moment" for English Law. Among other key points, in the statement is pointed out that a smart contract has all the attributes of a contract under English law: (i) two or more parties have reached an agreement; (ii) the parties intend to create a legal relationship; and (iii) the terms of the relationship depend on the parties' words and conduct "just as it does with any other contract". Also, it is stated that wherever rules require a written signature, those requirements can very likely be met using a private key, or a code element "recorded in source code". Overall, the take-away is that "there is no reason why the normal rules should not apply just because a potential contract is a smart contract". It is obvious that the flexibility of English law helps to adapt new technologies such as blockchain-enabled smart contracts (Corrales et al., 2019).
Legally enforceable smart contracts have come a long way since their inception. Yet, the continuous evolution of technology puts constant pressure on judicial systems to adapt to overcome enforcement limitations. The best practices for legally enforceable smart contracts present several arguments in support of hybrid smart contracts over standalone smart contracts. Human intervention is necessary for interpretation of the variations between the spirit and the letter of the law. While smart contracts are rigid and inflexible, conventional contracts offer room for reason in their interpretation.
For these reasons the smart contracts developed in automatic trading systems cannot be self-contained and legally enforceable, but they will implement automatic mechanisms following terms and conditions described in traditional contract documents: SLA agreements, international and national laws and regulation.

Technical challenges
Energy trading costs can be minimised with blockchain, while also the latter may offer transparent data that can be accessed by a variety of parties, including agencies that can verify regulatory compliance. Blockchain might cut out any middleman, perhaps increase trade volumes, allowing small-scale customers to engage in the energy market (Andoni et al., 2019). However, while adopting blockchain in the energy sector, technical challenges regarding blockchain throughput and scalability arise. The constraints of throughput, as well as latency, are frequently debated when it comes to scaling a blockchain . When blockchain is utilised as a database, it is regarded slow, and determining its boundaries is more difficult than it appears. Several factors such as the consensus algorithm used influence how quickly a transaction can be completed and what the transaction rate would be. Another key concern is having sensitive data publicly available to all. Platforms that give end users access to energy markets can help the grid unleash new flexibility services. Furthermore, such activities can boost customer knowledge and choice over their energy source, perhaps leading to speedier switching and increase competition.

Discussion and recommendations
In this section, we will discuss the results obtained and provide some recommendations in order to improve the social acceptance of PEM based on smart contracts.
The first recommendation is that any PEM solution should have at least two modes of operation: a complete autonomous mode for the "lazier" people and a semi-autonomous mode where the system would collaborate with prosumers. Please note that the default mode should be the semi-autonomous mode as it is the most solicited (around 60% of the potential prosumers) and it is in line with some of the risks identified related to involvement. In fact, the system should also allow prosumers to audit each transaction and complain about any error. This is very in line with the risks associated with Current Lifestyles and Trust, overall, under unexpected circumstances such as friends coming to the house or working at home. Please note that 60% of the potential prosumers will complain if an error in the system is found but would not leave the system immediately. In fact, if the system is able to provide explanations of what had happened and cues about how the user could avoid these problems in the future (openness and explainability of the autonomous system and a hybrid approach seem to be quite relevant here), around 35% of the prosumers would be willing to follow them.
The second recommendation is that the platform should be run by a neutral company hired by the participants (near a 40% of answers). A lot of emphasis must be put on convincing users about their neutrality and the no intention to make profit or abuse the PEM. In fact, according to the results of the risks, they should make people think that the system is reliable and robust under potential system errors or cyber-attacks. A platform run by a public authority could also be an option (25%) but a fully decentralised solution seems like not very appealing to the end users (only 15%). In fact, this has been highlighted in the risk assessment when the respondents provided low confidence in the prosumers cooperation. A hybrid solution seems to be the ideal option.
Regarding the business model, the results suggest that a revenue model based on a fee per transaction will be accepted if the fee charged is less than 5% of each transaction. Simulations should be run in order to assess if this fee is enough to recover the costs and leave a margin of profit. If not, improvement on the system should be carried out or another business model should be sought. However, there is a major risk that people will not participate because of the initial investment or because they do not rely on the potential Return on Investment (ROI).
Finally, there does not seem to be any issue leaving the smart contract in charge of buying or selling energy as more than 60% of the end users would be willing to accept both. Nevertheless, half of the answers consider that the system should also optimise the energy consumption (including energy efficiency and energy conservation actions) before following any demand response signal. The main risk here is that people need the system to ensure the resources (electricity, water) at any time and upon any unexpected circumstances. If the system has to buy more resources to ensure the availability and the cost is higher than the usual, the user should always have to give the last consent.
Nevertheless, the actual research presents several limitations that should be taken into consideration. The first and most obvious one is the implicit transferability assumption we have made presenting the problem from the water domain instead of the energy sector. Even as the authors think that this is a very reasonable hypothesis, the answer from the survey was quite positive and support this hypothesis. For example, lots of respondents explicitly said that the survey was clear, several of them think this technology was going to exist on the near future ("It is in general the direction in which the future is pointing us and someday I think humanity will need something like that") and one got the simile right ("It was very interesting idea of water trading. Such systems could apply in renewable energy sources").
The second clear limitation of the paper is the lack of a proper descriptive assessment of the answers. In particular, it has not been assessed if there are differences in the answers provided depending on the region, gender, socio-economic status or previous knowledge. The information collected allows for such an assessment as the sample size is large enough to perform some (if not all) such comparisons. Nevertheless, the authors have considered that the actual document is already complex enough and this assessment would need a different approach to assess and present the results (see next point).
Finally, the third main limitation of the research done is the sampling method used. The method used by Prolific does not warranty to get a proper randomised sampled outside of USA or UK regions (Team, 2022). In our case, this could hinders the generalisation of the results but given the actual size of the sample obtained, post stratification methods could be used (Qian, 2010). In a future research article, the authors pretend to finish this assessment.
Taken into consideration the aforementioned, we recommend the following directives in terms of the social, legal and technical aspects of blockchain-enabled PEMs. Although, it should be clearly stated that the objective of this is not to provide at this point policy recommendations/advises. Policy recommendation will come later on, after implementation and evaluation of our work. Having said that, the first thing that should be mentioned in respect to the social aspects is the fact that conflicts of interest between the involved participants should be tackled. For instance, in order to tackle the risks associated with cost, mechanisms that would maintain a price cap on the services provided and managing possible trade-offs in an optimal way should be considered . In relation to the legal aspects, prosumers should have direct access to their energy-related data in order to make informed decisions when switching suppliers or providers and to make use of the blockchain technical solutions. Prosumers should also be able to regulate how their personal data is used by third parties (GDPR compliance). Better access to reliable data from important industry actors is critical for the market. It is important to support data access and sharing for fair market competition, while also preserving consumers' privacy through GDPR compliance (Zhang et al., 2021). Finally, in terms of the technical aspects of the blockchain integration within PEMs, the main aspect that should be taken into consideration is the hardware requirements. Most of the technological solutions (e.g. Stellar, Energy Web Chain, Hyperledger , etc.) require significant resources, especially in terms of memory and disk usage. Thus, it is important to know apriori the use case, in order to select the most suitable blockchain. Moreover, blockchain solutions developed for PEMs should be able to interact with other chains to exchange critical data (i.e. fungible and non-fungible tokens exchange) (Strepparava et al., 2022). Finally, for economic efficiency and supply reliability, market processes should have suitable synchronisation mechanisms across them, particularly if the same assets will deliver different services to multiple market processes.

Conclusions and future work
Flexible and distributed energy markets are a reality that is progressively reaching many regions of the world. They offer key benefits in many environments where energy production and consumption takes place in close geographic areas between particular agents that play the dual role of energy producers and consumers (prosumers).
Despite the clear benefits that no one disagrees with, these markets must be accepted by the ultimate protagonists who are the final prosumers. And if these markets are not designed with this reality in mind, they run the risk of failing miserably. This paper has analysed the reluctance or concerns of potential end users and offers a rigorous analysis together with very relevant recommendations for the design of any flexible energy market.
Among these concerns, we highlight those related to information transparency to ensure a fair and secure market. A key information exchange in these markets will be the contracts between prosumers or intermediaries. The digitisation of these contracts through smart contracts, based on blockchain technology, is one of the natural steps in these markets. Although, we recommend that, in order to facilitate their legal fit, it is advisable to design hybrid contracts that solve the most unforeseen and delicate cases. Blockchain will be one of the key technologies in the proliferation of flexible and distributed markets. It will provide security and transparency to many of the information flows that will be generated between energy prosumers. But other fundamental aspects in the design and deployment of these markets should not be ignored, as we run the risk of believing that technology fixes everything, and nothing could be further from the reality. The coexistence of autonomous and semi-autonomous modes of operation is considered fundamental. As it is the guarantee of the neutrality of the intermediary agent between prosumers. It is highly recommended that any flexible market should first suggest improving consumption before going to market, although there are other aspects that are more complex to generalise, such as exploitation models and the use of fees. In this case, it is recommended to simulate several options and always give the prosumers the option to participate in the design of the best solution. Moreover, in regard to the blockchain integration within these markets, we believe the future development should mainly focus on the acceptance and legality of this technology. Assuming that smart contracts can be made to operate with more security, legality and flexibility, we may expect that they will be widely used in the energy industry, and especially in PEM. Finally, we concluded that these proposals and recommendations have to be tested per country instead of the whole Europe at the same time.
The main reason is that specific nuances and social-legal aspects in each country may impair the acceptance of these technologies and contracts and each country will require tailored interventions depending on the energy context and the development of the markets.