Design and Implementation of a Blockchain-Based Energy Trading Platform for Electric Vehicles in Smart Campus Parking Lots

: This paper proposes a blockchain-based energy trading platform for electric vehicles in smart campus parking lots. Smart parking lots are smart places capable of supporting both parking and charging services for electric vehicles. The electric vehicle owner may want to charge energy at a low price and sell it during peak hours at a higher price. The proposed system architecture consists of two layers: the physical infrastructure layer and the cyber infrastructure layer. The physical infrastructure layer represents all of the physical components located in the campus distribution power system, such as electric vehicles charging stations, transformers, and electric feeders, while the cyber infrastructure layer supports the operation of the physical infrastructure layer and enables selling / buying energy among participants. Blockchain technology is a promising candidate to facilitate auditability and traceability of energy transactions among participants. A real case of a parking lot with a realistic parking pattern in a university campus is considered. The system consists of a university control center and various parking lot local controllers (PLLCs). The PLLC broadcasts the electricity demand and the grid price, and each electric vehicle owner decides whether to charge / discharge based on their beneﬁts. The proposed system is implemented on Hyperledger Fabric. Participants, assets, transactions, and smart contracts are deﬁned and discussed. Two scenarios are considered. The ﬁrst scenario represents energy trading between electric vehicles as sellers and the PLLC as a buyer, while the second scenario involves energy trading between electric vehicles as buyers and the PLLC as a seller. The proposed platform provides proﬁts for participants, as well as enables balancing for the university load demand locally. of


Introduction
Nowadays, the distribution power system is experiencing fundamental changes with the increasing number of distributed energy resources (DERs), such as small-scale wind turbines, photovoltaic systems, energy storage systems, and electric vehicles. With these developments in DERs, many end-users are transforming from energy consumers to energy prosumers. Energy prosumers are able to generate and consume energy at the same time. During the periods of mismatch between supply and demand, energy prosumers and energy consumers can interact with each other and trade energy locally over a the authors in [16] proposed a Hyperledger-based emission trading system in order to improve the existing centralized systems.
The operation of the energy trading platform and the integration of various participants require an innovative, secure, and smart information system [3]. Most of related works have provided a high-level description of blockchain-based energy trading systems in the distribution power network [3,4,10,11,15,16]. However, detailed technical descriptions and implementation of blockchain-based energy trading systems are missing. Therefore, this work aims to fill this gap by providing detailed technical description for the system design and the platform implementations for a blockchain-based energy trading platform for electric vehicles in smart campus parking lots. The work done in this paper is an extension to our recent work in [17] by implementing a blockchain-based energy trading platform. The main contributions of this work are: • A system architecture for energy trading in a smart campus parking lot is proposed. It consists of two layers: the physical infrastructure layer and the cyber infrastructure layer. • A local energy trading blockchain-based platform is designed for selling and buying energy among electric vehicles in university campus parking lots. The system reduces dependence on the main grid and reduces the peak demand of university buildings. • A case study scenario concerning smart parking lots located at the Chonbuk National University of South Korea is evaluated for three different market mechanisms, where approved transactions are recorded and shared on the platform.
The rest of the paper is organized as follows: Section 2 presents a framework for an energy trading platform in smart campus parking lots. Section 3 discusses the main elements of the blockchain-based energy trading platform: participants, assets, and transactions. Section 4 presents the implementation of energy trading platform. Section 5 evaluates the performance of the proposed energy trading platform, considering a case study of smart parking lots located at the Chonbuk National University of South Korea. Section 6 provides the conclusion of the paper.

Proposed System Architecture for an Energy Trading Platform in Smart Campus Parking Lots
The proposed system architecture of an energy trading platform consists of two layers: the physical infrastructure layer and the cyber infrastructure layer, as shown in Figure 1.

Physical Infrastructure Layer
The electric vehicle system is a complex cyber-physical system. The physical infrastructure layer represents all of the physical components located in the local distribution power system that supports the parking lot operation. It consists of electric vehicle charging stations, transformers, electric feeders, smart meters, etc. The electric vehicle represents a logical device that consists of various attributes, such as availability (arrival time and departure time), battery parameters (battery capacity and current state of charge (SoC)), user preferences, type of charging, battery state of health, etc.

