MACI
A contract which allows users to sign up, and deploy new polls
stateTreeDepth
uint8 stateTreeDepth
The state tree depth is fixed. As such it should be as large as feasible so that there can be as many users as possible. i.e. 2 ** 23 = 8388608 this should also match the parameter of the circom circuits. IMPORTANT: remember to change the ballot tree depth in contracts/ts/genEmptyBallotRootsContract.ts file if we change the state tree depth!
maxSignups
uint256 maxSignups
STATE_TREE_ARITY
uint8 STATE_TREE_ARITY
PAD_KEY_HASH
uint256 PAD_KEY_HASH
This is the poseidon hash of the pad key
emptyBallotRoots
uint256[5] emptyBallotRoots
The roots of the empty ballot trees
nextPollId
uint256 nextPollId
Each poll has an incrementing ID
polls
mapping(uint256 => struct IMACI.PollContracts) polls
A mapping of poll IDs to Poll contracts.
pollFactory
contract IPollFactory pollFactory
Factory contract that deploy a Poll contract
messageProcessorFactory
contract IMessageProcessorFactory messageProcessorFactory
Factory contract that deploy a MessageProcessor contract
tallyFactory
contract ITallyFactory tallyFactory
Factory contract that deploy a Tally contract
leanIMTData
struct LeanIMTData leanIMTData
The state tree. Stores users' public keys
signUpPolicy
contract IBasePolicy signUpPolicy
Address of the signup policy, a contract which determines whether a user may sign up to vote
stateRootsOnSignUp
uint256[] stateRootsOnSignUp
The array of the state tree roots for each sign up For the N'th sign up, the state tree root will be stored at the index N
SignUp
event SignUp(uint256 _stateIndex, uint256 _timestamp, uint256 _userPubKeyX, uint256 _userPubKeyY)
DeployPoll
event DeployPoll(uint256 _pollId, uint256 _coordinatorPubKeyX, uint256 _coordinatorPubKeyY, enum DomainObjs.Mode _mode)
PoseidonHashLibrariesNotLinked
error PoseidonHashLibrariesNotLinked()
custom errors
TooManySignups
error TooManySignups()
InvalidPubKey
error InvalidPubKey()
PollDoesNotExist
error PollDoesNotExist(uint256 pollId)
UserNotSignedUp
error UserNotSignedUp()
constructor
constructor(contract IPollFactory _pollFactory, contract IMessageProcessorFactory _messageProcessorFactory, contract ITallyFactory _tallyFactory, contract IBasePolicy _signUpPolicy, uint8 _stateTreeDepth, uint256[5] _emptyBallotRoots) public payable
Create a new instance of the MACI contract.
Parameters
Name | Type | Description |
---|---|---|
_pollFactory | contract IPollFactory | The PollFactory contract |
_messageProcessorFactory | contract IMessageProcessorFactory | The MessageProcessorFactory contract |
_tallyFactory | contract ITallyFactory | The TallyFactory contract |
_signUpPolicy | contract IBasePolicy | The signup policy contract |
_stateTreeDepth | uint8 | The depth of the state tree |
_emptyBallotRoots | uint256[5] | The roots of the empty ballot trees |
signUp
function signUp(struct DomainObjs.PubKey _pubKey, bytes _signUpPolicyData) public virtual
Allows any eligible user sign up. The sign-up policy should prevent double sign-ups or ineligible users from doing so. This function will only succeed if the sign-up deadline has not passed.
Parameters
Name | Type | Description |
---|---|---|
_pubKey | struct DomainObjs.PubKey | The user's desired public key. |
_signUpPolicyData | bytes | Data to pass to the sign-up policy register() function. For instance, the POAPPolicy or TokenPolicy requires this value to be the ABI-encoded token ID. |
deployPoll
function deployPoll(struct IMACI.DeployPollArgs args) public virtual returns (struct IMACI.PollContracts)
Deploy a new Poll contract.
Parameters
Name | Type | Description |
---|---|---|
args | struct IMACI.DeployPollArgs |
getStateTreeRoot
function getStateTreeRoot() public view returns (uint256 root)
Return the main root of the StateAq contract
Return Values
Name | Type | Description |
---|---|---|
root | uint256 | The Merkle root |
getPoll
function getPoll(uint256 _pollId) public view returns (struct IMACI.PollContracts pollContracts)
Get the Poll details
Parameters
Name | Type | Description |
---|---|---|
_pollId | uint256 | The identifier of the Poll to retrieve |
Return Values
Name | Type | Description |
---|---|---|
pollContracts | struct IMACI.PollContracts | The Poll contract object |
numSignUps
function numSignUps() public view returns (uint256 signUps)
Get the number of signups
Return Values
Name | Type | Description |
---|---|---|
signUps | uint256 | numsignUps The number of signups |
getStateRootOnIndexedSignUp
function getStateRootOnIndexedSignUp(uint256 _index) external view returns (uint256 stateRoot)
Return the state root when the '_index' user signed up
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | The serial number when the user signed up |
Return Values
Name | Type | Description |
---|---|---|
stateRoot | uint256 | The Merkle root |
getStateIndex
function getStateIndex(uint256 _pubKeyHash) external view returns (uint256)
Get the index of a public key in the state tree
Parameters
Name | Type | Description |
---|---|---|
_pubKeyHash | uint256 | The hash of the public key |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | index The index of the public key in the state tree |