{"id":27934,"library":"maci-cli","title":"MACI CLI","description":"Command-line interface for Minimal Anti-Collusion Infrastructure (MACI), version 2.5.0. MACI is a set of smart contracts and zero-knowledge proofs for on-chain voting that prevents bribery and coercion. This CLI provides tools for deploying, managing, and interacting with MACI instances. It captures commands for coordinator operations, user key generation, and contract deployment. Released under the MACI project, updated infrequently with new protocol iterations.","status":"active","version":"2.5.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install maci-cli","lang":"bash","label":"npm"},{"cmd":"yarn add maci-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add maci-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core MACI types and interfaces","package":"maci-core","optional":false},{"reason":"Domain object classes for MACI","package":"maci-domainobjs","optional":false},{"reason":"Cryptographic utilities (BabyJubJub, Poseidon)","package":"maci-crypto","optional":false}],"imports":[{"note":"Default export provides the CLI entry point.","wrong":"import { maciCLI } from 'maci-cli'","symbol":"default","correct":"import maciCLI from 'maci-cli'"},{"note":"Named export 'CLI' is available for programmatic use.","wrong":"const CLI = require('maci-cli').CLI","symbol":"CLI","correct":"import { CLI } from 'maci-cli'"},{"note":"Individual named exports for each subcommand; available since v2.5.0. Using wildcard import may clash with other MACI packages.","wrong":"import * as maciCLI from 'maci-cli'","symbol":"Subcommands","correct":"import { deployVkRegistry, setVerifyingKeys, signup, publish, tallyVotes, processMessages } from 'maci-cli'"},{"note":"CommonJS require works with named exports. Default export not applicable for CJS.","wrong":"const maciCLI = require('maci-cli')","symbol":"CLI","correct":"const { CLI } = require('maci-cli')"}],"quickstart":{"code":"import { signup, publish, processMessages, tallyVotes } from 'maci-cli';\nimport { PrivKey, PubKey, Keypair } from 'maci-domainobjs';\n\nasync function main() {\n  const keypair = new Keypair();\n  const privKey = keypair.privKey.serialize();\n  const pubKey = keypair.pubKey.serialize();\n  await signup({ pubKey, privateKey: privKey });\n  const vote = { voteOptionIndex: 1, voteWeight: 9 };\n  await publish({ privateKey: privKey, vote, stateIndex: 1 });\n  await processMessages();\n  const result = await tallyVotes();\n  console.log('Tally result:', result);\n}\nmain().catch(console.error);","lang":"typescript","description":"Shows how to use key CLI functions programmatically: generate keys, signup user, publish vote, process messages, and tally votes."},"warnings":[{"fix":"Generate new keys using Keypair.generate() from maci-domainobjs.","message":"MACI v2.0 uses a new key format. Old keys must be regenerated.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Deploy new contracts using CLI or hardhat tasks.","message":"MACI v2.0 requires a fresh smart contract deployment. Not backward-compatible with v1.x.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Replace `create` with `signup`.","message":"The old `create` subcommand is deprecated; use `signup` instead.","severity":"deprecated","affected_versions":">=2.0"},{"fix":"Use privKey.serialize() to get a hex string.","message":"All private keys must be serialized as hex strings. Raw Buffer objects are not accepted.","severity":"gotcha","affected_versions":">=2.5.0"},{"fix":"Ensure your contract artifacts and CLI versions match exactly.","message":"State leaf hashes differ between MACI v2.0 and v2.5.0. Tally results will fail if mismatched.","severity":"gotcha","affected_versions":">=2.5.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Convert using `SerializedPrivateKey = privKey.serialize()`.","cause":"Passing a Buffer object instead of a hex string.","error":"Error: Invalid private key"},{"fix":"Only call serialize() on Keypair objects, not on hex strings.","cause":"Attempting to serialize an already serialized key.","error":"TypeError: Cannot read properties of undefined (reading 'serialize')"},{"fix":"Run `maci deploy` or use hardhat tasks to deploy.","cause":"Using CLI without deploying MACI contracts first.","error":"Error: Contract not deployed"},{"fix":"Check contract timestamps or wait until the voting period is active.","cause":"Calling publish or tallyVotes outside the voting window.","error":"Error: voting period not started"},{"fix":"Ensure the circuit files (e.g., processMessages) are correctly generated and placed in the expected path.","cause":"Using zk-SNARK artifacts that do not match the deployed circuit.","error":"Error: invalid proof"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}