Cyber Infrastructure Layer
The cyber infrastructure layer supports the operation of the physical infrastructure layer. Internet of Things (IoT) devices such as sensor nodes, smart meters, and monitoring devices are responsible for collecting data from electric vehicle subsystems. IoT devices are equipped with different communication interfaces, as well as embedded processors, that are connected to the blockchain layer. The blockchain layer handles the data from IoT devices and enables decentralized data storage. Furthermore, the cyber infrastructure layer enables members of the energy trading network to publish and bid the amount of energy and the energy price. Data gathered from electric vehicle subsystems and IoT devices are stored in system servers. All transaction data are traceable and non-tamperable.

Blockchain-Based Energy Trading Platform
In order to adapt to the increasing number of electric vehicles, Chonbuk National University is moving forward to transform conventional parking lots into smart parking lots. Smart parking lots are smart places capable of supporting both parking and charging services for electric vehicles. Charging infrastructures supported by different companies and vendors will be installed in campus parking lots in order to provide charging and discharging services for electric vehicles. The smart parking lot consists of electric vehicles, charging stations, and parking lot local controllers (PLLCs). The PLLC plays a major role in managing the charging/discharging operation of electric vehicles. Figure 2 shows the main elements of the blockchain-based energy trading platform for smart parking lots at Chonbuk National University, South Korea. The proposed energy trading platform supports the charging services for electric vehicles, exchange of energy between electric vehicles and PLLCs (charging infrastructure from different service providers), exchange of energy among PLLCs, and energy exchange between PLLCs and the distribution system operator (DSO).
Considering the high power consumption of university buildings during on-peak periods, the new charging infrastructures installed in parking lots will enable energy trading between electric vehicles and PLLCs in order to support the university high-peak demand. A university control center (UCC) will be responsible for monitoring the operation of new parking lots in order to ensure reliable operation and services. The proposed blockchain-based energy trading platform aims to connect among different organizations (UCC, PLLCs, and DSO). The platform aims to enable the UCC to trace and audit campus energy transactions, as well as to provide transparency for energy trading among parking lot operators.
This section describes the basic elements of the energy trading system. The three major components that compose the blockchain system are peers, ordering service, and certificate authority.

Blockchain-Based Energy Trading Platform
In order to adapt to the increasing number of electric vehicles, Chonbuk National University is moving forward to transform conventional parking lots into smart parking lots. Smart parking lots are smart places capable of supporting both parking and charging services for electric vehicles. Charging infrastructures supported by different companies and vendors will be installed in campus parking lots in order to provide charging and discharging services for electric vehicles. The smart parking lot consists of electric vehicles, charging stations, and parking lot local controllers (PLLCs). The PLLC plays a major role in managing the charging/discharging operation of electric vehicles. Figure 2 shows the main elements of the blockchain-based energy trading platform for smart parking lots at Chonbuk National University, South Korea. The proposed energy trading platform supports the charging services for electric vehicles, exchange of energy between electric vehicles and PLLCs (charging infrastructure from different service providers), exchange of energy among PLLCs, and energy exchange between PLLCs and the distribution system operator (DSO).
Considering the high power consumption of university buildings during on-peak periods, the new charging infrastructures installed in parking lots will enable energy trading between electric vehicles and PLLCs in order to support the university high-peak demand. A university control center (UCC) will be responsible for monitoring the operation of new parking lots in order to ensure reliable operation and services. The proposed blockchain-based energy trading platform aims to connect among different organizations (UCC, PLLCs, and DSO). The platform aims to enable the UCC to trace and audit campus energy transactions, as well as to provide transparency for energy trading among parking lot operators.
This section describes the basic elements of the energy trading system. The three major components that compose the blockchain system are peers, ordering service, and certificate authority.

•
Peer is a network entity that commits transactions and maintains a ledger in conjunction with the support of the ordering service. Smart contracts run on this ledger and let assets move and transactions occur according to the business logic defined by the participants of the network.

•
Ordering service (OS) establishes the ordering of the blocks in the ledger in a decentralized fashion. In addition, this component allows for events to be broadcasted among all the participants. • Certificate authority (CA) is an entity that issues enrollment for participants. • Peer is a network entity that commits transactions and maintains a ledger in conjunction with the support of the ordering service. Smart contracts run on this ledger and let assets move and transactions occur according to the business logic defined by the participants of the network.

