Blockchain &
Cryptoeconomics
Coursework
ZHUOLUN LI
Assessment brief
u Assignment type: Programming assignment
u Description: Develop smart contracts for a carpooling system
u Aim: Evaluate the students` knowledge of
u blockchain based systems
u Understand the context to which distributed ledgers are applied
u smart contract development skills and design decentralized applications
u Weighting: 30%
u Submission deadline: 03/05/2024
u Submission method: upload documents on Gradescope u Individual assignment
Plagiarism
u Plagiarism is a serious academic offense
u It is essential to properly cite all sources used in your work
u Always give credit where credit is due
u Be aware of the potential consequences of plagiarism in academic and professional settings
u Refrain from using AI language tools, such as ChatGPT
u By submitting this assignment you are confirming that the work is a true expression of your own work and ideas and that you have given credit to others where their work has contributed to yours
u Any plagiarism in the assignment or usage of AI tools to complete the assignment will result in failing grades
Background
u A driver is going from place A to place B tomorrow
Programming Help, Add QQ: 749389476
Background
u The driver can offer a ride to other people intending to travel from A to B tomorrow
Anyone wants a ride from me?
Background
u The driver publishes this information
u potential passengers can join the ride
I am going from A to B tomorrow at 10 AM, there are 4 spaces left, to join my ride the price is 1 Ether
Sounds good, I¡¯ll join
Background
u Challenge part 1:
u Implement a carpooling system in smart contracts u Drivers initiate rides
u Passengers search & join rides
u Drivers start & complete rides
u For simplicity, assume:
u There are three locations: A, B, C
u Drivers and passengers are honest and always attend rides u All rides are for tomorrow, no need to consider date
程序代写 CS代考 加微信: cstutorcs
Background
u Imagine this situation: A -> B, 10 AM,
I want to go at 11 AM, driver 1 is more suitable for me
A -> B, 2 PM, 1 seat
Passenger 1
I want to go at 6 AM, but I can only go with driver 2 now
Passenger 2
Background
Let¡¯s coordinate!
I want to go at 11 AM
10 AM, 1 seat
2 PM, 1 seat
Coordination algorithm
Passenger 1
I want to go at 6 AM
Let¡¯s assign driver 2 to passenger 1 Driver 1 to passenger 2
Passenger 2
Background
u Challenge Part 2:
u Implement a coordinated carpooling system u Try to minimize the total travel time deviation
u I want to travel at 10 AM, I am assigned to a ride at 8 AM, my travel time deviation is 2
u Total travel time deviation = sum of all passengers¡¯ travel time deviation
u For simplicity, assume:
u Passengers agree to coordinate
u Passengers always deposit enough money to join any rides
Your Tasks
u Given a template of Solidity code, complete the smart contracts
u Function signatures & some data structures are defined, DO NOT ALTER
u Write down your thoughts on the coordination algorithm
u Test your contract! Make sure your contract works
u We provide some basic test cases for you to run in Hardhat u You are encouraged to write more test cases
Submission
u Submission opens on Monday 29th April
u Submit two files on Gradescope: the Solidity code file and the
readme file
u Grades are not available immediately, BUT
u There is a leader board showing preliminary levels: u No stars: can do better
u One star (*): good
u Two stars (**): very good
u Three starts (***): outstanding!
Questions?