0% found this document useful (0 votes)
27 views19 pages

Ex3 Tab Lab

The document describes building an event management system decentralized application using blockchain technology. It details the software requirements, working, modules, smart contract code and frontend code for implementing the system. The system aims to offer a secure and transparent user authentication and event registration process through a user-friendly interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views19 pages

Ex3 Tab Lab

The document describes building an event management system decentralized application using blockchain technology. It details the software requirements, working, modules, smart contract code and frontend code for implementing the system. The system aims to offer a secure and transparent user authentication and event registration process through a user-friendly interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Exp.

No : 3

Date: EVENT MANAGEMENT SYSTEM

AIM:

Our project aims to develop an Event Management System Decentralized Application


(DApp) utilizing blockchain technology for secure and transparent authentication. We strive

to offer a user-friendly interface, fast verification process, and robust encryption to ensure
data integrity and build trust among users.

SOFTWARE REQUIRED:

 Visual Studio Code: For coding and development of the DApp frontend and backend.

 Remix: An online IDE for Solidity smart contract development.

 MetaMask: A browser extension wallet to interact with the Ethereum blockchain.

 MongoDB Compass: A GUI tool for MongoDB database management, used for storing user
information and event data securely.

WORKING:

 The event management system Dapp will utilize blockchain technology for storing
event details, user registrations, and authentication data securely and transparently.
 Users will interact with the Dapp through a user-friendly interface, accessing features
such as event browsing, registration, and profile management.
 Smart contracts deployed on the blockchain will handle the logic for user registration,
event registration, and generation of unique IDs and QR codes for users.
 MetaMask will serve as the Ethereum wallet interface for users to interact with the
Dapp, enabling transactions and interactions with the blockchain.
 Remix will be used for writing, testing, and deploying smart contracts onto the
Ethereum blockchain.
 Visual Studio Code will serve as the integrated development environment (IDE) for
coding and managing the project files.
MODULES :

User Authentication Module:

Implements KYC (Know Your Customer) procedures for user verification during registration.

Generates one-time passwords (OTP) for secure user login.

Event Management Module:

Stores event details on the blockchain, including event name, date, location, and unique hash

value.

Facilitates event browsing and viewing of event details.

Registration Module:

Allows users to register for events through the Dapp.

Generates a unique ID for each registered user.

QR Code Generation Module:

Converts the unique user ID into a QR code for easy validation during event attendance.

Stores the QR code in the user's profile for access when needed.

Validation Module:

Validates users during event check-in by scanning the QR code generated during registration.

Ensures the authenticity of the user and their registration status for the event.

CONTRACT:

//Academic Mentor : Dr.S.Dheenathayalan