•
Ordering service (OS) establishes the ordering of the blocks in the ledger in a decentralized fashion. In addition, this component allows for events to be broadcasted among all the participants.

•
Certificate authority (CA) is an entity that issues enrollment for participants.

Participants
A participant is anyone who can trade in the system. The participants are defined as entities that are involved in buying/selling in the parking lots. The energy trading network consists of three types of participants: selling electric vehicle (SEV), buying electric vehicle (BEV), and the parking lot local controller (PLLC). Participants are represented by unique IDs.
• SEVs (owners) are willing to sell part of their energy.
• BEVs (owners) are willing to buy energy.
• PLLC is willing to sell/buy based on grid condition.

Assets
Owners of the electric vehicles have to register their vehicle as an asset in the blockchain network. The registration should include a unique ID for the vehicle "EViD" and a unique owner ID "OwneriD". We defined two major assets: Energy and kWhlisting.
• Energy: It represents the main asset in the system, and it can be traded among all participants.
• kWhlisting: This asset is generated automatically by the system. It includes the following information, such as available energy "kWhavailable", required kWh "kWhrequired", selling offer "SellOffer", and buying offer "BuyOffer".

Participants
A participant is anyone who can trade in the system. The participants are defined as entities that are involved in buying/selling in the parking lots. The energy trading network consists of three types of participants: selling electric vehicle (SEV), buying electric vehicle (BEV), and the parking lot local controller (PLLC). Participants are represented by unique IDs.
• SEVs (owners) are willing to sell part of their energy. • BEVs (owners) are willing to buy energy. • PLLC is willing to sell/buy based on grid condition.

Assets
Owners of the electric vehicles have to register their vehicle as an asset in the blockchain network. The registration should include a unique ID for the vehicle "EViD" and a unique owner ID "OwneriD". We defined two major assets: Energy and kWhlisting.

•
Energy: It represents the main asset in the system, and it can be traded among all participants. • kWhlisting: This asset is generated automatically by the system. It includes the following information, such as available energy "kWhavailable", required kWh "kWhrequired", selling offer "SellOffer", and buying offer "BuyOffer".

Transactions
The proposed system enables each electric vehicle owner to participate in energy trading. The basic transactions are sell energy to the PLLC, buy energy from the PLLC, and notifications from the PLLC about bidding process. The list of participants, assets, and transactions is shown in Table 1. The buy offer transaction and the sell offer transaction are shown in Algorithms 1 and 2, respectively.

Algorithm 1 BUYOffer Transaction
Input: KWHlisting (Blockchain Asset), BuyOffer (Object that contains information of the submitted offer: EV, Qty, Price), EVState (State of the EV, available status are SEV, BEV), KWHlistingState )represents the state of the listing, available status are 'Accepting Offers' and 'Closed Offers') Output: listingBuyOffers (Array of all the buying offers) 1. if KWHlisting.state is equal to "ACCEPTING OFFERS" then 2: if EVState is equal to BEV then 3: listingBuyOffer.push(buyOffer); 4: KWHlisting.update(listingBuyOffers); 5: else 6: This EV is not allowed to BUY. 7: end 8: else 9: The listing is not accepting offers. if EVState is equal to SEV then 3: listingSellOffer.push(sellOffer); 4: KWHlisting.update(listingSellOffers); 5: else 6: This EV is not allowed to SELL. 7: end 8: else 9: The listing is not accepting offers. 10: end Notifications from the PLLC about status of the bidding process.

