Skip to main content
Version: v2.0_alpha

SimplePayout

A simple payout contract that works with a SimpleProjectRegistry and a MACI Tally contract

WETH

contract IWETH WETH

WETH address

projectRegistry

contract ISimpleProjectRegistry projectRegistry

the project registry

payoutToken

address payoutToken

the payout token

tally

contract ITally tally

the tally contract

paidProjects

mapping(uint256 => bool) paidProjects

keep track of which users have already been paid

totalAmount

uint256 totalAmount

the total amount of tokens available to be paid out

totalVoiceCreditsSpent

uint256 totalVoiceCreditsSpent

the total amount of voice credits spent

uint256 paid

keep track of how many users have been paid

InvalidSpentVoiceCredits

error InvalidSpentVoiceCredits()

Custom errors

ProjectAlreadyPaid

error ProjectAlreadyPaid()

InvalidProof

error InvalidProof()

NotAllProjectsPaid

error NotAllProjectsPaid()

NotEnoughEther

error NotEnoughEther()

TransferFailed

error TransferFailed()

constructor

constructor(address _projectRegistry, address _token, address _tally, uint256 _totalAmount, uint256 _totalSpent, uint256 _totalSpentSalt, uint256 _resultCommitment, uint256 _perVOSpentVoiceCreditsHash, address _weth) public payable

Create a new instance of the payout contract

Parameters

NameTypeDescription
_projectRegistryaddressthe address of the project registry
_tokenaddressthe address of the payout token
_tallyaddressthe address of the tally contract
_totalAmountuint256the total amount of tokens available to be paid out
_totalSpentuint256the total amount of voice credits spent
_totalSpentSaltuint256the salt of the spent amount
_resultCommitmentuint256the commitment of the results
_perVOSpentVoiceCreditsHashuint256the hash of the spent voice credits
_wethaddress

deposit

function deposit() external payable

Deposit the amount of tokens to the contract

This function is only callable by the owner

payout

function payout(uint256 _voteOptionIndex, uint256 _spent, uint256[][] _proof, uint256 _spentSalt, uint256 _resultsCommitment, uint256 _spentVoiceCreditsCommitment, uint8 _voteOptionTreeDepth) external

Payout the amount of tokens to the projects

Parameters

NameTypeDescription
_voteOptionIndexuint256the index of the vote option
_spentuint256the amount of voice credits spent
_proofuint256[][]the proof of the spent amount
_spentSaltuint256the salt of the spent amount
_resultsCommitmentuint256the commitment of the results
_spentVoiceCreditsCommitmentuint256the commitment of the spent voice credits
_voteOptionTreeDepthuint8the depth of the vote option tree

collectDust

function collectDust() external

A function to collect the dust left from round downs can only be called once all projects have been paid

_handleNativeTransfer

function _handleNativeTransfer(address _dest, uint256 _amount) internal

Handle native transfers

Parameters

NameTypeDescription
_destaddressThe destination address
_amountuint256The amount to transfer