Skip to content

Latest commit

 

History

History
153 lines (138 loc) · 6.09 KB

README.md

File metadata and controls

153 lines (138 loc) · 6.09 KB

calendar-smart-contract

Solidity Smart Contract Template for Decentralized Meeting Scheduling and Management on Blockchain

👉 STAR ⭐ this project for later use and to keep posted on the changes.

Table of Contents

General Information

  • This project was created to fulfill the need many developers face when building decentralized applications with on-chain meeting management functionality.
  • It provides a Solidity smart contract template to create, manage, and track meetings, ensuring transparency and immutability on the blockchain.
  • It simplifies the implementation of features like meeting creation, rescheduling, participant management, and availability checks, serving as a foundation for your blockchain-based scheduling applications.

Features

  • Create a Meeting: Allows an organizer to create a meeting with participants, date, time, agenda, and link ✔
  • Reschedule a Meeting: Organizer can reschedule the meeting by changing the date and time ✔
  • Add Participants: Organizer can add participants to an existing meeting ✔
  • Cancel a Meeting: Organizer can cancel the meeting ✔
  • Check Meetings by Address: Retrieve all meetings for which a user is an organizer or participant ✔
  • Check Availability: Checks if an address is available for a given date and time ✔

Function's

createMeeting

  • Purpose: Allows an organizer to create a new meeting.
  • Parameters:
    • participants: List of participants' addresses.
    • date: UNIX timestamp for the meeting date.
    • startTime: Start time of the meeting in seconds from midnight.
    • endTime: End time of the meeting in seconds from midnight.
    • agenda: A brief agenda of the meeting.
    • meetLink: Link to the meeting (e.g., Zoom/Google Meet link).
  • Details:
    • Creates a new meeting and tracks it under the organizer and participants' addresses.
    • Emits the MeetingCreated event.

rescheduleMeeting

  • Purpose: Enables the organizer to reschedule an existing meeting.
  • Parameters:
    • meetingId: ID of the meeting to be rescheduled.
    • newDate: New date for the meeting.
    • newStartTime: New start time of the meeting.
    • newEndTime: New end time of the meeting.
  • Details:
    • Updates the date and time of the specified meeting.
    • Emits the MeetingRescheduled event.

addParticipants

  • Purpose: Allows the organizer to add new participants to an existing meeting.
  • Parameters:
    • meetingId: ID of the meeting.
    • newParticipants: List of new participants' addresses.
  • Details:
    • Adds only non-duplicate participants to the meeting.
    • Tracks the meeting under the new participants' addresses.
    • Emits the ParticipantAdded event for each added participant.

cancelMeeting

  • Purpose: Lets the organizer cancel an existing meeting.
  • Parameters:
    • meetingId: ID of the meeting to be canceled.
  • Details:
    • Marks the meeting as canceled.
    • Emits the MeetingCancelled event.

getMeetingDetails

  • Purpose: Retrieves detailed information about a specific meeting by its meetingId.
  • Parameters:
    • meetingId: The unique identifier of the meeting to retrieve details for.
  • Details:
    • A MeetingDetails object with the following fields:
    • organizer: Address of the meeting organizer.
    • date: Meeting date (UNIX timestamp).
    • startTime: Meeting start time (in seconds from midnight).
    • endTime: Meeting end time (in seconds from midnight).
    • agenda: The agenda of the meeting.
    • meetLink: Link to the meeting.
    • isCancelled: Boolean indicating if the meeting is cancelled.
    • participants: Array of addresses representing participants in the meeting.

addMeetingToUser

  • Purpose: Associates a meeting with a user's address.
  • Parameters:
    • user: Address of the user.
    • meetingId: ID of the meeting.
  • Details:
    • Ensures no duplicate meetings are added to the user's list.

Technologies and Techniques

Project configuration

📦src
 ┣ 📂contracts  => Contains contract
 ┣ 📂scripts  => Scripts to deploy the contract.
 ┣ 📂test  => Tests of the contract.
 ┣ 📜hardhat.config.js  => Network details.

Main application

Setup

  1. Clone this project by doing:
$ git clone https://github.com/sarvesh371/calendar-smart-contract.git
  1. Go to the folder you've just cloned the code and execute:
$ npm install
  1. Create a .env file in your project's container folder. The file should have the following variables with your own values:
API_URL="ALCHEMY_API_URL"
PRIVATE_KEY="METAMASK_PRIVATE_KEY"
BASESCAN_API_KEY="BASESCAN_API_KEY"
  1. Compile the contract
$ npx hardhat compile
  1. Deploy the contract
$ npx hardhat run scripts/deploy.js --network baseSepolia
  1. Verify the contract
$ npx hardhat verify --network baseSepolia <DEPLOYED_CONTRACT_ADDRESS>
  1. Run tests on hardhat local
$ npx hardhat test
  1. Run tests on Base Sepolia
$ npx hardhat test --network baseSepolia