Parking Lot Energy Trading Mechanism
In smart campus parking lots, electric vehicle owners are allowed to sell/buy electricity to/from the PLLC to achieve a win-win outcome. This includes receiving more profits for selling electric vehicles (SEVs), while saving costs for buying electric vehicles (BEVs). Figure 3 shows the flowchart of the proposed energy trading platform. Selling electric vehicles is denoted as SEVi, i = 1,2, . . . .,N where electric vehicles have extra power and are represented as energy providers. Buying electric vehicles is denoted as BEVj, j = 1,2, . . . ,K where electric vehicles require power demands for charging and are represented as energy consumers.  We considered a time period for energy trading consisting of two parts: A bidding period and an energy transfer period. All electric vehicle owners are allowed to submit their offers/bids, including quantities and prices, during a certain time window. As soon as this time window is closed, the platform no longer accepts any more offers/bids. The platform determines the local market price using a market mechanism and selects a set of electric vehicles who should trade with based on the local market price.
Three market mechanisms are considered to define the parking lot local market price: Grid-to- We considered a time period for energy trading consisting of two parts: A bidding period and an energy transfer period. All electric vehicle owners are allowed to submit their offers/bids, including quantities and prices, during a certain time window. As soon as this time window is closed, the platform no longer accepts any more offers/bids. The platform determines the local market price using a market mechanism and selects a set of electric vehicles who should trade with based on the local market price.
Three market mechanisms are considered to define the parking lot local market price: Grid-to-vehicle (G2V), mid-market price (MMP), and auction-based price (APP) [18][19][20][21]. The G2V mode is the conventional base case for charging. The electric vehicle owner charges from the power grid using a predefined utility price (grid price). Equation (1) shows the cost of buying energy from the grid COST BFG,t .
where P BFG,t Power bought from the grid in kW p BFG,t Electricity buying price in money unit per kWh ∆t Length of scheduling time interval SEVs/BEVs are self-interested in economic benefits. All offers/bids of the electric vehicle owners are confidential to other electric vehicles. In the mid-market price mechanism, the market clear price is calculated as the average price among all participants. For example, in the case of buying electric vehicles, only electric vehicles with higher or equal price bids are selected for participation. Equation (2) shows the mid-market price for selling electric vehicles MMP SEV,t , while Equation (3) shows the mid-market price for buying electric vehicles MMP BEV,t . After the market clear price is determined, the PLLC selects a set of electric vehicles that satisfy this condition. In the auction-based mechanism, Equation (4) shows the total cost for buying energy from the SEVs COST BFV,t , while Equation (5) shows the total cost for selling energy for BEVs COST STV,t . The PLLC selects a set of electric vehicles that satisfy this demand based on the first-come-first-serve (FCFS) scheme or the Knapsack Algorithm (KPA) [17]. In the FCFS scheme, the PLLC selects electric vehicles that request the service first, while in KPA the PLLC sorts EV's revenue in ascending/descending order with the objective of minimizing/maximizing the cost of buying/selling energy. Finally, the PLLC notifies the winning vehicles to proceed in the energy transfer process.
where P BFVi,t Discharge power from SEVi in kW p BFVi,t Electricity price in money unit per kWh N Number of SEVs ∆t Length of scheduling time interval where P STV j,t Power sold to charge BEVj in kW p STV j,t Electricity price in money unit per kWh K Number of BEVs ∆t Length of scheduling time interval After the market clear price is determined using G2V, MMP, or APP, the platform selects the winner based on FCFS or KPA. In FCFS, depending upon buying or selling, the system sorts the offers by timestamps and chooses the winners by adding their quantities until it reaches the desired demand amount (50 for our case). In the case of KPA, the system sorts the offers by multiplying the quantity and the price, and then it sorts them in ascending order if processing a buying trade, and in descending order otherwise. Then, it chooses the winners that satisfy the quantity needed.

Implementation of Energy Trading Platform
The blockchain-based energy trading platform is configured on PCs running Ubuntu operating system [22] and hosting an REST API, Hyperledger Composer [23], and Hyperledger Fabric [24]. The proposed system considers that the electric vehicle owner interacts with the energy trading platform via an application interface. This application interface enables the user to register himself as an electric vehicle owner, register his electric vehicle, and participate in the energy trading platform by selling or buying energy. The following five key elements were considered in our implementation: User Interface, REST API, MongoDB, Hyperledger Composer, and Hyperledger Fabric.

User Interface
The user interface is developed in Vue [25]. Vue is a progressive JavaScript framework that has grown in popularity for its quick and easy capabilities of developing user interfaces. The user interface is intended for the user to interact with the platform. The interactions in the view trigger requests that are sent to an REST API. The following views are designed:

•
User registration: This view allows the registration of a user into the platform.

•
Log in: This view allows the user to access to the platform. • Electric vehicle registration: Once a user is logged in, the user can register the electric vehicle for later interaction in the platform.

•
Selling energy: In this view, the user can offer any amount of his available energy for selling.

•
Buying energy: This view allows a user to bid for energy.

REST API
A REST API is implemented in order to attend requests coming from the user interface. The REST API is done in Node.js with Restify [26]. All the requests to the API use JSON Web Token (JWT) [27], RFC 7519. The JWT is used to secure requests. The REST API deals with the following functionalities: • Receives incoming requests from users.

