Skip to main content

Call minWinPercentage and minVotes

We are ready to create a new function that calls both minWinPercentage and minVotes. We will also finally add this function to _user/username.

The transaction is as follows:

[
{
"_id": "_fn",
"name": "2VotesMajority",
"code": "SMART FUNCTION CODE HERE"
},
{
"_id": ["_predicate/name", "_user/username"],
"spec": ["2VotesMajority"]
}
]

You should write smart function code that sets a minimum win percentage of 0.5 and a minimum number of votes to 2.

You'll also need several of the following smart functions.

FunctionArgumentsExample
incn optional(inc)
decn optional(dec)
==arg1 arg2 ...(== 1 1 1 1)
+arg1 arg2 ...(+ 1 2 3)
-arg1 arg2 ...(- 10 9 3)
*arg1 arg2 ...(* 90 10 2)
/arg1 arg2 ...(/ 36 3 4)
>arg1 arg2 ...(> 90 10 2)
<arg1 arg2 ...(< 90 10 2)
>=arg1 arg2 ...(>= 90 90 10 2)
<arg1 arg2 ...(< 2 10 90)
<=arg1 arg2 ...(<= 2 10 90 90)
maxarg1 arg2 ...(max 1 2 3)
minarg1 arg2 ...(min 1 2 3)
andarg1 arg2 ...(and (== 1 1) (> 10 3))
orarg1 arg2 ...(or (== 1 1) (> 10 3))

Write 2VotesMajority


Using `minWinPercentage`, `minVotes`, and any other functions necessary to write the code for 2VotesMajority