open-index/open-npm huggingface dataset:
npm package: @roamin/ecvrf
Description: Elliptic Curve VRF
Latest version: 0.2.0

Verifiable Random Function (VRF)
------------------

This library has an implementation of an ECVRF based on the [IETF draft 05](https://tools.ietf.org/id/draft-irtf-cfrg-vrf-05.html) using the secp256k1 curve, `SHA256` as hash function and `try-and-increment` as hash to curve method (cipher suite `SECP256K1_SHA256_TAI`). The cipher suite code used is `0xFE` for compatibility with other implementations.

### Node
```sh
# with npm
npm install @roamin/ecvrf

# with yarn
yarn add @roamin/ecvrf
```

### Usage

```js
const { prove, proofToHash, verify } = require('@roamin/ecvrf');
const elliptic = require('elliptic');

const EC = new elliptic.ec('secp256k1');

const SECRET = EC.keyPair({ priv: 'c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721', privEnc: 'hex' });

const msg = Buffer.from('sample').toString('hex');

// VRF proof and hash output
const proof = prove(SECRET.getPrivate(), msg);
const hash = proofToHash(proof);

// VRF proof verification (returns VRF hash output)
const beta = verify(SECRET.getPublic('hex'), proof, msg);
```
npm package: @roamin/koinos-as-gen
Description: This is a `protoc` plugin to generate Koinos AssemblyScript Contract boilerplate code based on a proto file.
Author: Roamin Ro
Latest version: 1.0.1

# koinos-as-gen
This is a `protoc` plugin to generate Koinos AssemblyScript Contract boilerplate code based on a proto file.

## Installation
```sh
# with npm
npm install --save-dev koinos-as-gen

# with yarn
yarn add --dev koinos-as-gen
```

## Important note
The plugin will generate a `CONTACT.boilerplate.ts` file and an `index.ts`, for this to work the proto file needs to follow these rules:
  - the proto file must like in a `proto` folder that is at the same level as the AssemblyScript files
  - arguments messages must be name as `METHODNAME_arguments`
  - result messages must be name as `METHODNAME_result` (you can also provide a custom result by using the `@result` decorator. The custom result MUST be within the same proto file)

## Usage

```sh
protoc --plugin=protoc-gen-as=./node_modules/.bin/koinos-as-gen --as_out=. myProtoFile.proto

// you can generate the "authorize" entry point by setting the GENERATE_AUTHORIZE_ENTRY_POINT env variable
GENERATE_AUTHORIZE_ENTRY_POINT=1 protoc --plugin=protoc-gen-as=./node_modules/.bin/koinos-as-gen --as_out=. myProtoFile.proto

// you can set the return buffer size of the contract by setting the RETURN_BUFFER_SIZE env variable
RETURN_BUFFER_SIZE=2048 protoc --plugin=protoc-gen-as=./node_modules/.bin/koinos-as-gen --as_out=. myProtoFile.proto
```

## Example
The following proto file:
```proto
syntax = "proto3";

package calculator;

// @description Add two integers
// @read-only true
message add_arguments {
  int64 x = 1;
  int64 y = 2;
}

message add_result {
  int64 value = 1;
}
```

will generate the following `Calculator.boilerplate.ts file:
```js
import { calculator } from "./proto/calculator";

export class Calculator {
  add(args: calculator.add_arguments): calculator.add_result {
    // const x = args.x;
    // const y = args.y;

    // YOUR CODE HERE

    const res = new calculator.add_result();
    // res.value = ;

    return res;
  }
}
```

and will generate the following `index.ts file:
```js
import { System, Protobuf } from "koinos-as-sdk";
import { Calculator as ContractClass } from "./Calculator";
import { calculator as ProtoNamespace } from "./proto/calculator";

export function main(): i32 {
  const entryPoint = System.getEntryPoint();
  const rdbuf = System.getContractArguments();
  let retbuf = new Uint8Array(1024);

  const c = new ContractClass();

  switch (entryPoint) {
    case 0x7e9e5ac3: {
      const args = Protobuf.decode<ProtoNamespace.add_arguments>(
        rdbuf,
        ProtoNamespace.add_arguments.decode
      );
      const res = c.add(args);
      retbuf = Protobuf.encode(res, ProtoNamespace.add_result.encode);
      break;
    }

    default:
      System.exitContract(1);
      break;
  }

  System.setContractResult(retbuf);

  System.exitContract(0);
  return 0;
}

main();
```
npm package: @roamin/koinos-sdk-as
Description: [![Test](https://github.com/roaminro/koinos-sdk-as/actions/workflows/test.yml/badge.svg)](https://github.com/roaminro/koinos-sdk-as/actions/workflows/test.yml)
Author: Roamin Ro
Latest version: 1.2.0

[![Test](https://github.com/roaminro/koinos-sdk-as/actions/workflows/test.yml/badge.svg)](https://github.com/roaminro/koinos-sdk-as/actions/workflows/test.yml)

# koinos-sdk-as
AssemblyScript (AS) Software Development Toolkit (SDK) for the Koinos Blockchain

See documentation: https://roaminro.github.io/koinos-sdk-as/

Learn how to create smart contracts by looking at the examples repo: https://github.com/roaminro/koinos-sdk-as-examples

## Requirements:
You need to install NodeJS v16 or higher [download](https://nodejs.org/en/download/)

## Installation

```sh
# with npm
npm install @roamin/koinos-sdk-as

# with yarn
yarn add @roamin/koinos-sdk-as
```
## Run unit tests
```sh
# with npm
npm test

# with yarn
yarn test
```

## Build test contract
```sh
# with npm
npm run buildTestContract

# with yarn
yarn run buildTestContract
```

## Upload and trigger the test contract on a local devnet using [Local-Koinos](https://github.com/roaminro/local-koinos)
```sh
🚫 🔐 > open wallets/bob.wallet bob
Opened wallet: wallets/bob.wallet

🚫 🔓 > connect http://localhost:8080
Connected to endpoint http://localhost:8080

🔓 > register foobar 161DDwJNQyHqYJbP4C7Y8BTULrkjgC4U6g /test/abi/foobar.abi
Contract 'foobar' at address 161DDwJNQyHqYJbP4C7Y8BTULrkjgC4U6g registered

🔓 > foobar.foobar 42
Calling foobar.foobar with arguments 'value:42'
Transaction with ID 0x1220654597dfe99b4d5f841c129be39d3fe725539240b9efb43f8ea8ab4d9cd35742 containing 1 operations submitted.
Mana cost: 0.01831902 (Disk: 10, Network: 254, Compute: 1830532)
Logs:
entryPoint: 3282800625
contractArgs: 42
contractId (b58): 161DDwJNQyHqYJbP4C7Y8BTULrkjgC4U6g
headInfo.head_block_time: 1645327982254
headInfo.head_topology.height: 7771
headInfo.last_irreversible_block.: 7711
callerData.caller_privilege: 1
lastIrreversibleBlock: 7711
putRes: 0
obj: testValue
putRes: 0
obj: testValue2
obj: testValue2
putRes3: 0
obj5.value: 42
no obj5
recoveredKey (b58): 1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe
value2
no key5
value3
key3
value1
key1
nothing before key1
nothing after key3
obj201.value: 200
next obj202.value: 300
prev obj202.value: 100
nothing before key1
nothing after key3
payer: 161DDwJNQyHqYJbP4C7Y8BTULrkjgC4U6g
payer: 161DDwJNQyHqYJbP4C7Y8BTULrkjgC4U6g
```
npm package: @roamin/local-koinos
Description: Local Koinos CLI'
Latest version: 0.4.16

[![ubuntu-ci](https://github.com/roaminro/local-koinos/actions/workflows/ubuntu-ci.yml/badge.svg)](https://github.com/roaminro/local-koinos/actions/workflows/ubuntu-ci.yml)
[![macos-ci](https://github.com/roaminro/local-koinos/actions/workflows/macos-ci.yml/badge.svg)](https://github.com/roaminro/local-koinos/actions/workflows/macos-ci.yml)

# Local-Koinos

Local-Koinos is a set of scripts and tools that will help you spin up a devnet on your local machine in minutes.

## Install Docker (and Docker-Compose)

You will need to install Docker on MacOS, Linux or Windows first. You can follow their instructions for installation [here](https://www.docker.com/products/docker-desktop). Docker desktop comes with a recent version of docker-compose, but make sure it's at least docker-compose v2.

## Installation
```sh
# with npm
npm install -g @roamin/local-koinos

# with yarn
yarn global add @roamin/local-koinos
```

## Usage as CLI
```sh
# start a local Koinos devnet (default mode is "auto")
# there are 3 modes available:
# - auto: produces a block every time you submit a transaction to the mempool
# - interval: creates a block every X seconds with all transactions available in the mempool (default is every 3 seconds)
# - manual: awaits for blocks to be manually submitted to the chain
# a local JSON RPC service will be available by default at http://127.0.0.1:8080
local-koinos start

# stop the node
local-koinos stop
```

## Example of programmatic usage using JavaScript/TypeScript

```js
import { LocalKoinos, Token, Signer } from '@roamin/local-koinos';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore 
import * as abi from './calculator-abi.json';

// @ts-ignore koilib_types is needed when using koilib
abi.koilib_types = abi.types

const localKoinos = new LocalKoinos();

// start local-koinos node
await localKoinos.startNode();
// start block production in auto mode (a block gets produced every time you submit a transaction)
await localKoinos.startBlockProduction();

// deploy the Koin contract
await localKoinos.deployKoinContract();

// mint 50,000 Koin tokens to 10 accounts
await localKoinos.mintKoinDefaultAccounts();

// get the accounts initialized with `mintKoinDefaultAccounts`
const [genesis, koin, acct1] = localKoinos.getAccounts();

// deploy a contract to the devnet (returns an instance of a Koilib Contract)
const contract = await localKoinos.deployContract(acct1.wif, './calculator-contract.wasm', abi);

// call your contract functions
const { result } = await contract.functions.add({ x: '4', y: '5' });
expect(result!.value).toBe('9');

// stop local-koinos node
await localKoinos.stopNode();
```

## Example of programmatic usage using Jest
https://github.com/roaminro/local-koinos/blob/0ddc2bf468418fa743c017a457ba9f7701e229eb/tests/tests.spec.ts#L1-L59