•
Connects to a MongoDB to store reference information related to electric vehicle owners and electric vehicles.

•
When a user requests a transaction, the API collects the information regarding the transaction, and sends a request to the Hyperledger Composer REST API, so that it can be incorporated in the blockchain.

•
When an event is received from Hyperledger Composer API, the API sends a notification to the user.

MongoDB
A MongoDB is used to store user information such as session token for a user interface, access token issued by Hyperledger CA, and personal information. For simplicity, we used MongoDB Atlas, a cloud-based service providing a reliable database for storing information [28].

Hyperledger Composer
Hyperledger Composer is an open development framework for developing blockchain applications. Composer allows modeling the business network. A detailed description of how to setup a blockchain network in given in [23]. The business network is composed of the following files: a model file, a script file, and access control file.

•
The model file defines the structure and relationships between business network elements, including assets, participants, and transactions.

•
The script file contains the transaction processor functions and the smart contract definition.

•
The access control file contains a set of access control rules that define the rights of the different participants in the business network.

Hyperledger Fabric
Fabric is a modular blockchain framework which acts as a foundation for developing blockchain-based products, solutions, and applications using plug-and-play components [24].

Simulation Results
This section evaluates the performance of the proposed energy trading platform for a smart parking lot. The parking lot of engineering building 2-7, Chonbuk National University, Jeonju campus is considered as a case study. However, the proposed platform is also applicable for other scenarios, such as communities, microgrids, and third-party trading companies. The parking lot serves faculty members, employees, and students. Five different types of electric vehicles are considered. Their manufacturing specifications are given in Table 2 [29]. Table 3 shows the electric vehicle charging tariff by Korea Electric Power Corporation (KEPCO). The energy charge is different based on time period (off-peak, mid-peak, and on-peak) and season (summer, spring, fall, and winter) [30]. We considered 10 charging stations installed in the parking lot. We assumed that the local power demand for selling/buying in the smart parking lot is 50 kW. A case study with 10 electric vehicles was evaluated as an example. The amount of selling/buying energy of each electric vehicle was considered as 50% of the battery capacity. The amount was randomly generated among different electric vehicles considered in Table 2. Different scenarios were considered for energy trading: case (1) all vehicles act as energy sellers and the PLLC as a buyer, and case (2) all vehicles act as energy buyers and the PLLC as a seller. All vehicles in scenario (1) are considered as SEVs. The energy bought from SEVs could support the load demand of engineering building 2-7 or used to charge other electric vehicles. All vehicles in scenario (2) are considered as buying vehicles. Each vehicle requests the amount of buying energy that is required for charging and the buying price that the electric vehicle owner is willing to pay. Table 4 shows the real power consumption of engineering building. In the G2V scenario, we considered a charging tariff of 232 KRW/kWh. Tables 5 and 6 show the results of the G2V charging with 10 buying electric vehicles (BEVs) requesting the charging services based on the first-come-first-serve (FCFS) scheme and the Knapsack Algorithm (KPA), respectively. In order to select a set of electric vehicles for charging, the FCFS scheme selects the electric vehicles that request the service first. For a demand of 50 kW, the PLLC selects BEV1, BEV2, BEV3, BEV4, and BEV5, with a total charging cost of about 11,600 KRW. In the case of KPA, the PLLC sorts the revenue in a descending order to maximize the PLLC revenue. The PLLC selects BEV2, BEV7, BEV10, and BEV3. Figure 4 shows the number of served electric vehicles, the total buying energy, and the total profit for 10 BEVs in G2V charging mode.

Mid-Market Price Scenario
In the mid-market price scenario, BEVs/SEVs are allowed to submit their offers/bids, including quantities and prices, during a certain bidding time. The selling/buying prices are randomly selected based on KEPCO electric vehicle charging tariff in the range of [58-232] Korean Won (KRW). The market clear price is calculated as the average price among all participants using Equation (3). In this case, the local parking lot clear price was about 158.68 KRW/kWh. Only electric vehicles with higher or equal price bids are selected for participation, as shown in Tables 7 and 8. For a demand of 50 kW, the PLLC selects BEV3, BEV4, BEV5, BEV7, and BEV8 in the case of FCFS scheme, while the PLLC selects BEV8, BEV7, BEV10, BEV5, and BEV3 in the case of KPA. Figure 5 shows the number of served electric vehicles, total buying energy, and total profit for 10 BEVs using the mid-market clear price mechanism. The results show that during some iterations, the total buying energy from electric vehicles was less than the required demand.

