Skip to content

Commit 80d2333

Browse files
committed
Intial Commit
0 parents  commit 80d2333

File tree

4,875 files changed

+560484
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,875 files changed

+560484
-0
lines changed

bs-config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"server": {
3+
"baseDir": ["./src", "./build/contracts"]
4+
}
5+
}

build/contracts/Election.json

Lines changed: 2967 additions & 0 deletions
Large diffs are not rendered by default.

build/contracts/Migrations.json

Lines changed: 1310 additions & 0 deletions
Large diffs are not rendered by default.

contracts/.gitkeep

Whitespace-only changes.

contracts/Election.sol

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
pragma solidity ^0.5.0;
3+
4+
contract Election {
5+
//Model a candidate
6+
struct Candidate{
7+
uint id;
8+
string name;
9+
uint voteCount;
10+
11+
}
12+
//Store account that have voted
13+
mapping (address => bool) public voters;
14+
15+
16+
//Store candidate
17+
//Fetch candidate
18+
19+
mapping (uint => Candidate) public candidates;
20+
//store candidates voteCount
21+
22+
uint public candidatesCount;
23+
24+
25+
constructor() public {
26+
addCandidate("Logan Paul");
27+
addCandidate("Felix");
28+
addCandidate("Vedant Jajoo");
29+
addCandidate("Bhuwan Bam");
30+
addCandidate("None of the above");
31+
32+
33+
}
34+
35+
function addCandidate (string memory _name) private {
36+
37+
candidatesCount ++;
38+
candidates[candidatesCount] = Candidate(candidatesCount, _name
39+
, 0);
40+
}
41+
42+
event votedEvent (
43+
uint indexed _candidateId
44+
);
45+
46+
function vote (uint _candidateId) public {
47+
// require that they haven't voted before
48+
require(!voters[msg.sender]);
49+
50+
// require a valid candidate
51+
require(_candidateId > 0 && _candidateId <= candidatesCount);
52+
53+
// record that voter has voted
54+
voters[msg.sender] = true;
55+
56+
// update candidate vote Count
57+
candidates[_candidateId].voteCount ++;
58+
59+
// trigger voted event
60+
emit votedEvent(_candidateId);
61+
}
62+
63+
64+
}
65+

contracts/Migrations.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.5.0;
2+
3+
contract Migrations {
4+
address public owner;
5+
uint public last_completed_migration;
6+
7+
modifier restricted() {
8+
if (msg.sender == owner) _;
9+
}
10+
11+
constructor() public {
12+
owner = msg.sender;
13+
}
14+
15+
function setCompleted(uint completed) public{
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public{
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}

migrations/1_initial_migration.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Migrations = artifacts.require("./Migrations.sol");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Migrations);
5+
};

migrations/2_deploy_contracts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Election = artifacts.require("./Election.sol");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Election);
5+
};

node_modules/.bin/browser-sync

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/browser-sync.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/dev-ip

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/dev-ip.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/lite-server

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/lite-server.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/lt

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/lt.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/throttleproxy

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/throttleproxy.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/window-size

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)