-
Notifications
You must be signed in to change notification settings - Fork 0
/
contract-c085f3f6c9.sol
55 lines (40 loc) · 2.27 KB
/
contract-c085f3f6c9.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract NairobiParkingSmartContract {
address public nairobiCounty;
mapping(address => uint256) public parkingBalances;
event ParkingPayment(address indexed payer, uint256 amount, string vehicleLicense, string parkingZone);
event PenaltyPayment(address indexed payer, uint256 amount, string vehicleLicense, string parkingZone);
event VehicleClamped(string vehicleLicense, string parkingZone);
event VehicleImpounded(string vehicleLicense, string impoundYard);
modifier onlyNairobiCounty() {
require(msg.sender == nairobiCounty, "Only Nairobi County can call this function");
_;
}
constructor() {
nairobiCounty = msg.sender;
}
function payForOnStreetParking(string memory vehicleLicense, string memory parkingZone) external payable {
require(msg.value > 0, "Payment amount must be greater than zero");
// Additional checks for valid parking zone, vehicle license, and other conditions can be added here.
parkingBalances[msg.sender] += msg.value;
emit ParkingPayment(msg.sender, msg.value, vehicleLicense, parkingZone);
}
function payPenalty(string memory vehicleLicense, string memory parkingZone) external payable {
require(msg.value > 0, "Payment amount must be greater than zero");
// Additional checks for valid penalty, vehicle license, and other conditions can be added here.
parkingBalances[msg.sender] += msg.value;
emit PenaltyPayment(msg.sender, msg.value, vehicleLicense, parkingZone);
}
function requestVehicleClamp(string memory vehicleLicense, string memory parkingZone) external onlyNairobiCounty {
// Additional checks for valid parking zone, vehicle license, and other conditions can be added here.
emit VehicleClamped(vehicleLicense, parkingZone);
}
function impoundVehicle(string memory vehicleLicense, string memory impoundYard) external onlyNairobiCounty {
// Additional checks for valid impound yard, vehicle license, and other conditions can be added here.
emit VehicleImpounded(vehicleLicense, impoundYard);
}
function withdrawFunds() external onlyNairobiCounty {
payable(nairobiCounty).transfer(address(this).balance);
}
}