AI and Blockchain Integrated Billing Architecture for Charging the Roaming Electric Vehicles

: Due to the proliferation of extended travel range electric vehicles (EVs), these will travel through di ﬀ erent networks that might be served by di ﬀ erent utility companies. Therefore, we propose an architecture capable of o ﬀ ering a charging service to roaming vehicles. Furthermore, although the energy internet supports both the ﬂow of energy and information, it does not support seamless EV roaming service, because it is based on a centralized architecture. The blockchain technology that is based on a decentralized system has the potential to support a secure billing platform for charging the EVs roaming through di ﬀ erent electrical jurisdictions. Furthermore, the integration of artiﬁcial intelligence (AI) ensures that the participating players get a fair portion of the revenue. Thus, the objective of this paper is to develop an AI and blockchain integrated billing architecture that would o ﬀ er a charging service to the “roaming” EVs and present a fair and uniﬁed billing solution.


Introduction
Electric vehicles (EVs) are gaining importance as they are evolving to (a) provide more miles per charge, (b) help utilities in peak demand shaving, (c) reduce environmental pollution, and (d) offer a lower cost per mile [1]. Many of today's newest EVs can travel over 200 miles on a single charge. Tesla's flagship Model S offers as much as 370 miles on demand [2]. The market penetration of extended travel range EVs is encouraging EV travel through networks that might be served by different utility companies. Therefore, there is a need for roaming-enabled charging infrastructure.
Roaming refers to an EV drivers' ability to receive an EV charging service during long-distance EV travels, using charging stations that belong not only to a home utility network (HUN), but also to a visiting utility network (VUN), with the same privileges as they would receive in an HUN. These privileges may include, for example, receiving a discounted EV charging rate based on a drivers' long term dedication with a HUN, or receiving premium charging services for being a Gold, Diamond, or Platinum customer, contingent upon their enrollment in a loyalty program with their HUN, etc. Thus, such customers will continue to receive discounted and premium services even if they travel out of the service jurisdiction of their HUN. Furthermore, with roaming-enabled infrastructure in place, an EV driver will receive just one bill associated with the customer HUN's account number. Provisioning of roaming service requires (a) the introduction of new functional entities; (b) development of new communication interfaces; (c) upgrades in charging stations; (d) creation of contractual agreements among the participating utilities that would bind them to provide the agreed-upon charging services to each other's customers while honoring consumer confidentiality, privacy, and security; (e) interconnection between the energy and the information flow; and (f) a decentralized, transparent, and secure transaction system to allow participating utilities to keep track of usage of service and completion of transactions. This paper proposes an "AI and blockchain integrated billing architecture for charging the roaming electric vehicles".
Blockchain technology was developed specifically for bitcoin; bitcoin is the first application of blockchain in action. However, blockchain has several applications beyond cryptocurrency networks, and these have the potential revolutionize the way we conduct business [3]. Figure 1 shows the players involved, and the following paragraphs show some of the benefits for each player for using blockchain technology for billing architecture for charging roaming EVs.
IoT 2019, 2 FOR PEER REVIEW 2 Provisioning of roaming service requires (a) the introduction of new functional entities; (b) development of new communication interfaces; (c) upgrades in charging stations; (d) creation of contractual agreements among the participating utilities that would bind them to provide the agreedupon charging services to each other's customers while honoring consumer confidentiality, privacy, and security; (e) interconnection between the energy and the information flow; and (f) a decentralized, transparent, and secure transaction system to allow participating utilities to keep track of usage of service and completion of transactions. This paper proposes an "AI and blockchain integrated billing architecture for charging the roaming electric vehicles".
Blockchain technology was developed specifically for bitcoin; bitcoin is the first application of blockchain in action. However, blockchain has several applications beyond cryptocurrency networks, and these have the potential revolutionize the way we conduct business [3]. Figure 1 shows the players involved, and the following paragraphs show some of the benefits for each player for using blockchain technology for billing architecture for charging roaming EVs. EV Owners: Blockchain-based roaming offers several perks for EV owners. For example, blockchain-enabled roaming eliminates the need for one to possess multiple subscriptions, loyalty cards, credit cards, or gift cards for different charging networks. It also reduces transaction fees [4], because in blockchain, there is no involvement of a third-party management entity. The integration of AI with blockchain also provides transparency, fairness, and security for billing. Further, it offers a single/unified billing solution [5], regardless of where the charging request is initiated from. Furthermore, it offers the ability to provide premium services to the select customers, such as priority charging, discounted tariffs, and pre-booking of charging facility, etc.

