This repository contains the necessary files to build a Docker image for the MACI project. The Docker image supports two workflows:
- Starting an API server to listen to API requests.
- Running a command with a specified poll ID and private key.
- Docker installed on your machine.
- Node.js installed on your machine (for local development).
- Populate the
.envfile with following environment variables.PINATA_JWT= ETH_SK=
To build the Docker image, navigate to the root directory of the repository and run the following command:
docker build -t maci-docker .To start an API server, run the following command:
docker run -p 3000:3000 maci-dockerFollowing endpoints would be available
This endpoint is used to check if the server is running. It returns a simple message "Hello World!".
- Method:
GET - URL:
/hello
- Status Code:
200 OK - Body:
Hello World!
This endpoint is used to generate a tally for a specified poll. It performs several steps to merge messages, merge signups, generate proofs, and pin the resulting tally file to IPFS using Pinata.
- Method:
POST - URL:
/generate-tally - Headers:
Content-Type: application/json - Body:
{ "pollId": "<PollId>", "coordinatorPrivateKey": "<CoordinatorPrivateKey>" }
- Success: Returns the CID (Content Identifier) of the pinned tally file
{
"cid": "<CID>"
}
- Error: Returns an error message
{
"error": "<ErrorMessage>"
}
Example:
curl -X POST http://localhost:3000/generate-tally \
-H "Content-Type: application/json" \
-d '{
"pollId": "1",
"coordinatorPrivateKey": "your_coordinate_private_key"
}'- Merge Messages: Runs the
mergeMessagescommand for the specified poll ID.
node build/ts/index.js mergeMessages --poll-id <PollId>- Merge Signups: Runs the
mergeSignupscommand for the specified poll ID.
node build/ts/index.js mergeSignups --poll-id <PollId>- Generate Proof: Runs the
generateProofcommand for the specified poll ID and creates a tally file.
node build/ts/index.js genProofs -sk <CoordinatorPrivateKey> -zp /path/to/ProcessMessages.zkey -zt /path/to/TallyVotes.zkey -tw /path/to/TallyVotes.wasm -pw /path/to/ProcessMessages.wasm --poll-id <PollId> -w true -t tally-file.json --output proofs/-
Pin Tally File: Pins the generated tally file to IPFS using Pinata. Only poll deployer can pin the file, helps in avoiding gas costs of pushing large metadata to the chain.
-
Return CID: Returns the CID of the pinned tally file.
To run the command with a specified poll ID and private key, provide the poll ID and private key as arguments when running the Docker container:
```bash
docker run maci-docker <PollId> <CoordinatorPrivateKey>
```
-
If you encounter an error while building the Docker image, try running the following command to remove all Docker images:
docker system prune -a
Also ensure that you have provided the correct arguments and that the Docker container has the necessary permissions to access the required files.
Feel free to contribute to this repository by opening an issue or a pull request. Please ensure that your pull request follows the Conventional Commits specification.
This project is licensed under the MIT License - see the LICENSE file for details.