System Setup
🐧 This tutorial is for Ubuntu Desktop 22.04.2
Setting up the System from Scratch
Open a terminal and install the node package manager
sudo apt install npm
Install NodeJS version 16.13 and open a new terminal afterwards
sudo npm cache clean -f
sudo npm install -g n
sudo n 18.12
sudo npm install -g npm@9.6
Install git
sudo apt install git
Download the Code
Clone the project from Bitbucket to your local machine.
git clone {repository-url}
Setup the Project
All the commands of the e-voting system need to be run inside the root folder of the project, unless specified otherwise.
To install all the required npm packages and the cli tool, enter:
npm run setup
The installation of all the packages can take a while!
Install the Registration Application
This code only works on debian based systems. You can find a .exe installer for Windows and a zip file containing the MacOS application at ./assets/registration-app-builds/
.
To install the pre-built and packaged application, run:
npm run iregdeb
If you want to build and install the app yourself, run:
sudo npm i -g electron
npm run makeregdeb
Configure the Project
Open the configuration file of the server and the contract at config/config.json
.
The value for MNEMONIC
is the mnemonic for the Ethereum account that will be used to deploy the contract to the Mumbai test network.
The value for PRIVATE_KEY
is the private key of the Ethereum account that will be used to relay the votes to the smart contract.
An Ethereum mnemonic and private key can be generated with the help of the cli tool after it has been installed. (Enter chainvote
in a terminal and choose the option to create an Ethereum account.)
The account you generated also needs to be funded with test Matic, which you can do for free at faucet.polygon.technology.
The next step is to specify a PROVIDER_PROXY
. The PROVIDER_PROXY
is the url of the node, which will be used to access the blockchain. You can use https://rpc-mumbai.matic.today/
for free, but it is recommended to use a non-shared node (offered by Alchemy and Infura), because public nodes are rate limited and don't work all the time. The TARGET
value of the provider proxy is the base url of the node, whereas ENDPOINT
is anything that comes after the base url.
After performing these steps, your config/config.json
file should look something like this:
{
"contract": {
"LOAD_ADMINS": "TRUE",
"PUBLICNET": "FALSE",
"MNEMONIC": "east deal economy gas fit swap asset cart man hospital panel copy",
"UPDATE_ABI": "FALSE"
},
"server": {
"PORT": 8080,
"PRIVATE_KEY": "0x81c974985f21770f365a74018750acb740070db6fa720aa967a86f65c95bacca",
"NODE_ENV": "development",
"PROVIDER_PROXY": {
"TARGET": "https://rpc-mumbai.matic.today",
"ENDPOINT": "/"
}
}
}
Optionally you can update the PORT
value, if you want to use a different port than the pre-configured one.
Next, open the config/Evote.config.json
file. For now, the only thing you need to update is the provider
value. The value for provider can be the same as the full url of PROVIDER_PROXY
for testing purposes.
Now distribute the contract and server config:
npm run updateconfig
Deploy the Evote Contract
The accounts that will be set as the admins on contract deployment are located in the config/Admins.config.json
file. You can create these accounts using the cli tool the same way as mentioned above. You will also need to fund these accounts as mentioned above already.
In order to deploy a contract instance to the public testnet, enter:
npm run deploytest
Truffle will first compile the Evote contract and then deploy it. The contract is very large, that's why the deployment might take several minutes. It is very important that you'll save the contract address of the contract instance (Truffle will first deploy a contract called "Migrations", whose address you don't need, and after that a contract called "Evote", whose address you need to save). Truffle will tell you the address during deployment. You will need to save the address somewhere for the next step.
Configure the Evote Contract
Open the Evote contract configuration file located at config/Evote.config.json
. Here you first need to update the value of address
. This is the address of the deployed contract instance on the public test network.
Now enter the address that truffle returned after deploying the contract.
To distribute the Evote contract config and build the front-ends, run:
npm run build
Start the Server
To start the server with the relay and the front-ends, enter:
npm run startserver
- The admin app should now be available at:
http://localhost:{PORT}/admin/
- The voting app should now be available at:
http://localhost:{PORT}/client/
Configure your Browser
Because the e-voting system uses WebCrypto and no https during testing, you will need to enable the secure context manually in your browser. Follow these steps for chrome:
- Visit
chrome://flags/#unsafely-treat-insecure-origin-as-secure
- Enable the option and set the value to
http://localhost
- Apply the changes
The next time you want to test the front-ends, you only need to run npm run startserver
You now finished the setup and can start testing 🥳