2.
Utility Industry: The potential of blockchain-based roaming in the utility industry is transformative, as it has a great beneficial impact on the revenue, which is a key performance indicator (KPI) of utility companies [6]. Blockchain-enabled roaming also provides the utilities the liberty to pick-and-choose best roaming partners, which in turn promotes competition, and enhances customers' trust and retention. It also offers a decentralized energy trading platform and distributive data storage facility. Additionally, it provides a 1. EV Owners: Blockchain-based roaming offers several perks for EV owners. For example, blockchain-enabled roaming eliminates the need for one to possess multiple subscriptions, loyalty cards, credit cards, or gift cards for different charging networks. It also reduces transaction fees [4], because in blockchain, there is no involvement of a third-party management entity. The integration of AI with blockchain also provides transparency, fairness, and security for billing. Further, it offers a single/unified billing solution [5], regardless of where the charging request is initiated from. Furthermore, it offers the ability to provide premium services to the select customers, such as priority charging, discounted tariffs, and pre-booking of charging facility, etc.

2.
Utility Industry: The potential of blockchain-based roaming in the utility industry is transformative, as it has a great beneficial impact on the revenue, which is a key performance indicator (KPI) of utility companies [6]. Blockchain-enabled roaming also provides the utilities the liberty to pick-and-choose best roaming partners, which in turn promotes competition, and enhances customers' trust and retention. It also offers a decentralized energy trading platform and distributive data storage facility. Additionally, it provides a robust security architecture, as the whole blockchain system is protected by encryption algorithms. Its integration with AI provides a fair distribution of the funds. 3.
Charging Infrastructure Providers: AI integrated blockchain-based roaming also offers several benefits to the charging infrastructure providers. The charging infrastructure may include the real estate and the charging equipment, also called electric vehicle supply equipment (EVSE). It offers the transaction's correctness, openness, traceability, and immutability that is hard to achieve in traditional centralized charging stations. AI integrated blockchain-based roaming system will build trust in EV owners for battery charging in general, and for battery swapping in particular, because the network will permanently save operations histories, including information about battery health and life-cycle, and make it visible to all the players, i.e., the EV owner, the charging/swapping stations, and the utilities.

Literature Survey
Before writing this paper, the authors performed a thorough literature survey to discover if such a solution had already been discussed in the scientific community in the past. They studied the most relevant papers carefully, gauged them, performed a meticulous contrast and comparison so that they may distinctly ink their original ideas. The authors of this paper analyzed the following comparable papers and found that the proposed approach is unique in several aspects. Reference [7]-"Application of Blockchain Technology in Sustainable Energy Systems-An Overview", a survey paper-provides several possible applications of blockchain technology in energy systems. One of the applications, which pertains to EV charging and resembles our proposal, is JuiceNet. JuiceNet provides the EV driver a blockchain-enabled software-based app, which the EV driver may use to view the available charging devices on a map and navigate to a nearby charging station for charging. It also allows EV owners to lease the time of charging to increase the available number of charging posts. It also provides a communication, control, and intelligence platform that dynamically matches drivers' historical charging patterns, so that the utility service providers may manage the charge station demand effectively. The work presented by the authors provides a software-the "JuiceNet app"-and pertains to the application layer of the OSI model; thus, this is completely different from our proposal, as our proposal provides a complete core network architecture to offer the blockchain-enabled roaming service.
The authors in [8] used blockchain technology for vehicle battery refueling. This paper caught our attention as it initially seemed to match our proposal quite closely in some areas. However, it utilizes Blockchain technology to evaluate the quality of battery automatically. Battery related operations are implemented with a smart contract. Besides that, the life cycle information of the battery is stored in the blockchain network, keeping data immutable and traceable. The data are open to both EV owners and stations, to check the health status of the battery. Thus, the core research area of this work is battery health and not the roaming architecture; thus, it is completely different from what we propose in this paper.
The authors in [9] focused on cyber-attacks using blockchain technology for the EVs. More precisely, it proposes blockchain technology to combat the potential attacks, such as replay, impersonation, and session key disclosure, and proves that the blockchain-based authentication between EV and energy aggregator using Burrows-Abadi-Needham (BAN) logic is much more secure. It concludes that the blockchain-based EV charging solution is resistant to replay and man-in-the-middle attacks using automated validation of internet security protocols and applications.
Reference [10] presents an IoT-based blockchain paradigm for the electric vehicle. In this paper, we find that the authors address the EV charging process in shared living spaces, such as condominiums and apartment buildings. The motivation is to facilitate the charging process at condominiums and The remainder of the paper is organized as follows. Section 2 offers a description, Section 3 presents the use-case scenario, performance analysis, and results, and Section 4 concludes the paper.