Mid-Market Price Scenario
In the mid-market price scenario, BEVs/SEVs are allowed to submit their offers/bids, including quantities and prices, during a certain bidding time. The selling/buying prices are randomly selected based on KEPCO electric vehicle charging tariff in the range of [58-232] Korean Won (KRW). The market clear price is calculated as the average price among all participants using Equation (3). In this case, the local parking lot clear price was about 158.68 KRW/kWh. Only electric vehicles with higher or equal price bids are selected for participation, as shown in Tables 7 and 8. For a demand of 50 kW, the PLLC selects BEV3, BEV4, BEV5, BEV7, and BEV8 in the case of FCFS scheme, while the PLLC selects BEV8, BEV7, BEV10, BEV5, and BEV3 in the case of KPA. Figure 5 shows the number of served electric vehicles, total buying energy, and total profit for 10 BEVs using the mid-market clear price mechanism. The results show that during some iterations, the total buying energy from electric vehicles was less than the required demand.

Auction-Based Price Scenario
In the auction-based scenario, BEVs/SEVs are allowed to submit their offers/bids, including quantities and prices. The selling/buying prices are randomly selected in the range of [58-232] Korean Won (KRW). For the BEV scenario, Tables 9 and 10 show the results for 10 BEVs based on FCFS and KPA, respectively. In FCFS, the PLLC selects BEV1, BEV2, BEV3, BEV4, and BEV5, while selects BEV8, BEV10, BEV5, BEV7, and BEV3 in the case of KPA. In KPA, the PLLC sorts the revenue in a descending order to maximize the PLLC revenue. As shown in Figure 6, the KPA outperform the FCFS scheme with a profit increase of about 32.27%. For the SEV scenario, Tables 11 and 12 show the results for 10 SEVs based on FCFS and KPA, respectively. In FCFS, the PLLC selects SEV1, SEV2,

Electric Vehicle Registration
This section explains the procedure for registering an electric vehicle. In order to access the platform, it is required that the electric vehicle owner enters the vehicle identification number (VIN). The VIN is a unique identification assigned by the manufacture. With the VIN number, the system is able to retrieve information regarding vehicle brand, vehicle model, and battery capacity. The user interface for electric vehicle registration is shown in Figure 8a.

Electric Vehicle Registration
This section explains the procedure for registering an electric vehicle. In order to access the platform, it is required that the electric vehicle owner enters the vehicle identification number (VIN). The VIN is a unique identification assigned by the manufacture. With the VIN number, the system is able to retrieve information regarding vehicle brand, vehicle model, and battery capacity. The user interface for electric vehicle registration is shown in Figure 8a.

Selection of the Operation Mode
After the electric vehicle owner accesses the platform, the system asks if the owner wishes to participate in the regular charging service or the energy trading service. The electric vehicle owner can select whether to participate in the energy trading process with the PLLC or buy from the grid. Selecting the regular charging service means the user is willing to charge the electric vehicle with normal grid tariffs, while selecting the energy trading service enables the user to sell/buy energy with the PLLC. This procedure can be done anytime during the registration phase. After selection, the electric vehicle owner must press accept, as shown in Figure 7b. Figure 9a shows the information retrieved from the electric vehicle system. At this stage, the electric vehicle owner can select the participation as a SEV or a BEV. The electric vehicle owner confirms the information by pressing "Accept". The electric vehicle information consists of both static and dynamic information. The static information includes vehicle brand, vehicle model, and total battery capacity, while the dynamic information includes the status of the electric vehicle (SEV and BEV), available capacity, and current state of charge (SoC). The electric vehicle owner can manage his own electric vehicle by sending a BUY/SELL request to the PLLC and waiting for the confirmation. The user interface for the selling electric vehicle (SEV) and the buying electric vehicle (BEV) is shown in Figure 9b,c. The electric vehicle owner can check both the vehicle information (ID and brand) and the battery information (total battery capacity and available SoC).

