NAV
javascript shell

Tools for Easy Protocolization

pro·to·col /ˈprōdəˌkôl,ˈprōdəˌkäl/

noun

the official procedure or system of rules governing affairs of state or diplomatic occasions. "protocol forbids the prince from making any public statement in his defense"

Tokenized Protocols

Bitcoin and others have popularized the system of using tokens within a network of peers as a means of rewarding good behaviour. This addition has expanded the feasibility of protocols as tools for social change, and specifically has created a new type of economic motive which can be sharpened and honed specifically for a particular task.

Koii

The aim of the Koii network is to provide a convenient and simple way for software developers to easily concieve, implement, and deploy new mechanisms, while also enriching the public commons.

Koii provides a suite of software tools designed to:

  1. Reward attention-based contributions, such as art and public data sets;
  2. Reliably track and reward repeatable tasks;
  3. Establish incentives and markets to reward profitable shifts in behaviour of (1) or (2).

Join the Network

The Koii Network is made up of devices running compatible protocol software. Install "@_koi/sdk" to join.

// For NodeJS environments
const knode = require("@_koi/sdk/node");
const ktools = new knode.Node();

const walletKeyLocation = "/path/to/your/wallet.json";

async () => {
  await ktools.nodeLoadWallet(walletKeyLocation);
  console.log("ktools", ktools);
};

Make sure to replace /path/to/your/wallet.json with the location of your wallet file.

// For web and browser environments
const kweb = require("@_koi/sdk/web");
const ktools = new kweb.Web();

// Use the Koi extension to interact with the wallet
$ npm i @_koi/sdk
$ yarn add @_koi/sdk

Wallet Generation

Koii uses Arweave wallets for interacting with the network. If you don't yet have a Arweave wallet, you can generate a standard wallet, or a mnemonic wallet using our SDK.

// Standard wallet
await ktools.generateWallet();
console.log("My wallet: ", ktools.wallet);
// {kty:"RSA", n:"0vx7agoebGcQSuu...", e:"AQAB"... }

// Mnemonic wallet
await ktools.generateWallet(true);
console.log("My wallet: ", ktools.wallet);
// {kty:"RSA", n:"0vx7agoebGcQSuu...", e:"AQAB"... }
console.log("My mnemonic: ", ktools.mnemonic);
// "violin artwork lonely inject resource jewel purity village abstract neglect panda license"

// View wallet address
const myAddress = await ktools.getWalletAddress();
console.log(myAddress);
// "FeSD9TV8aB0GK0yby8A40KEX1N-3wrJQTDbRW4uUiEA"

Registering Content

Every 24 hours, the Koii Network votes to mint 1000 new tokens and awards them to the registered owners of the most popular content since the previous day.

let txId = "GoKkAKHi-g2WsVtcKKYqhRgpxOHlgtPRDxkIHC6FIAY";

var result = await ktools.registerData(txId);

console.log("transaction", result);

Make sure to replace GoKkAKHi-g2WsVtcKKYqhRgpxOHlgtPRDxkIHC6FIAY with the address of the content you want to register.

Transfer Koii Tokens

Transferring Koii Tokens is easy using our SDK, all that's needed is a small amount of AR token.

const receiverAddress = "FeSD9TV8aB0GK0yby8A40KEX1N-3wrJQTDbRW4uUiEA";
const transferTxId = await ktools.transfer(123.456, friendAddress, "KOI");

Make sure to replace FeSD9TV8aB0GK0yby8A40KEX1N-3wrJQTDbRW4uUiEA with the wallet address you would like to transfer to.

Gateways

Gateways can be added to the Koii network to include more content in the traffic rewards network. Contact us about grants to help you get set up to track traffic and reward creators!

Install Koii Middleware

The Koii middleware package provides easy traffic logging, and will soon be expanded to support proof of work headers.

npm i -g koi-logs
const Express = require("express");
// import { config } from 'dotenv';
const {
  koiLogMiddleware,
  koiLogsDailyTask,
  koiLogsHelper,
} = require("koi-logs");

// config();

var app = new Express();

// add koi tasks
app.use(koiLogMiddleware);
app.get("/logs", koiLogsHelper);
koiLogsDailyTask(); // start the daily log task

// start the server listener
app.listen(process.env.PORT || 3000, () => {
  log.info(`[app] started on http://localhost:${process.env.PORT || 3000}`);
});

Testing Tips

While most Koi nodes rely on bundlers to store consensus data on their behalf, you can also interact directly with the Koi smart contract using the Koi Tools library. In order to do that, you'll first want to visit the Arweave Faucet to get some free storage tokens, and then return back here once you have a standard wallet.json RSA file.