Description
We propose a complete and unique system architecture as depicted in Figure 2. The architecture is classified into "Functional Entities" and "Blockchain Overlay Network". The functional entities are (i) enhanced charging stations, (ii) roaming gateway/router (R-GW/R), (iii) authentication, authorization, and accounting (AAA) node, (iv) charging rules and policy (CRP) database, and (v) consumer profile database. The blockchain overlay network includes a communication protocol and consortium blockchain code.
To understand the roaming framework, we first introduce a unique consumer identification number (CIN). A CIN is a sequence of digits formatted and standardized in such a way that all the functional entities involved in this architecture and the services associated with the CIN are distinguished by the functional entities. For example, the first part of a CIN uniquely identifies the AAA node situated in the HUN and is used to establish a communication link between the charging station and AAA node. The second part of the CIN is interpreted by the AAA node to validate the consumer and uniquely recognize the services associated with the number. To understand the roaming framework, we first introduce a unique consumer identification number (CIN). A CIN is a sequence of digits formatted and standardized in such a way that all the functional entities involved in this architecture and the services associated with the CIN are distinguished by the functional entities. For example, the first part of a CIN uniquely identifies the AAA node situated in the HUN and is used to establish a communication link between the charging station and AAA node. The second part of the CIN is interpreted by the AAA node to validate the consumer and uniquely recognize the services associated with the number.

