// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; /// @title Parking ticket contract. contract ParkingTicket { string licenseplate; uint balance; uint public created; address payable propertyowner; // Events event Paidfully(address from, address to, uint amount); // Errors error OverPaid(address payer, uint available); constructor( uint price, string memory _licenseplate, address payable _propertyowner ) { balance = price; licenseplate = _licenseplate; created = block.timestamp; propertyowner = _propertyowner; } function payoff(address sender, uint amount) public { if(amount > balance){ revert OverPaid({ payer: sender, available: balance }); } balance -= amount; if(balance == 0) { emit Paidfully( sender, propertyowner, amount); } } function getbalance() public view returns (uint) { return balance; } }
0.7.1