Question: You are provided with a simple e-voting smart contract code below. Create a contract file with a .sol extension using the Remix Ethereum IDE inside

You are provided with a simple e-voting smart contract code below. Create a contract file with a .sol extension using the Remix Ethereum IDE inside the browser and copy the code to it.

Rename the contract as well as the functions inside to add your initials.

Deploy the smart contract on the test blockchain provided by Javascript VM and provide screenshots showing that the functions are being executed correctly.

Deliverables

Submit a single zipped file containing the following:

1) Your contract .sol file. Please add comments in the code to improve readability.

2) A word document containing screenshots showing that your contract is successfully deployed on development blockchain. Also, show that your functions are executing correctly.

pragma solidity ^0.8.2;

contract VotingContract {

struct vote {

string name;

uint id;

string party;

}

mapping (uint => vote) votes;

uint public totalVotes=0;

function checkVote(uint id) public view returns(bool) {

if (votes[id].id != 0)

{

return true;

}

else

{

return false;

}

}

function castVote(string memory name, uint id, string memory party) public {

if(checkVote(id)==false)

{

vote memory v = vote(name,id,party);

votes[id] = v;

totalVotes++;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!