# Blockchain-Enabled NextGen Service Architecture for Mobile Internet Offload
## 3 Blockchain-Based Subscriber Offloading Framework
The smart contract functionality is implemented in Solidity, and code snippets for various functions are shown in Figure 3.  
**Phase 4: WiFi Access Facilitation and Data Usage Logs. ** In phase 4, the WP checks the status of the smart contract. If the contract has been executed, the WP allows access to its services to the subscriber provided. Predominantly, the service offered is high-speed Internet access, but it can also be a wide range of other services. When the subscriber terminates the connection, the WP records the data consumed by the subscriber in its logs. We note that the NEMO app also monitors the data usage by the MN, and periodically sends updates to the MNO. **Phase 5: Blockchain Transactions and Billing. ** Phase 5 deals with the transactions and billing-related procedures. Once the offloaded connection is terminated, the WP will calculate the data usage and execute blockchain transactions along with information such as \(DataUsage_{WP}\) and the corresponding smart contract ID. The MNO also enters the data usage of the user, as advised by the NEMO app, into the \(DataUsage_{MNO}\) field and executes it as a transaction along with the corresponding smart contract ID. If the \(DataUsage_{WP}\) and \(DataUsage_{MNO}\) values agree within a predetermined threshold, then this transaction will be used in the next invoice generation. In the case of any dispute, the broker can mediate to resolve it. The invoice can be generated by the WiFi provider after an agreed period, such as a week or a month. The WiFi provider will access all the transactions made by it from the blockchain data and prepare an invoice based on the mutually agreed price per unit. This invoice will also be verified by the associated MNO and can also be ratified by the BK. Once all parties verify the invoice, the bill will be paid using a mutually agreed out-of-bounds payment mechanism. Figure 3: Code Snippet of the Smart Contract. The Ethereum blockchain supports scalability for large-scale offloading requests/ transactions using a combination of sharding and side chains. To test the performance of the Ethereum blockchain, researchers measured four million transactions for 380 h [23]. The experiment concluded that throughput decreases, whereas latency increases linearly, if we increase the block period, which is fixed as per the difficulty level of PoW. In our proposed framework, we are using a proof-of-authority (PoA) strategy, so this bottleneck should not affect the overall throughput and latency of the proposed system. To decrease the time required to complete the workload, the study suggests that powerful machines with high memory and CPUs should be used as blockchain nodes in PoA mode; for example, the computation time for a workload can be reduced by 25% if the memory is increased from 4 GB to 24 GB. The performance of the blockchain network can be improved by keeping the network size as small as possible. For example, in the study, it is found that the successful search ratio for a blockchain with a small size is 90-100%, whereas the successful search ratio is merely 60-75% for larger networks for a given time slot.