Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
1 Assignment Guidance
Context
Carpooling, also known as car sharing or ride sharing, involves individuals
sharing a single vehicle for travel in the same direction or to a common desti
nation, instead of driving separate cars. The primary aim of carpooling is to
reduce the number of vehicles on the road, offering a sustainable transporta
tion option. It addresses challenges such as traffic congestion, environmental
impact, fuel costs, and energy conservation, while increasing social interac
tion among people.
A blockchain-based carpooling service offers distinct advantages over tra
ditional, centralized carpooling apps. Its primary benefit is to enhance trust
among users, thanks to the transparent and immutable nature of blockchain
technology. Furthermore, blockchain enables smart contract-based, auto
matic payment settlements, ensuring fair compensation for drivers. This ap
proach not only simplifies the payment process but also reduces intermediary
fees. Overall, a blockchain-based carpooling system enhances transparency,
security, and efficiency, providing a more trustworthy and cost-effective solu
tion compared to conventional carpooling apps. In this coursework, you are
required to develop a smart contract in Solidity for a carpooling system.
Scenario
This coursework focuses on a carpooling system with two types of partici
pants: drivers and passengers, in a simplified scenario described below:
• Rides: Only drivers can create rides. It is assumed that drivers are
honest in attending and completing rides. Passengers can view available
rides and book seats. Passengers are assumed to always attend the rides
they book, hence ride cancellations are not considered.
• The map: The system operates on a map with three independent
locations: A, B, and C. Vehicles can travel between these points (e.g.,
A to B, B to C). Passengers can book a ride only if the starting point
and destination match their travel requirements.
• Time tracking: For simplicity, we assume rides are created one day
ahead of the travel date, eliminating the need to track days. Journey
2start times, precise to the hour, should be recorded. Time can be
represented as an unsigned integer from 0 to 23 in the smart contract,
where 0 represents 00:00, 1 represents 01:00, and so on.
• Payment: Ether is the currency used in the system. Passengers must
pay for their seat in Ethers in advance when booking a ride. The seat
price, set by the driver, is automatically transferred to the driver‘s
account once the ride is marked as complete.
The Smart Contract
You are provided with a template for the smart contract in contract template.sol.
This template outlines the structure and essential functionalities that you
need to implement. The details of these functionalities are as follows:
Basic Functionalities
• Registration: Before using any other functions, a blockchain address
must register as either a driver or a passenger in the contract. For in
stance, the function to create a ride should only be used by a registered
driver, and the function to join a ride should verify if the caller is a
registered passenger.
• Rides creation and recording: Drivers can create rides by providing
information including:
– travel time (journey start time, represented as an unsigned integer
from 0 to 23)
– available seats in the ride
– price of a seat
– starting point of the ride
– destination of the ride
When rides are stored in the smart contract, additional information
should be recorded, including:
– unique ID of the ride (starts counting from 0)
– blockchain address of the driver
3– status of the ride (the possible status are BookingOpen, Fully
Booked, Started, Completed)