Skip to main content


In the usual workflow, for a given round n, a submission is made , the audit is conducted on the submissions made in round n-1 and the distribution process encompasses the submissions made in round n-2.

Hence, after completing the implementation of the task logic, including the submission to K2 and the subsequent audit, the next step is to devise a mechanism for rewarding users based on their submissions. To achieve this, once the audit window concludes, a node is designated with the responsibility of generating and submitting an on-chain distribution list.

The distribution list is represented as a JSON object, consisting of key-value pairs. In this context, where the key is the node's public key and the value is the number of KOII tokens to be awarded to the node.

We can use generateDistributionList() and validateDistribution() function for the same, that is listed in distribution.js under the task directory.


The Task Template contains a sample logic for the generateDistributionList(), which rewards 1 KOII to all the nodes with valid submissions for that round. We'd retain the logic for the Hello World project.

In the sample code:

  • An empty distribution list is initialized.
  • The task's data is retrieved using the getTaskState helper function
  • All submissions are fetched from the task's data.
  • The submissions_audit_trigger is also retrieved from the task's data; this object contains information about the audited submissions.
  • An empty distribution list is returned if submissions is null. Otherwise, the keys and values of submissions are grouped separately, and in a loop, it calculates the audits on each submission and the number of votes on the audit and then generates a distribution list based on that.


In the sample code present in the template:

  • The distribution list is fetched.
  • If the distribution list is not null, it is parsed and stored in the variable fetchedDistributionList.
  • The distribution list is re-generated by calling the generateDistributionList method with the current round number and task state as parameters.
  • The generated distribution list is stored in the variable generatedDistributionList.
  • Finally, fetchedDistributionList and generatedDistributionList are compared to see if they are equal. If they are, this method returns true, otherwise false.