The parkinglot::parkinglot
module is a smart contract written in the Move programming language, designed to manage a decentralized parking lot system. This contract includes functionalities for managing parking slots, processing payments, and system administration.
The primary purpose of this module is to create a transparent and efficient parking lot management system on a decentralized platform. It aims to ensure fair management of parking slots, accurate tracking of parking durations, and proper handling of payments and revenue.
- Slot Management: Allows administrators to create and manage parking slots.
- Slot Reservation and Usage: Enables users to reserve, occupy, and vacate parking slots.
- Payment Processing: Facilitates the creation of payment records and calculation of parking fees.
- Revenue Management: Allows administrators to withdraw and distribute revenue generated by the parking lot.
Slot
: Represents a parking slot, including a unique ID, status, start time, and end time.ParkingLot
: Represents a parking lot, including a unique ID, admin address, list of parking slots, and SUI token balance.PaymentRecord
: Represents a payment record, including a unique ID, amount, and payment time.AdminCap
: Represents administrator capabilities, including a unique ID and admin address.
init
: Initializes the contract by setting up the administrator and parking lot.create_slot
: Allows administrators to create a new parking slot.reserve_slot
: Reserves a parking slot by setting its status to occupied.enter_slot
: Occupies a parking slot and records the start time.exit_slot
: Vacates a parking slot and records the end time.create_payment_record
: Creates a payment record.calculate_parking_fee
: Calculates the parking fee.withdraw_profits
: Withdraws profits from the parking lot (ensures the caller is an administrator).distribute_profits
: Distributes profits of the parking lot.test_generate_slots
: Function for testing slot generation.
- Prerequisites: Ensure that all necessary tools and dependencies are installed as per the setup instructions mentioned.
- Build Package: Use the command
sui move build
to build the package. - Publish Package: Publish the package using the command
sui client publish --gas-budget 100000000 --json
. Extract the package ID and other necessary information from the output. - Configure Connectivity: Run
sui client active-address
and provide details such as node URL and configuration name to configure connectivity to the local node. - Get Tokens: Obtain SUI tokens for testing using the appropriate command (
curl
orsui client faucet
). - Switch to Testnet: If testing on the testnet, switch to the testnet environment using
sui client switch --env testnet
. - Deploy Contract: Deploy the smart contract to the desired environment using the extracted package ID and other relevant information.
- Unit Testing: Run unit tests using the command
sui move test
. - Manual Testing: Interact manually with the deployed contract using CLI commands provided in the contract documentation. Test various functionalities such as creating parking slots, reserving slots, handling payments, and managing revenue.
- Integration Testing: Conduct integration testing by simulating real-world scenarios and ensure that the contract behaves as expected under different conditions.
- Error Handling: Test error handling mechanisms by intentionally triggering error conditions and verify that the contract responds with the correct error codes.
- Gas Usage: Monitor gas usage during testing to ensure that the contract operates within acceptable gas limits and does not exceed the specified gas budget.
- Security Audit: Consider performing a security audit to identify and address potential vulnerabilities in the contract code.
- Feedback and Iteration: Gather feedback from testing and iterate on contract design and implementation as needed to enhance functionality, performance, and security.