1. Introduction
Electric vehicles have the advantages of low greenhouse gas emissions and high energy efficiencies and have developed rapidly in recent years [
1]. A sound charging infrastructure system and a safe and convenient charging service model are important guarantees for the popularity of electric vehicles. At present, electric vehicle charging services have problems such as difficulty in finding piles for charging users, difficulty in connecting charging station information, and difficulty in settling charging transactions [
2,
3]. For example, the introduction of central institutions to manage charging services and charging transaction information can improve the status quo, but it is costly, and there is a risk of information leakage [
4]. Therefore, it is necessary to seek a new charging service model and transaction information management system.
Blockchain, as a new application technology of “Internet +”’s new format, has the characteristics of weak centralization, has no trust, is not easy to tamper with, can realize multi-node undifferentiated recording, and promote the interconnection of information (30). It can be widely used in electricity market transactions, energy demand responses, and other energy trading interconnection scenarios (31). The application mode of blockchain is divided into a public chain, alliance chain, and private chain. Ref. [
5] proposed to use blockchain technology to realize the transparency and trust of public charging pile billing. Ref. [
6] proposed an Ethereum-based electric vehicle charging transaction mode, in which the electric vehicle user selects the charging station with the best bid. Ref. [
7] proposed a charging pile sharing platform based on the lightning network, blockchain, and smart contracts. Ref. [
8] proposed an electric vehicle charging transaction based on the lightning network, which solved the possible security problems in the lightning network. The above studies generally used the traditional Bitcoin or Ethereum blockchain architectures, which require tokens and public chains and are not conducive to improving transaction efficiency and reducing transaction costs. So, it is necessary to select a blockchain architecture that is more suitable for the performance requirements of electric vehicle charging transaction businesses. The user in the alliance chain must have the participation permission of the federated authentication member, the write and read permission of the node used to block data in the federated authentication chain is limited by the federated authentication member, and its operation cost is moderate. Due to its special design, the alliance chain has also been widely concerned in various commercial organizations. Foreign scholars use weak centralized alliance chains to improve the efficiencies and security of electric vehicle transactions. In ref. [
9], multiple agent nodes were set to manage the selection and transaction of user charging modes, but the implementation architecture of a specific alliance chain was not mentioned. In ref. [
10], for the application scenario of a microgrid, electric vehicle users were set to trade with distributed energy operators. Ref. [
11] used the alliance chain to design the charging and discharging transactions between electric vehicles and set up a local aggregator to act as a service node, without involving the situation of user transactions in different aggregators.
The current research on charging transaction models does not take into account that the charging company is composed of multiple charging operators and public power supply enterprises, and the charging information and transaction mode are not uniform. In view of this, this paper proposes an electric vehicle trading model based on the alliance chain to realize the interconnection of charging services. An intelligent contract with the functions of settlement, evaluation, and query is designed to realize the autonomous management of charging transactions. An experimental environment is built on the Hyperledger Fabric platform to verify that the model provides users with more convenient charging services.
3. Electric Vehicle Charging Transaction Model and Smart Contract Design
3.1. Electric Vehicle Charging Transaction Model
An electric vehicle charging transaction architecture can be divided into an application layer, intelligent contract layer, consensus layer, network layer, and data layer [
14]. The data layer stores transaction data in LeveldB or CouchdB with the data structure of the Merkle bucket tree and blockchain table. The network layer selects the HTTP/2-based P2P protocol as the network transport protocol, allowing nodes to listen to verify that the new block or new transaction of the broadcast is valid. The consensus layer uses a practical Byzantine fault-tolerant algorithm. The smart contract layer encapsulates the smart contract for electric vehicle charging transactions written in the Go language. The application layer supports electric vehicle charging applications with the functions of querying charging stations and transferring transactions.
Figure 1 shows the network structure of the electric vehicle charging transaction model. The participants include the application program, the charging station node of the charging operator and the public power supply company, the sorting service node, and the supervision department of the charging transaction market.
Each charging operator or utility acts as an organization in the transaction network structure, and each organization has multiple charging station nodes. All nodes are accounting nodes and are responsible for verifying that the transaction is valid and writing the transaction to the ledger. On this basis, it can also play the roles of a host node, anchor node, and endorsement node. The master node is a node responsible for communicating with the sequencing service node, and the sequencing service node receives a transaction containing an endorsement signature, sequences the unpackaged transaction, generates a block, and broadcasts the block to the accounting node. An anchor node is a node that can communicate with nodes of other organizations. By running its installed smart contract, the endorsement node can sign and endorse the charging transaction proposal proposed by the client and feed back the results. The transaction model calculates the endorsement experience value
M according to the number of endorsements of nodes and refers to this index in service evaluation so that it can encourage each charging station node to act as an endorsement node and maintain the stable operation of the blockchain platform. The endorsement empirical value
M is calculated as
Here, is the number of book updates by which charging station node acted as endorsement node at the time of this transaction. is the total number of book updates. is the weight of endorsement experience. In this paper, considering the practical application of electric vehicles at the present stage, beta is taken as 0.5.
All charging station nodes implement public key infrastructure (PKI) services through the digital certificate authentication center module of the Federation chain and set a membership service provider (MSP) component. The control structure relationship between the participants is abstracted, and the identity authentication and authority control are carried out. The authentication center is mainly responsible for providing digital certificates to the charging station node, including a public key, a private key, and a certificate revocation list. The administrator of the MSP component is the supervision department of the electric vehicle charging trading market, and the roles of organization, channel, and node are configured in the MSP of the trading model. After the MSP directory is set for each node, the node has a signature certificate. When transmitting and writing data in the channel node, it is necessary to verify the signature of the node, the path of the certificate, and whether it is in the certificate revocation list.
Data exchange is realized by establishing a transaction channel, which is a virtual channel for atomic broadcasting. The design of the transaction channel makes the nodes outside the channel unable to access the data in the channel, providing safe and efficient data exchange. The channel is managed by the supervision department of the electric vehicle charging trading market and connects the charging station nodes and sorting service nodes of multiple companies. Users registered with any charging operator or public power supply enterprise can have the account authentication of the trading platform and deposit their wallet address, account balance, current credibility, certificate, and public/private key pair. Users can access all endorsement nodes in the channel through the application program and select charging services provided by multiple charging operators and public power supply enterprises.
The energy function is used to define the probability distribution of the explicit and implicit layers.
When a new charging operator joins the network, the corresponding endorsement node of the operator will be added to the channel; the geographical location of the charging station, the type and quantity of charging piles, and other parameters will be uploaded to the database; and the nodes of other operators and public power supply enterprises will update the data synchronously.
3.2. Operation Process of Electric Vehicle Charging Transaction Model
The operation process of the EV charging transaction mode is based on the practical Byzantine fault-tolerant (practical Byzantine fault tolerance, PBFT) algorithm [
15]. PBFT is a state machine replica replication algorithm. In short, PBFT is a data filtering algorithm that reflects the majority rule. The state machine performs replica replication at different nodes.
Figure 2 is its timing diagram. The client sends a request to the master node to invoke the service operation. After receiving the request information, the master node enters the pre-preparation phase to broadcast to other nodes. After receiving the broadcast, other nodes simulate the transaction and generate the transaction result, generate the hash value of the new block according to the result information, and enter the preparation stage to broadcast within its range. Let
f be the maximum number of invalid copies and broadcast an authentication message to the network when a node receives 2F identical copies of information with itself. When all nodes receive 2
f + 1 identical messages, new block information can be submitted to the local blockchain and database. The PBFT algorithm can effectively reduce the influence of EV users’ misoperations on charging stations’ credit evaluations.
The operation process of the electric vehicle charging transaction mode is shown in
Figure 3, including transaction initiation, contract execution, and transaction verification of the transaction subject under the consensus mechanism. Firstly, the electric vehicle user selects the charging station to charge according to the service score and uses the charging client to send the operation of calling the charging service to the endorsement node in the channel. After receiving the request message, the endorsement node verifies the identity of the client, simulates the transaction by executing the smart contract, and evaluates the charging service. The endorsement node outputs the smart contract result, which is a set of key values read or written in the smart contract. The response to the transaction request with an endorsed signature will be sent back to the client. The client broadcasts it to the sequencing service node. The sequencing service node transmits the ordered transactions as a block to all nodes on this channel. Each node verifies whether the execution result can be written into the ledger state database and notifies the client.
4. Intelligent Contract of Electric Vehicle Charging Trading Model
A smart contract is a program that runs on a blockchain data ledger and is automatically executed by a computer. The main functions of the intelligent contract for electric vehicle charging transaction include the settlement of charging fees for electric vehicles, the evaluation of charging services and user credibility, and the inquiry of transaction orders by users, charging operators, and public power supply enterprises. For each electric vehicle transaction settlement completed by the vehicle owner, the credibility
of the vehicle owner is evaluated according to the transaction behavior of the vehicle owner, and the formula is as follows:
Here, is the credit award that the EV account v obtains or deducts after the jth charging transaction is completed, and its value satisfies the collection . When the user completes the correct payment of the previous charging service, they can receive a credit award, and, vice versa, a credit score is deducted. If the reputation is below the minimum threshold set by the system, i.e., , the user will not be able to use the charging service normally. In this paper, the initial and threshold values of reputation are 0.
The transaction model recommends charging stations with high evaluations of nearby charging services for charging transactions to users with normal reputations. The charging service evaluation
of the charging station node is updated with the increase in transaction number n. Formula (3) is based on the literature [
16] evaluation mechanism, the charging service evaluation of the charging station is calculated according to the rating given by users with different reputation and endorsed experience value of the charging station node. The formula is as follows:
Here, represents the n-1st transaction service evaluation of the charging station node. determines the speed of service evaluation change after each transaction score. By adjusting the value of , the charging station node with low evaluation will not always be affected by the past bad evaluation after its service capability is improved. is the endorsement empirical value calculated by Formula (1). is the rating given by the user with a reputation of and satisfies . is the expected score to be obtained by the charging station node. is highest level of service evaluation. is a damping function that makes the change in the charging service evaluation value tend to be gentle. is the acceleration factor in the damping function.
When calculating the evaluation of charging service, the creditworthiness of EV users and endorsements of charging station nodes are taken into account to make the evaluation more reasonable and play a role in stimulating charging station nodes to improve the level of charging service, contributing computing power, and maintaining the stable and efficient operation of trading platform. The intelligent contract pseudocode for completing credit rating and charging service evaluation calculations uses intelligent contracts to achieve charging fee payments for electric vehicle users, setting up a charging station to provide charging services for electric vehicles; electric vehicle users need to pay charging operators and utility power supply company fees, and the formula is:
Here,
is the initial electric quantity of the electric vehicle.
is the amount of electricity after charging.
is the unit price of electricity.
is the unit price of service charge. The total cost of charging an electric vehicle
Fv is:
Here, is the charging power. t is the charging time.
The specific steps of the transaction fee settlement function are as follows. First, the payment function receives parameters, including a charging amount, an electric vehicle ID (EVID), a charging station ID (CSID), and a time period ID (PriceID), to which the electricity price belongs. The function then applies the API that queries the ledger to receive the account balance and the unit price of electricity corresponding to the PriceID. The calculation of the charging transaction amount payment is completed according to the Formula (6), and the corresponding amount in the electric vehicle account is transferred to the charging station account amount. If the balance of the electric vehicle’s account after transfer is lower than the threshold value, the bonus points are deducted; otherwise, the bonus points are increased. Finally, the transaction is written in the ledger. See Algorithms 1 and 2 for the smart contract pseudocode that completes the transaction fee settlement function.
Algorithm 1 Calculate reputation function |
Input: Wn, Rv, Φ(Rcs,n−1) Output: Query results, include time, payment, PriceID, CSID, EVOrgID, CSOrgID. Initialize: J = 0
- 1:
Step 1: calculate the reputation of CS - 2:
Step 2: calculate the reputation of EV user - 3:
Update J, Rv - 4:
For Rv < Rv,min do - 5:
Use Algorithm 2 to complete transaction Return , |
Algorithm 2 Chaincode payment function |
Input: transaction information including EVID, CSID, PriceID Output: new EVaccount, new CSaccount. Initialize: payment = 0- 1:
Step 1: query their accounts in database - 2:
Step 2: calculate the payment of charging - 3:
EVaccount = Vaccount-payment - 4:
CSaccount = Saccount + payment - 5:
Step 3: write the state back to ledger - 6:
Putstate (EVID, EVaccount) - 7:
Putstate (CSID, CSaccount) Return EVaccount, CSaccount |
Electric vehicle users and administrators of charging operators can query the data of charging bills through smart contracts. Take the function of bill inquiry as an example. The electric vehicle number EVID is first received from the client’s Java SDK. Then, the query string is constructed according to the EVID, and the query string proposal is sent to the ledger, and the query result is obtained. The query results include transaction time, charging cost, unit electricity price, charging station number, user organization number, and charging station organization number. Finally, all the query results are aggregated and returned. Different from other functions that need to be written into the ledger, such as calling the function of querying the transaction ledger when the node runs the smart contract to access the status data, it does not need consensus to directly output the running results to the client.
6. Conclusions
In this paper, we propose a transaction model based on the alliance blockchain, according to the demand of electric vehicle charging transaction, which avoids the use of tokens, improves the transaction performance, and solves the interconnection problem of charging facilities between different charging operators and public power supply enterprises by establishing inter-organizational channels. Through blockchain technology, the whole network can trade independently and solve the industry pain points of different payment methods and scarce charging piles under the inconsistent application scenarios of charging operation companies. The intelligent contract of charging transaction running on the channel is designed to ensure the automatic and strict execution of transaction rules, improve the transparency of charging transaction information and the timeliness and fairness of charging settlements, and encourage each charging station node to maintain the efficient operation of the trading platform by calculating the charging service evaluation. It should be pointed out that the profit game between charging operators, charging guidance optimizations, system maintenance, and other issues still need to be further studied and discussed, although this paper designed a charging transaction model based on the alliance blockchain.