Skip to main content

Task Development Guide

banner

Easy-Peasy, JavaScript

Our mission is to improve access to decentralized technology, which is why Koii tasks are written and configured entirely in JavaScript (NodeJS 16, to be exact) and support the majority of popular NPM Modules.

It can help to think of task executables as Express.js nodes for hire, each of which stake tokens and reputation to participate. Combined with Koii App Library, that means you can deploy an entire stack, decentralized, with just JavaScript, while taking advantage of all the existing Node.js modules.

Task Development Guide

Developing Tasks

When creating a new task, there are three main functions that define the task's logic, how results should be verified, and how rewards will be distributed. These are the functions:

  1. The Task Function
    This function contains the core logic of the Koii task and submits the proof of the work done by participating nodes to K2.

    Execute Tasks

  2. The Audit Function
    This function verifies the validity of the submissions made by nodes. If a node's submission is invalid, an audit is initiated, and other participating nodes vote for or against the audit. If they cast a negative vote, the malicious node's stake is slashed and they are not eligible to receive rewards for completing the task.

    Audit Tasks

    Any significant aspects of the task, regardless of whether they are directly associated with bounties or not, should be subject to audits.

    Please see the audit section for details.

  3. The Distribution Function
    This function generates a distribution list and submits it on-chain. A distribution list is a JSON object containing a key-value pair, where the key is the public key of the node that made the submission and the value is the number of KOII tokens to be rewarded to the node.

    Distribute Rewards

tip

Confused on how's the runtime flow looks like? Check out the Runtime Flow to understand the task execution flow.

Ready to get started? Let's dive into the details of each of these functions. Start here.