{"id":15680941,"url":"https://github.com/samajammin/simple-democracy","last_synced_at":"2025-05-07T11:21:15.338Z","repository":{"id":43588555,"uuid":"167123737","full_name":"samajammin/simple-democracy","owner":"samajammin","description":"If only voting was as simple as this dApp...","archived":false,"fork":false,"pushed_at":"2022-12-10T00:56:11.000Z","size":3473,"stargazers_count":13,"open_issues_count":9,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T09:37:18.223Z","etag":null,"topics":["dapp","drizzle","elections","ethereum","metamask","reactjs","smart-contracts","solidity","truffle","voting","web3"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samajammin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-23T05:38:01.000Z","updated_at":"2024-03-05T10:41:14.000Z","dependencies_parsed_at":"2023-01-26T01:16:48.045Z","dependency_job_id":null,"html_url":"https://github.com/samajammin/simple-democracy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samajammin%2Fsimple-democracy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samajammin%2Fsimple-democracy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samajammin%2Fsimple-democracy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samajammin%2Fsimple-democracy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samajammin","download_url":"https://codeload.github.com/samajammin/simple-democracy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252866114,"owners_count":21816395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dapp","drizzle","elections","ethereum","metamask","reactjs","smart-contracts","solidity","truffle","voting","web3"],"created_at":"2024-10-03T16:46:52.832Z","updated_at":"2025-05-07T11:21:15.311Z","avatar_url":"https://github.com/samajammin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Democracy\n\nTruffle, Drizzle \u0026 React dApp for conducting basic elections on the Ethereum blockchain.\n\nYou can interact with the smart contract using a local network (see instructions below) or on the Rinkeby testnet (see [deploying section](#deploying)).\n\n## Prerequisites\n\nYou will need the following properly installed on your computer:\n\n- [Git](https://git-scm.com/)\n- [Node.js v8+ LTS](https://nodejs.org/en/)\n- [MetaMask browser extension](https://metamask.io/)\n\n## Installation\n\nInstall [yarn](https://yarnpkg.com/lang/en/docs/install) (or use NPM if you prefer):\n\n```\nbrew install yarn\n```\n\nInstall [Truffle](https://truffleframework.com/truffle):\n\n```\nyarn global add truffle\n```\n\nEnsure you have truffle 5. Running `truffle version` should output look something like:\n\n```\nTruffle v5.0.1 (core: 5.0.1)\nSolidity v0.5.0 (solc-js)\nNode v10.13.0\n```\n\nInstall [Ganache-CLI](https://github.com/trufflesuite/ganache-cli):\n\n```\nyarn global add ganache-cli\n```\n\nClone \u0026 navigate into the repository:\n\n```\ngit clone git@github.com:sbrichards/simple-democracy.git \u0026\u0026 cd simple-democracy\n```\n\n## Running / Development\n\n#### From project root...\n\nDownload dependencies:\n\n```\nyarn\n```\n\nFire up your local development blockchain:\n\n```\nganache-cli\n```\n\nIn addition to spinning up a test network (listening on 127.0.0.1:8545 by default), Ganache also creates 10 addresses, each with a balance of 100 ETH.\n\nLeave this terminal window open and copy the Mnemonic output. You'll need to [paste this seed phrase into MetaMask](https://medium.com/publicaio/how-import-a-wallet-to-your-metamask-account-dcaba25e558d) in order to import and control these accounts.\n\nCompile \u0026 deploy the application contracts to the test network:\n\n```\ntruffle migrate\n```\n\n#### From app/ directory...\n\nDownload dependencies:\n\n```\nyarn\n```\n\nFire up the React application:\n\n```\nyarn start\n```\n\nThe application shoud now be accessible at [http://localhost:3000/](http://localhost:3000/).\n\nLeave this terminal window open.\n\nPaste the Mnemonic from Ganache into MetaMask using the [\"import with seed phrase\" option](https://medium.com/publicaio/how-import-a-wallet-to-your-metamask-account-dcaba25e558d). From the MetaMask network dropdown, select the private network (Localhost 8545). You should now have control of the generated addresses to sign transactions.\n\n## Using the dApp\n\nThis dApp has three user types:\n\n1. Admins\n2. Voters\n3. Unregistered users\n\nA \"user\" in the dApp is an Ethereum account address. Users can interact with this dApp through MetaMask.\n\nOnly admins can:\n\n- Register users (i.e. Ethereum account addresses) as admins and/or as voters\n- Create elections by submitting a name for the election\n- Add candidates (i.e. Ethereum account addresses) to an election\n- Open elections, which allow voters to vote on the election\n- Close elections, which end voting and calculate a winner\n\nAll voters can:\n\n- Vote once for a candidate per open election\n- View their admin \u0026 registration status\n- View election stats\n\nUnregistered users can:\n\n- View their Ethereum address and Ether balance\n- Not much else...\n\nNote: the account that deploys the contract (the first account in your local test network) will be automatically registered as an admin.\n\nElections structs are state machines stored in contract storage - they maintain a status (either \"Pending\", \"Active\" or \"Closed\") representing their lifecycle stage.\n\n- Pending: the election has been created, admins can add candidates to this election and open the election\n- Active: the election is open, voters can vote on the election and admins can close the election\n- Closed: the election is close, the winner is calculated and no further actions can be taken on the election\n\n## Running Tests\n\n```\ntruffle test\n```\n\n## Deploying\n\nIf you'd like to interact with the contract on a testnet, see [deployed_addresses.txt](./deployed_addresses.txt).\n\nIf you'd like to deploy the contract to a testnet, the [truffle-config.js](./truffle-config.js) is set up to deploy to Rinkeby. You'll have place your mnemonic seed phrase into a file named `.secret` in this project root:\n\n```\necho 'your seed phrase in a string like this' \u003e\u003e .secret\n```\n\nEnsure your account address has adequate funds to deploy the contract, e.g. by using the [Rinkeby Faucet](https://faucet.rinkeby.io/).\n\nThen run:\n\n```\ntruffle migrate --network rinkeby\n```\n\n## Resources\n\n- [Design decisions of this project](./design_pattern_decisions.md)\n- [Attack vulnerabilities of this project](./avoiding_common_attacks.md)\n- [Truffle Suite](https://www.truffleframework.com/)\n\n## Troubleshooting\n\nIn general, if you encounter an issue (e.g. when submitting an input), refreshing the browser should solve the problem.\n\nIf you're able to describe the steps that produced your issue and copy any errors from the console, please email me at sbrichards(at)gmail(dot)com and I'll look into it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamajammin%2Fsimple-democracy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamajammin%2Fsimple-democracy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamajammin%2Fsimple-democracy/lists"}