Selection of the Operation Mode
After the electric vehicle owner accesses the platform, the system asks if the owner wishes to participate in the regular charging service or the energy trading service. The electric vehicle owner can select whether to participate in the energy trading process with the PLLC or buy from the grid. Selecting the regular charging service means the user is willing to charge the electric vehicle with normal grid tariffs, while selecting the energy trading service enables the user to sell/buy energy with the PLLC. This procedure can be done anytime during the registration phase. After selection, the electric vehicle owner must press accept, as shown in Figure 7b. Figure 9a shows the information retrieved from the electric vehicle system. At this stage, the electric vehicle owner can select the participation as a SEV or a BEV. The electric vehicle owner confirms the information by pressing "Accept". The electric vehicle information consists of both static and dynamic information. The static information includes vehicle brand, vehicle model, and total battery capacity, while the dynamic information includes the status of the electric vehicle (SEV and BEV), available capacity, and current state of charge (SoC). The electric vehicle owner can manage his own electric vehicle by sending a BUY/SELL request to the PLLC and waiting for the confirmation. The user interface for the selling electric vehicle (SEV) and the buying electric vehicle (BEV) is shown in Figure 9b,c. The electric vehicle owner can check both the vehicle information (ID and brand) and the battery information (total battery capacity and available SoC).

Trading Notification from the PLLC
After the registration phase, the electric vehicle owner receives notification messages from the energy trading platform. These notification messages include start bidding, close bidding, and determine winners. Figure 10 shows notification messages from the PLLC for the electric vehicle owner, indicating the beginning of the bidding phase for energy trading (ex. PLLC wants to Sell/Buy 50 kWh). The message includes the current grid price in Korean Won per kilowatt hour (KRW/kWh). After receiving the notification of the beginning of the bidding phase, each electric vehicle owner can participate and make a transaction (selling/buying) by pressing the "+" and making an offer. The information required for making a transaction is Sell/Buy price in Korean Won (KRW) and Sell/Buy quantity in kilowatt hour (kWh).

Trading Notification from the PLLC
After the registration phase, the electric vehicle owner receives notification messages from the energy trading platform. These notification messages include start bidding, close bidding, and determine winners. Figure 10 shows notification messages from the PLLC for the electric vehicle owner, indicating the beginning of the bidding phase for energy trading (ex. PLLC wants to Sell/Buy 50 kWh). The message includes the current grid price in Korean Won per kilowatt hour (KRW/kWh). After receiving the notification of the beginning of the bidding phase, each electric vehicle owner can participate and make a transaction (selling/buying) by pressing the "+" and making an offer. The information required for making a transaction is Sell/Buy price in Korean Won (KRW) and Sell/Buy quantity in kilowatt hour (kWh).

Trading Notification from the PLLC
After the registration phase, the electric vehicle owner receives notification messages from the energy trading platform. These notification messages include start bidding, close bidding, and determine winners. Figure 10 shows notification messages from the PLLC for the electric vehicle owner, indicating the beginning of the bidding phase for energy trading (ex. PLLC wants to Sell/Buy 50 kWh). The message includes the current grid price in Korean Won per kilowatt hour (KRW/kWh). After receiving the notification of the beginning of the bidding phase, each electric vehicle owner can participate and make a transaction (selling/buying) by pressing the "+" and making an offer. The information required for making a transaction is Sell/Buy price in Korean Won (KRW) and Sell/Buy quantity in kilowatt hour (kWh).

Buying/Selling Transaction
During the bidding phase, the electric vehicle owner is able to make a buying/selling transaction. The system retrieves information regarding available energy from the electric vehicle itself. For the purpose of this implementation, all used data are generated considering real information about electric vehicles (from manufacture specifications). After checking the displayed information, the user should press "Accept" to make the transaction occur. After user confirmation, the information is displayed. A user can check his own transactions within the current window time frame in the upper part of the user interface, as shown in Figure 11.

Buying/Selling Transaction
During the bidding phase, the electric vehicle owner is able to make a buying/selling transaction. The system retrieves information regarding available energy from the electric vehicle itself. For the purpose of this implementation, all used data are generated considering real information about electric vehicles (from manufacture specifications). After checking the displayed information, the user should press "Accept" to make the transaction occur. After user confirmation, the information is displayed. A user can check his own transactions within the current window time frame in the upper part of the user interface, as shown in Figure 11.

