Ex3 Tab Lab
Ex3 Tab Lab
No : 3
AIM:
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.
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 :
Implements KYC (Know Your Customer) procedures for user verification during registration.
Stores event details on the blockchain, including event name, date, location, and unique hash
value.
Registration 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:
// 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 './Event.css';
function Event() {
useEffect(() => {
try {
setLoading(true);
setData(response.data);
} catch (err) {
finally {
setLoading(false);
else {
navi('../login');
};
fetchData();
}, [email, navi]);
setFilter(Data);
} else {
console.log(event.category);
return event.category.toLowerCase().includes(searchValue.toLowerCase());
});
setFilter(filteredEvents);
console.log(filterData);
};
setSearchValue(e.target.value);
FilterData(searchValue);
};
setEvent(item);
navi('../detail');
};
return {
<>
<Navbar />
{loading ? (
<div id="load-back">
<img src={LoadBack} alt="Loading" />
</div>
):(
<>
<div>
<div id="text3">
<h3>Search</h3>
</div>
<div id="text5">
<div className="box-container">
<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>
</div>
))}
<h4>{item.desc}</h4>
<h4><span>Organizer: </span>{item.organizer}</h4>
<h4><span>Contact: </span>{item.contact}</h4>
</div>
))}
</div>
)}
)}
</div>
</div>
</>)}
<Footer />
</>
REGISTER.JSX
import './Register.css';
function Register() {
useEffect(() => {
console.log(event);
})
useEffect(() => {
if (window.ethereum) {
setWeb3(web3Instance);
if (accounts.length > 0) {
setAccount(accounts[0]);
} else {
};
initWeb3();
}, []);
e.preventDefault();
const data = {
person: e.target.elements.person.value
const YOUR_CONTRACT_ADDRESS =
"0x18295fa36744146BefdE07f211e84a5a3014cad3";
const YourContractABI = []
try {
if (!web3) {
return;
console.log(event.eventid);
event.evendid,
+data.person
console.log(result);
} catch (error) {
console.error(error);
}
return (
<>
<Navbar />
<div className="detail-container">
<div className="product-image">
<p>{event.desc}</p>
</div>
<div className="product-details">
<h2>{event.name}</h2>
<form onSubmit={handleRegister}>
<br />
<br />
<br />
<br />
<button id="btn">Register</button>
</form>
</div>
</div>
<Footer />
</>
INDEX.JS:
app.use(express.json());
app.use(cors());
require("dotenv").config();
mongoose
.then(() => {
console.log("Connected to MongoDB!");
})
.catch((error) => {
});
res.json("Hello");
})
try {
res.status(200).json("Success");
} catch (err) {
console.log(err);
res.status(500).json("Failed");
});
try {
if (user) {
if (match) {
res.json(user);
else {
else {
catch (err) {
console.log(err);
res.json(err);
})
app.get("/event",async(req,res)=>{
try{
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.