This smart contract implements a parking reservation system using the typescript on azle for internet Computer. The system allows for the initialization of an owner, addition of parking slots, allocation of parking spaces to clients, valet delivery, and various operations on parking slots.
- Node
- Typescript
- DFX
- IC CDK
-
Clone the repository:
git clone https://github.com/Collins-Ruto/parking-reservation-ICP.git cd parking-reservation-ICP
The project is organized into the following directories and files:
-
src/
: Contains the source code for the parking management system.index.ts
: App entry point Implementation of the parking management system.
-
node_modules/
: Directory for project dependencies. -
package.json
: Configuration file for npm, including project dependencies and scripts. -
tsconfig.json
: TypeScript configuration file, specifying compiler options. -
LICENSE
: MIT License file, detailing the terms under which the project is licensed. -
README.md
: Project documentation providing an overview, installation instructions, usage details, and license information.
- Initializes the system owner with a unique ID, name, and timestamp.
- There can only be one owner per contract.
- Retrieves the details of the system owner.
- Retrieves a list of available parking slots.
- Adds a new parking slot to the system. Reserved for the contract owner.
- Allocates a parking space to a client, marking the slot as occupied.
- Handles vallet delivery, updating the total cost and client's location.
- Picks up a car from a parking slot, calculates the parking duration and cost.
- Updates information for a parking slot, such as parking ID and price. Reserved for the contract owner.
- Deletes a parking slot from the system. Reserved for the contract owner.
- Initialize the owner using
initOwner(name)
. - Add parking slots with
addParkingSlot(payload)
. - Allocate parking spaces to clients using
getParkingSpace(payload)
. - Manage vallet delivery with
valetDelivery(payload)
. - Perform various operations on parking slots, including updates and deletions.
dfx
is the tool you will use to interact with the IC locally and on mainnet. If you don't already have it installed:
npm run dfx_install
Next you will want to start a replica, which is a local instance of the IC that you can deploy your canisters to:
npm run replica_start
If you ever want to stop the replica:
npm run replica_stop
Now you can deploy your canister locally:
npm install
npm run canister_deploy_local
To call the methods on your canister:
npm run name_of_function
npm run name_of_function
Assuming you have created a cycles wallet and funded it with cycles, you can deploy to mainnet like this:
npm run canister_deploy_mainnet
This project is licensed under the MIT License - see the LICENSE file for details.