The PLLC Dashboard
The PLLC is able to check information regarding current participants in the platform. A list of electric vehicles available on the platform at a given time is shown in Figure 12. The PLLC dashboard for BEVs and SEVs is shown in Figures 13 and 14, respectively. It includes the parking lot information (grid price and demand) and electric vehicle information (selling/buying amount, selling/buying price). The PLLC can check the demand/offer of electric vehicles, determine winners, and clear the market using a market clear price mechanism.

The PLLC Dashboard
The PLLC is able to check information regarding current participants in the platform. A list of electric vehicles available on the platform at a given time is shown in Figure 12. The PLLC dashboard for BEVs and SEVs is shown in Figures 13 and 14, respectively. It includes the parking lot information (grid price and demand) and electric vehicle information (selling/buying amount, selling/buying price). The PLLC can check the demand/offer of electric vehicles, determine winners, and clear the market using a market clear price mechanism.  After the market clear price is determined, the PLLC selects a set of electric vehicles that satisfy this demand based on FCFS and KPA. In KPA, the PLLC sorts EV's revenue in ascending/descending order with the objective of minimizing/maximizing the cost of buying/selling energy. Figure 14 shows the PLLC dashboard where an offer tab in given in the lower part of the screen. The offer tab enables the PLLC to check the list of current transactions. The dashboard information consists of "UserID" from the user who made the transaction, "KRW/kWh" which is the unit price per kilowatt hour (kWh) offered given a specific transaction, "kWh" which is the amount requested, and "Cost" which is the cost for the PLLC to acquire that energy.
Immediately after the bidding time window finishes, the PLLC is able to clear the market. Figure 15 shows the list of selected offers that meet the amount of energy requested by the PLLC after the market is cleared.

Update Balance Information
After the trading window time finishes, a notification is sent to every client who has made an offer. Figure 16 shows the updated balance information for a winner BEV/SEV, as well as the updated information related to battery status. The positive value indicates the amount of money to pay, while the negative indicates the amount to be paid. The green value (456) indicates the electric vehicle revenue (in KRW) for selling energy to the PLLC, while the red value (972) indicates the charging cost that should be paid to the PLLC for the charging service.  After the market clear price is determined, the PLLC selects a set of electric vehicles that satisfy this demand based on FCFS and KPA. In KPA, the PLLC sorts EV's revenue in ascending/descending order with the objective of minimizing/maximizing the cost of buying/selling energy. Figure 14 shows the PLLC dashboard where an offer tab in given in the lower part of the screen. The offer tab enables the PLLC to check the list of current transactions. The dashboard information consists of "UserID" from the user who made the transaction, "KRW/kWh" which is the unit price per kilowatt hour (kWh) offered given a specific transaction, "kWh" which is the amount requested, and "Cost" which is the cost for the PLLC to acquire that energy.   Immediately after the bidding time window finishes, the PLLC is able to clear the market. Figure  15 shows the list of selected offers that meet the amount of energy requested by the PLLC after the market is cleared.

Update Balance Information
After the trading window time finishes, a notification is sent to every client who has made an offer. Figure 16 shows the updated balance information for a winner BEV/SEV, as well as the updated information related to battery status. The positive value indicates the amount of money to pay, while the negative indicates the amount to be paid. The green value (456) indicates the electric vehicle revenue (in KRW) for selling energy to the PLLC, while the red value (972) indicates the charging cost that should be paid to the PLLC for the charging service.

Conclusions
In this work, we designed and implemented a business network for energy trading between electric vehicles and a parking lot local controller in smart campus parking lots. The proposed system architecture consists of two layers: the physical infrastructure layer and the cyber infrastructure layer. A real case study for local energy trading was designed for selling and buying energy between electric

Conclusions
In this work, we designed and implemented a business network for energy trading between electric vehicles and a parking lot local controller in smart campus parking lots. The proposed system architecture consists of two layers: the physical infrastructure layer and the cyber infrastructure layer. A real case study for local energy trading was designed for selling and buying energy between electric vehicles and the parking lot local controller in a university campus. The proposed energy trading platform was implemented using Hyperledger Fabric, where participants, assets, transactions, and events were defined and discussed. The proposed system aims to reduce the peak power demand of university buildings locally, where all approved transactions are recorded and shared on the platform, which provides transparency, trust, and integrity. As a future work, the energy trading platform will be extended to support energy trading among electric vehicles where several parking lots on the university campus and the distribution power system operator will be included.