Preventing Voter Fraud
vote/noVotes predicates hold all of the auth records that voted for or against a proposed change.
We need to make sure that only the owner of a given auth record adds their auth record to yes or no votes.
To do this, we can add a spec to both of these predicates, which ensures that users only cast votes with their own auth records.
The transaction will look as follows:
"_fn/code": "SMART FUNCTION CODE HERE"
"_id": ["_predicate/name", "vote/yesVotes"],
"_id": ["_predicate/name", "vote/noVotes"],
It is your job to write the code of the smart function. Remember, we want to check whether the
_auth we add to
vote/noVotes is your own
You will need one (or several) of these smart function to write,
You will also need several context-specific functions. Note, you may not need all of these functions:
_idfor the subject being updated.
_idof the auth making the update.
_idof the user making the update.
(?o): Tthe object (value) of the predicate that is being edited.
Write the Smart Function!
Using the above instructions, write the smart function code for ownAuth