// Industry Mentor : Mr.Kalyana Sundaram

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract EventContract {
//structure_for_event
struct Event {
address organizer;
string name;
string location;
uint256 ticketPrice;
uint256 totalTickets;
uint256 ticketsSold;
bytes32 eventid;
bool isActive;
}
struct eveId{
bytes32 eventid;
string name;
}
//structure_for_participant
struct Participant {
address participantAddress;
bytes32 eventId;
}
//store_events
mapping(bytes32 => Event) public events;
mapping (uint256 => eveId) public eve;
//store_participants
mapping(bytes32 => Participant) public participants;
uint256 public totalEvents;
uint256 public totalParticipants;
//event_created
event EventCreated(uint256 eventId, address organizer);
//new_event
function createEvent(string memory _name, string memory _location, uint256 _ticketPrice,
uint256 _totalTickets) public returns (bytes32) {
totalEvents++;
bytes32 eventId = keccak256(abi.encodePacked(_name,_location, block.timestamp,
msg.sender));
eve[totalEvents] = eveId(eventId,_name);
events[eventId] = Event(msg.sender, _name, _location, _ticketPrice, _totalTickets, 0,eventId,
true);
return eventId;
}
//register_event
function registerForEvent(bytes32 _eventId, uint256 _numTickets) public payable
returns(bytes32) {
require(events[_eventId].ticketsSold + _numTickets <= events[_eventId].totalTickets, "Not
enough tickets available");
uint256 totalCost = events[_eventId].ticketPrice * _numTickets;
require(msg.value >= totalCost, "Insufficient funds");
bytes32 participantId = keccak256(abi.encodePacked(msg.sender, _eventId,
block.timestamp));
participants[participantId] = Participant(msg.sender, _eventId);
totalParticipants++;
events[_eventId].ticketsSold += _numTickets;
payable(events[_eventId].organizer).transfer(msg.value);
return participantId;
}
function getEve(uint256 _eventId) public view returns (bytes32 eventid, string memory name)
{
eveId storage eventDetails = eve[_eventId];
return (
eventDetails.eventid,
eventDetails.name
);
}
//event_details
function getEventDetails(bytes32 _eventId) public view returns (address organizer, string
memory name, string memory location, uint256 ticketPrice, uint256 totalTickets, uint256
ticketsSold, bool isActive,bytes32 eventid) {
Event storage eventDetails = events[_eventId];
return (
eventDetails.organizer,
eventDetails.name,
eventDetails.location,
eventDetails.ticketPrice,
eventDetails.totalTickets,
eventDetails.ticketsSold,
eventDetails.isActive,
eventDetails.eventid
);
}
//participant_details
function getParticipantDetails(bytes32 _participantId) public view returns (address
participantAddress, bytes32 eventId) {
Participant storage participant = participants[_participantId];
return (participant.participantAddress, participant.eventId);
}
}

Frontend Code:

EVENT.JSX

import React, { useEffect, useState } from "react";

import './Event.css';

import axios from 'axios';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { SelectedEvent } from "../../context/eventContext";

import { faSearch } from '@fortawesome/free-solid-svg-icons';

import LoadBack from '../../assets/event.png';

import { SelectedEmail } from "../../context/EmailContext";

import Navbar from "../../components/Navbar/Navbar";

import Footer from "../../components/Footer/Footer";

import { useNavigate } from "react-router-dom";

function Event() {

const { email } = SelectedEmail();


const [loading, setLoading] = useState(true);

const [Data, setData] = useState([]);

const [filterData, setFilter] = useState([]);

const [searchValue, setSearchValue] = useState("");

const [visibleItems, setVisibleItems] = useState(6);

const navi = useNavigate();

const { setEvent } = SelectedEvent();

useEffect(() => {

const fetchData = async () => {

if (email !== "") {

try {

setLoading(true);

const response = await axios.get("http://localhost:3000/event");

setData(response.data);

} catch (err) {

console.log("Pro Error", err);

finally {

setLoading(false);

else {

navi('../login');

};

fetchData();

}, [email, navi]);

const FilterData = (searchValue) => {


if (!searchValue) {

setFilter(Data);

} else {

const filteredEvents = Data.filter((event) => {

console.log(event.category);

return event.category.toLowerCase().includes(searchValue.toLowerCase());

});

setFilter(filteredEvents);

console.log(filterData);

};

const handleSearchInputChange = (e) => {

setSearchValue(e.target.value);

const handleSearchButtonClick = () => {

FilterData(searchValue);

const loadMoreItems = () => {

setVisibleItems((prevVisibleItems) => prevVisibleItems + 3);

};

const handleAdd = async (item) => {

setEvent(item);

navi('../detail');

};

return {

<>

<Navbar />

{loading ? (

<div id="load-back">
<img src={LoadBack} alt="Loading" />

</div>

):(

<>

<div>

<div id="text3">

<h3>Search</h3>

<input type="text" value={searchValue}


onChange={handleSearchInputChange} placeholder=" Events"></input>

<button id="search" onClick={handleSearchButtonClick}><FontAwesomeIcon


icon={faSearch} /></button>

</div>

<div id="text5">

<h3>{(filterData && filterData?.[0]?.category)} Events</h3>

<div className="box-container">

{filterData.slice(0, visibleItems).map((item, index) => (

<div className="box" key={index}>

<img src={item.img} alt={item.name}></img>

<h4><span>Contest: </span>{item.name}</h4>

<h4>{item.desc}</h4>

<h4><span>Organizer: </span>{item.organizer}</h4>

<h4><span>Contact: </span>{item.contact}</h4>

<button id="btn" onClick={() => handleAdd(item)}>View More</button>

</div>

))}

{filterData.length === 0 && Data && Data.slice(0, visibleItems).map((item,


index) => (

<div className="box" key={index}>

<img src={item.img} alt={item.name}></img>


<h4><span>Contest: </span>{item.name}</h4>

<h4>{item.desc}</h4>

<h4><span>Organizer: </span>{item.organizer}</h4>

<h4><span>Contact: </span>{item.contact}</h4>

<button id="btn" onClick={() => handleAdd(item)}>View More</button>

</div>

))}

</div>

{visibleItems < filterData.length && (

<button onClick={loadMoreItems} id="button">Load More</button>

)}

{filterData.length === 0 && visibleItems < Data.length && (

<button onClick={loadMoreItems} id="button">Load More</button>

)}

</div>

</div>

</>)}

<Footer />

</>

export default Event;

REGISTER.JSX

import React, { useState, useEffect } from "react";

import './Register.css';

import { SelectedEvent } from "../../context/eventContext";


import { SelectedEmail } from "../../context/EmailContext";

import { useNavigate } from "react-router-dom";

import Web3 from 'web3';

import Navbar from "../../components/Navbar/Navbar";

import Footer from "../../components/Footer/Footer";

function Register() {

const { event } = SelectedEvent();

const { email } = SelectedEmail();

const [account, setAccount] = useState('');

const [web3, setWeb3] = useState(null);

useEffect(() => {

console.log(event);

})

useEffect(() => {

const initWeb3 = async () => {

// Check if MetaMask is installed

if (window.ethereum) {

const web3Instance = new Web3(window.ethereum);

setWeb3(web3Instance);

// Check if already connected to MetaMask

const accounts = await web3Instance.eth.getAccounts();

if (accounts.length > 0) {

setAccount(accounts[0]);

} else {

console.log('MetaMask not installed');

};
initWeb3();

}, []);

const handleRegister = async (e) => {

e.preventDefault();

const data = {

person: e.target.elements.person.value

const YOUR_CONTRACT_ADDRESS =
"0x18295fa36744146BefdE07f211e84a5a3014cad3";

const YourContractABI = []

try {

if (!web3) {

console.error('Web3 not initialized');

return;

const contract = new web3.eth.Contract(YourContractABI,


YOUR_CONTRACT_ADDRESS);

const balance = await web3.eth.getBalance(account);

console.log("Account balance:", web3.utils.fromWei(balance, 'ether'), "ETH");

console.log(event.eventid);

console.log(typeof event.evendid, typeof +data.person);

const result = await contract.methods.registerForEvent(

event.evendid,

+data.person

).send({ from: account });

console.log(result);

} catch (error) {

console.error(error);
}

return (

<>

<Navbar />

<div className="detail-container">

<div className="product-image">

<img src={event.img} alt={event.name} />

<p>{event.desc}</p>

</div>

<div className="product-details">

<h2>{event.name}</h2>

<form onSubmit={handleRegister}>

<br />

<br />

<label>No of Perosns: </label>

<input type="number" name="person"></input><br />

<br />

<br />

<button id="btn">Register</button>

</form>

</div>

</div>

<Footer />

</>

export default Register;


Backend Code:

INDEX.JS:

const express = require("express");

const cors = require("cors");

const bcrypt = require("bcrypt");

const Event = require ("./models/event");

const Signup =require("./models/Signup");

const app = express();

app.use(express.json());

app.use(express.urlencoded({ extended: true }));

app.use(cors());

const mongoose = require("mongoose");

require("dotenv").config();

const mongoURI = process.env.MONGO_URI;

mongoose

.connect(mongoURI, { useNewUrlParser: true, useUnifiedTopology: true })

.then(() => {

console.log("Connected to MongoDB!");

})

.catch((error) => {

console.error("Error connecting to MongoDB:", error.message);

});

app.get("/", (req, res) => {

res.json("Hello");

})

app.post("/signup", async (req, res) => {


const { fname, phone, email, pass } = req.body;

try {

const hashpass = await bcrypt.hash(pass, 10);

await Signup.insertMany({ fname, phone, email, pass: hashpass });

res.status(200).json("Success");

} catch (err) {

console.log(err);

res.status(500).json("Failed");

});

app.post("/login", async (req, res) => {

const { email, pass } = req.body;

try {

const user = await Signup.findOne({ email: email });

if (user) {

const match = await bcrypt.compare(pass, user.pass);

if (match) {

res.json(user);

else {

res.json("The password is incorrect");

else {

res.json("No record existed");

catch (err) {

console.log(err);
res.json(err);

})

app.get("/event",async(req,res)=>{

try{

const event=await Event.find();

res.json(event);

catch(err){

res.json(err);

})

app.listen(3000, () => {

console.log("Running...");

});

OUTPUT:
PLAGIARISM REPORT:
CONCLUSION:
In conclusion, the event management system Dapp, empowered by blockchain
technology, ensures secure event authentication and management. Through user-friendly
interfaces and robust encryption, it prioritizes user experience while guaranteeing data
integrity. Smart contracts on the blockchain provide transparent and tamper-proof storage
of event details and user interactions. Leveraging Visual Studio Code, Remix, and MetaMask,
the system offers seamless development, testing, and deployment processes.

Problem Implementation Program Time Viva Total


Understanding (10) Execution Management (10) (50)
(10) (10) (10)

You might also like