Enhanced Charging Station
The enhanced charging stations are distributed throughout the service area. EVs connect to the charging station using a charging cable. The communication between the charging station (i.e. EVSE and the EV is carried out following the ISO/IEC 15118 protocols. The communication between the charging station (i.e. SECC) and the roaming-gateway/router (R-GW/R) is carried over ISO/IEC 61850. The serving utility feeds the EVSE.
Enhanced charging stations have standard-as well as additional-features for the enablement of blockchain-based billing and EV recharging. Each charging station has a unique, addressable ID and supports the Energy Internet, i.e., it handles the flow of energy, as well as information. The flow of energy is between the EV and the serving utility provider through the serving charging station, whereas the flow of information is between the serving charging station, the HUN, and the VUN through the cloud. The charging stations are equipped with a graphical user interface to accept user information, e.g. a utility-issued consumer identification number (CIN), customer loyalty number, or any such numbers that contain customers' subscription and service related information. The graphical user interface may be a dial pad, a scanner to read the magnetic tape cards, a chip reader to read the integrated circuit (IC) chip card, a radio frequency identity (RFID), or a near field communication (NFC) reader to read the cards wirelessly. User information may appear on the card issued to the EV drivers by their HUN. It may also be human/machine-readable.

Enhanced Charging Station
The enhanced charging stations are distributed throughout the service area. EVs connect to the charging station using a charging cable. The communication between the charging station (i.e., EVSE and the EV is carried out following the ISO/IEC 15118 protocols. The communication between the charging station (i.e., SECC) and the roaming-gateway/router (R-GW/R) is carried over ISO/IEC 61850. The serving utility feeds the EVSE.
Enhanced charging stations have standard-as well as additional-features for the enablement of blockchain-based billing and EV recharging. Each charging station has a unique, addressable ID and supports the Energy Internet, i.e., it handles the flow of energy, as well as information. The flow of energy is between the EV and the serving utility provider through the serving charging station, whereas the flow of information is between the serving charging station, the HUN, and the VUN through the cloud. The charging stations are equipped with a graphical user interface to accept user information, e.g., a utility-issued consumer identification number (CIN), customer loyalty number, or any such numbers that contain customers' subscription and service related information. The graphical user interface may be a dial pad, a scanner to read the magnetic tape cards, a chip reader to read the integrated circuit (IC) chip card, a radio frequency identity (RFID), or a near field communication (NFC) reader to read the cards wirelessly. User information may appear on the card issued to the EV drivers by their HUN. It may also be human/machine-readable.

Roaming-Gateway/Router (R-GW/R)
The R-GW/R is a newly proposed entity and is a part of the communication network. It is capable of handling, coordinating, and managing all communications aspects related to the charging service for roaming or non-roaming EVs. When the R-GW/R receives data from the charging station side, it forwards those data to the network side, more specifically, to the designated AAA node that may reside in HUN or VUN. Similarly, when it receives the data from the utility network either HUN or VUN, it forwards these to the destined charging station. It not only handles two-way communication, but also two types of data: the consumer subscription-related data and the power consumption related data. These two pieces of information are put together for each charging event.
2.1.3. Authentication, Authorization, and Accounting (AAA) Node The proposed AAA node performs three functions: (a) authentication, which authenticates consumer credentials, (b) authorization, which determines if a consumer is authorized to consume the requested service, and (c) accounting, which tracks the means of payment. This could be through several well-established payment options, such as debit card/real-time, credit card, pre-paid, and post-paid options. For customer convenience, the bitcoin option will provide the most secure, direct, and cost-effective payments option, as it will eliminate the service fee. Moreover, payments made to the company directly is more convenient than paying through a payment gateway.
Upon authentication and authorization, the AAA node sends a message through R-GW/Router, to the charging station to begin charging the EV-battery. During charging, the AAA node and the charging station may exchange several messages to ensure that the EV gets the specified services and bill the customer accordingly.
The utility company may also retrieve information from the AAA node for data analytics purposes. For example, accounting information may be used for auditing, trend analysis, capacity planning, type of charging service delivered, the volume of charging/electricity usage, time duration of usage, etc. Furthermore, the authentication and authorization information for analysis of authentication failure, attempt to use unauthorized services, and procedure correctness verification, etc.

Charging Rules and Policy Database (CRP Database)
To perform authentication, authorization, and accounting functions, the AAA node interacts with the newly proposed charging rules and policy (CRP) database. The CRP database is situated in each participating utility's network. There are two types of CRP database: one contains the policy and charging rules for the home customers, and the other contains the policy and charging rules for each participating utility companies' customers. A set of different charging rules and policies for each participating utility is based on the contractual agreement with that utility.
The CRP database may interface with its other operational support systems, such as real-time complex rate and billing management server [1] to apply complex energy rates based on real-time energy generation, demand, and peak load, etc. in the serving area. Thus, the CRP database makes intelligent rate adjustment decisions for each subscriber based on a set of charging rules and policies for each participating utility, the prevailing complex tariff rates, customer loyalty membership, and the type of selected payment option. The CRP database may review and update the policies anytime.

Consumer Profile Database
The newly proposed consumer profile database is located in each participating utility's network. It is divided into two categories: the HUN consumer profile databases (HCPD), which contains the subscription profile of the utility's own consumers, and the VUN consumer profile databases (VCPD), which contains the subscription profile of the visiting utility's consumers. The records pertaining to HCPD are permanent, whereas the records pertaining to VCPD, fetched from the HCPD and stored in the VCPD, are temporary, and deleted when the EV driver is assumed to be no longer in the VUN. Figure 2 also shows the communication interface between the CRP database, the HCPD, and the VCPD. These are to distinguish the visiting customers from the home customers based on their CIN, and provide the customized services and billing adjustment, accordingly.

Blockchain Overlay Network, Communication Protocols, and Code
As shown in Figure 3, we propose to layover the blockchain protocols on top of the Ethernet-based TCP/IP protocol stack. Furthermore, in the application layer, we propose the use of ISO/IEC-15118 for communication between the charging station and the EV, and ISO/IEC-61850 or IEC63110 for communication between the charging station and the utility company. These protocols are explained in [14][15][16]. Figure 2 also shows the communication interface between the CRP database, the HCPD, and the VCPD. These are to distinguish the visiting customers from the home customers based on their CIN, and provide the customized services and billing adjustment, accordingly.

Blockchain Overlay Network, Communication Protocols, and Code
As shown in Figure 3, we propose to layover the blockchain protocols on top of the Ethernetbased TCP/IP protocol stack. Furthermore, in the application layer, we propose the use of ISO/IEC-15118 for communication between the charging station and the EV, and ISO/IEC-61850 or IEC63110 for communication between the charging station and the utility company. These protocols are explained in [14,15,16]. The above-noted protocols are overlaid on the blockchain network. The elements contained in the blockchain overlay network are (i) distributed ledgers, (ii) consensus mechanisms, (iii) advanced encryption algorithms, and (iv) smart contracts. Their functions are briefly noted below.
Distributed ledgers are decentralized databases that hold the sequence of all actions, such as electricity demand, selling price, and time of service provisioning, etc. Decentralization averts a variety of cyberattacks including, zero-day attack, DDOS (distributed denial of service), ransom attacks, etc. [8].
Consensus mechanisms are built into the protocols that enable players to agree on a "single version of the truth", to validate that the data is not altered without the consensus of any of the player, to confirm that the transactions are valid, and to confirm that the utility actually owns the commodity it is selling.
Advanced encryption algorithms work through hash functions, public/private keys authentication, and digital signatures, and are discussed in the next section. Smart contracts are legal rules and agreements that will be executed inside the blockchain architecture to automatically exchange funds based on predefined conditions. At present, the defined standards regarding smart contracts lack artificial intelligence, which means the contracts are static and do not account for the dynamically changing utility grids load conditions and the time of use rate. This shortcoming could potentially lead to undesired monetary losses to the players, utility, customers, and charging infrastructure providers. We propose applying AI [22] technology to smart contracts to overcome this shortcoming.
We apply AI technology to smart contracts dynamic. The integration of AI will make the contracts depend on (i) static agreed upon roaming rules and, (ii) dynamically changing utility's load The above-noted protocols are overlaid on the blockchain network. The elements contained in the blockchain overlay network are (i) distributed ledgers, (ii) consensus mechanisms, (iii) advanced encryption algorithms, and (iv) smart contracts. Their functions are briefly noted below.
Distributed ledgers are decentralized databases that hold the sequence of all actions, such as electricity demand, selling price, and time of service provisioning, etc. Decentralization averts a variety of cyberattacks including, zero-day attack, DDOS (distributed denial of service), ransom attacks, etc. [8].
Consensus mechanisms are built into the protocols that enable players to agree on a "single version of the truth", to validate that the data is not altered without the consensus of any of the player, to confirm that the transactions are valid, and to confirm that the utility actually owns the commodity it is selling.
Advanced encryption algorithms work through hash functions, public/private keys authentication, and digital signatures, and are discussed in the next section. Smart contracts are legal rules and agreements that will be executed inside the blockchain architecture to automatically exchange funds based on predefined conditions. At present, the defined standards regarding smart contracts lack artificial intelligence, which means the contracts are static and do not account for the dynamically changing utility grids load conditions and the time of use rate. This shortcoming could potentially lead to undesired monetary losses to the players, utility, customers, and charging infrastructure providers. We propose applying AI [22] technology to smart contracts to overcome this shortcoming.
We apply AI technology to smart contracts dynamic. The integration of AI will make the contracts depend on (i) static agreed upon roaming rules and, (ii) dynamically changing utility's load conditions, peak load, and time of use rate. To execute the smart contracts, our AI Client in the cloud continually communicates with the AI Server. For proof of concept, we used a Google-based AI server that is available to the users under the Pre-General Availability Terms of the Google Cloud Platform. The structured data in the form of CVS files with data primitives, such as numbers, classes, strings, timestamps, lists, and nested fields, are sent to and received from the AI server. Our AI client uses the Auto Machine Learning (AutoML) application of the Google-based AI server. AutoML uses this data to train MLTables and to predict the utility grid's load condition. The code used to accomplish the objective is provided by Google [23] and is given in Appendix B.
For operational efficiency and cost-effectiveness, we propose a cloud network. The cloud network includes virtual routers, firewalls, and network management software. The cloud network communication channels may be wireless, wired, or Power line communication (PLC) [24]. Wireless channels maybe 4G, 5G, or local area networks, or wide area networks. Wired channels may be coaxial cables or optical fibers. Communication network latency is not a concern as in any common payment network latency of 5 seconds is acceptable, whereas latency in 4G is 50 milliseconds, and in optical fibers or coaxial cables, it is around 5 µsec per kilometer.
Since bitcoin is not currently widely used, credit card companies are planning to launch a blockchain-technology for credit card transactions. Shinhan Card has already announced the use of blockchain for credit card payments [25]. Visa has launched a payment system for business-to-business (B2B) transactions based on blockchain technology [26].
The blockchain code we implement is "Consortium Blockchain". Consortium blockchain architecture requires developing (i) functional specification, (ii) flowchart, (iii) authentication and authorization code, and (iv) accounting schema. These are briefly discussed below.

Functional Specifications
Our functional specification is based on the use of the Federal Information Processing Standard (FIPS), defined by the National Institute of Standards and Technology (NIST) that recommends Secure Hash Algorithm (SHA)-256. SHA-256 is a set of cryptographic hash functions in which computers race to solve a complicated math problem. After one computer finds a solution, it broadcasts that solution to the rest of the computers on the peer to peer network. Each computer on the network verifies the solution or "single version of the truth", independently. Figure 4 shows the flowchart for blockchain-enabled billing service. The graphical user interface of a charging station prompts the EV Driver to swipe his/her CIN card. The charging station reads the CIN and forwards it to R-GW/Router. The R-GW/Router resolves the number to uniquely identify.

Flowchart
The HUN to connect the charging station to the HUN's AAA node. The CIN is further analyzed by the HUN's-AAA node for authentication and service privilege identification. The privileges may include, for example, receiving a discounted EV charging rate for being a HUN's star customer, based on their long term dedication with the HUN, or receiving premium charging services for being a Gold, Diamond, or Platinum customer based on their enrollment in a loyalty program with HUN, etc., so that the customer may get discounted and premium services even if they are out of the service jurisdiction of their HUN.
The HUN's AAA bills for the service consumed to their existing account so that the EV drivers receive just one bill. The HUN's AAA may also inform the EV Driver about the approximate estimated bill for the service based on day, time, and location. If the EV driver agrees to the tariff, the Charging station will start the battery charging. The R-GW/router manages the whole procedure and forwards the charging session-related messages between the user and the VUN. The billing records are sent to the appropriate billing entities. The HUN to connect the charging station to the HUN's AAA node. The CIN is further analyzed by the HUN's-AAA node for authentication and service privilege identification. The privileges may include, for example, receiving a discounted EV charging rate for being a HUN's star customer, based on their long term dedication with the HUN, or receiving premium charging services for being a Gold, Diamond, or Platinum customer based on their enrollment in a loyalty program with HUN, etc., so that the customer may get discounted and premium services even if they are out of the service jurisdiction of their HUN.
The HUN's AAA bills for the service consumed to their existing account so that the EV drivers receive just one bill. The HUN's AAA may also inform the EV Driver about the approximate estimated bill for the service based on day, time, and location. If the EV driver agrees to the tariff, the Charging station will start the battery charging. The R-GW/router manages the whole procedure and forwards the charging session-related messages between the user and the VUN. The billing records are sent to the appropriate billing entities.

Authentication and Authorization Code
As noted above, the AAA node performs three functions: (a) authentication, to authenticate consumer credentials, (b) authorization, to determine if a consumer is authorized to consume the requested service, and (c) accounting, for billing the consumer. AAA is programmed to perform Open ID Connect (OIDC) authentication, and Open Authorization (OAuth) for authorization. The authentication code uses MATLAB based JavaScript Object Notation (JSON) schema, and

Authentication and Authorization Code
As noted above, the AAA node performs three functions: (a) authentication, to authenticate consumer credentials, (b) authorization, to determine if a consumer is authorized to consume the requested service, and (c) accounting, for billing the consumer. AAA is programmed to perform Open ID Connect (OIDC) authentication, and Open Authorization (OAuth) for authorization. The authentication code uses MATLAB based JavaScript Object Notation (JSON) schema, and authorization uses an open-standard authorization protocol. Both, the authentication code and authorization codes are given in Appendix A.

Accounting Schema
For fair billing, the AAA node exchanges several messages with the charging station and several other databases as explained above. Since revenue is a KPI, and roaming impacts the revenue of utility companies, the authors analyze it by adapting the model presented in [26].
Let the Revenue "R i " for a utility company in the country/geographical region "i" is given as: where DCR in Equation (1) stands for domestic charging revenue, paid by domestic customers for domestic use, and it is proportional to: where m i is the total number of potential customers, p i is the subscription price, λ i is the customers' ability-to-pay, and θ i is the minimum willingness-to-pay. RCR in Equation (1) stands for roaming charging revenue, paid by the roaming customers for roaming use in country/geographical region "i", and it is proportional to: where c i is the fixed per-volume price for the roaming service in country/geographical region i. TCR in Equation (1) stands for transit charging revenue, paid to a utility company in the country/geographical region "j" for provisioning the roaming service and meeting the costs for providing roaming infrastructure. It is proportional to where t i is the transit price decided by the utility in the geographical region "i". It may be decided either by the partner utility companies to reach an equilibrium, or by the regulator to maximize the consumer surplus (CS-a measure of aggregated satisfaction level of all subscribers), and is defined in (2) below. Zero transit prices (i.e., t i = 0, ∀ i ) are likely to be optimal for a maximized CS. TCC in Equation (1) stands for transit charging cost. It is the transit usage cost a utility company in country/geographical region "j" must pay to a utility company in country/geographical region "i" to cover the roaming costs incurred by their domestic customers for roaming on foreign networks. It is proportional to From the users' perspective, satisfaction is a key metric. If the consumer surplus (CS) be a measure of aggregated satisfaction level of all subscribed users, across all countries. It is expressed as: where net utility for domestic usage (NUDU) represents the users' subscription decision about the utility's subscription price for the domestic service. It is equal to θ i − p i . Furthermore, NURU stands for net utility for roaming usage, and it represents the per-volume price for the roaming service. It is proportional to (θ i − c i ) 2 . The values of pi and ci are selected to maximize the utility's revenue. The performance comparison between the traditional and the proposed blockchain-based roaming system is conducted in the next section by evaluating Equations (1) and (2).

Example Usage Scenario
The following scenario presents an example of EV roaming in the United States; however, nothing prevents this technology from global roaming among different countries, like cell phone roaming.
Let us assume an EV driver has a CIN Card issued by Alabama Power, a Utility company of Alabama. Furthermore, assume that this EV driver drives through North Carolina needs charging service and swipes his/her CIN Card in the charging station served by Duke Energy, a Utility company of North Carolina. The charging station reads the CIN Card and forwards the card information to the R-GW/Router. The R-GW/Router parses the CIN and finds that the number is issued by Alabama Power, thus routes the CIN to the AAA node residing in the Alabama Power network.
The AAA node of Alabama Power further analyzes the CIN and verifies (i) the legitimacy of the CIN and service portfolio associated with that CIN by consulting its own HCP Database. The AAA node of Alabama Power sends "Authorization" and "Service description", the CIN Cardholder is eligible for, to Duke Energy's AAA. After receiving the user authentication and service description detail from the AAA node of Alabama Power, Duke Energy's AAA saves the visiting customer's profile in its VCP Database temporarily so that if the same customer sends a charging request again, the remote authentication/authorization steps could be avoided, and local authentication could be performed. Now the AAA server of Duke Energy consults its own CRP Database that contains the policy and charging rules for Alabama Power's customers. Using this information, and the prevailing load conditions of Duke Energy, Duke Energy's serving charging station provides the requested service. Upon completion of the service, the AAA node of Duke Energy sends an invoice to the AAA node of Alabama Power. Alabama Power delivers the service charge to Duke Energy according to the contractual agreement. The customer will receive the unified bill from Alabama Power only.

Performance Comparison
The performance comparison in terms of utility company's revenue, for no roaming, traditional roaming, and the proposed blockchain-based roaming is conducted by evaluating Equations (1) and (2). In these equations we set m 1 = 1, m 2 = 2 and λ 2 = 1 for a fair comparison, as used in [25]. Figure 5 shows that with no roaming, the revenue of a utility company operating in a certain region/country (λ 1 ), increases as the ability and willingness of the customers of that region/country to pay increases. For traditional roaming, the graph is inverted i.e., the revenue of a utility company operating in a certain region/country (λ 1 ) increases due to the contribution (i.e., TCR) from roaming customers of other regions/countries (λ 2 , λ 3 , etc.), or in other words, increasing λ 1 , the operator's revenue is less negatively impacted, and with the proposed roaming, the revenue of the utility company further increases because the customers seamlessly receive the desired service that increases (or less negatively impact) the customer satisfaction (CS) level as shown by the dotted line.
The graph of Figure 6 shows the results of the effect of AI on smart contracts. As shown, the impact of AI is not prominent during the initial learning epoch, and the efficiency of decision making performance remains 95.3%. With time the efficiency increases to 97.86 percent with AI. Thus a net improvement of 2.5 in efficiency is obtained. The graph of Figure 6 shows the results of the effect of AI on smart contracts. As shown, the impact of AI is not prominent during the initial learning epoch, and the efficiency of decision making performance remains 95.3%. With time the efficiency increases to 97.86 percent with AI. Thus a net improvement of 2.5 in efficiency is obtained. Figure 5. Impact of blockchain roaming on utility's revenue.
The graph of Figure 6 shows the results of the effect of AI on smart contracts. As shown, the impact of AI is not prominent during the initial learning epoch, and the efficiency of decision making performance remains 95.3%. With time the efficiency increases to 97.86 percent with AI. Thus a net improvement of 2.5 in efficiency is obtained. Figure 6. Effect of artificial intelligence on smart contract. Figure 6. Effect of artificial intelligence on smart contract.

Conclusion
The extended travel range of EVs will encourage EV drivers to travel through networks belonging to different utility jurisdictions. Therefore, we propose AI and blockchain integrated billing architecture for charging the roaming electric vehicles, since blockchain technology offers attractive features.
The proposed system provides several benefits to all the players. The analysis shows that it improves the aggregated satisfaction level of the customers, and thus positively impacts the utility companies' revenue. It also shows the results of the effect of AI on smart contracts. It is also demonstrated that, with the integration of AI with smart contracts, the efficiency of decision-making performance increases, which ensures that the participating players get a fair portion of the revenues.

Future Work
In the future, we plan to make a system capable of supporting EV diagnostic services employing an AI-based remote diagnostic application.  Funding: This research did not receive any funding.

Conflicts of Interest:
The authors declare no conflict of interest.

A-2: Authorization Code
The authorization is performed using the following code.

A-2: Authorization Code
The authorization is performed using the following code.