# @kyve/logic

> @kyve/logic

Latest version **0.0.0-alpha.19** (published 2021-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kyve/logic
pnpm add @kyve/logic
yarn add @kyve/logic
bun add @kyve/logic
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0-alpha.19 |
| Published | 2021-04-26 |
| First published | 2021-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 32.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | John Letey |
| Maintainers | fabianriewe, johnletey |

## Links

- npm: https://www.npmjs.com/package/@kyve/logic
- Repository: https://github.com/KYVENetwork/logic
- Homepage: https://github.com/KYVENetwork/logic#readme
- Issues: https://github.com/KYVENetwork/logic/issues
- npm.io page: https://npm.io/package/@kyve/logic

## Dependencies (6)

- [ardb](https://npm.io/package/ardb.md) ^1.0.8
- [rxjs](https://npm.io/package/rxjs.md) ^6.6.6
- [arweave](https://npm.io/package/arweave.md) ^1.10.11
- [smartweave](https://npm.io/package/smartweave.md) ^0.4.27
- [arweave-bundles](https://npm.io/package/arweave-bundles.md) ^1.0.3
- [@kyve/contract-lib](https://npm.io/package/@kyve/contract-lib.md) ^0.1.0-alpha.4

## Recent versions

- 0.0.0-alpha.19 (latest) — 2021-04-26
- 0.0.0-alpha.18 — 2021-04-26
- 0.0.0-alpha.17 — 2021-04-26
- 0.0.0-alpha.16 — 2021-04-26
- 0.0.0-alpha.15 — 2021-04-07
- 0.0.0-alpha.14 — 2021-04-07
- 0.0.0-alpha.13 — 2021-04-07
- 0.0.0-alpha.12 — 2021-04-07
- 0.0.0-alpha.11 — 2021-04-07
- 0.0.0-alpha.10 — 2021-04-07
- 0.0.0-alpha.9 — 2021-04-07
- 0.0.0-alpha.8 — 2021-04-02
- 0.0.0-alpha.7 — 2021-04-02
- 0.0.0-alpha.6 — 2021-03-31
- 0.0.0-alpha.5 — 2021-03-31
- … 5 more at https://npm.io/package/@kyve/logic/versions

## README

<p align="center">
  <a href="https://kyve.network">
    <img src="https://user-images.githubusercontent.com/62398724/110093923-289d6400-7d93-11eb-9d37-3ab7de5b752b.png" height="96">
  </a>
  <h3 align="center"><code>@kyve/logic</code></h3>
  <p align="center">A protocol for verified data streams.</p>
</p>

## Usage

### Installation

```
yarn add @kyve/logic
```

### Using KYVE in your application

#### Initiating a node

```ts
import KYVE from "@kyve/logic";

const node = new KYVE();
```

#### Node configuration

KYVE requires two custom functions. One which fetches the data from your data source and one which validates this data.
You can then simply add these two functions into the KYVE instance.

###### Specifying an upload function

To pass data into KYVE, simply call `subscriber.next()`:

```ts
const myDataFetcher = async (subscriber) => {
  // use your custom logic here
  const data = ...
  subscriber.next({ data });
}
```

You can also optionally add custom tags to your transactions:

```ts
const myDataFetcher = async (subscriber) => {
  // use your custom logic here
  const data = ...
  const tags = [...]
  subscriber.next({ data, tags });
}
```

###### Specifying a validation function

```ts
const myDataValidator = async (subscriber) => {
  // fetch the data uploaded onto Arweave
  const fetchedData = ...
  const arweaveTxId = ...
  // validate the data with your custom logic
  const isValid = ...
  // pass the result into KYVE
  subscriber.next({ valid: isValid, id: arweaveTxId });
}
```

###### Giving the node your functions

```ts
import KYVE from "@kyve/logic";

const node = new KYVE(myDataFetcher, myDataValidator);
```

###### Pool configuration

Next you need to set up the pool. You can create a new pool here.
After you have created the pool, insert its name and your arweave keyfile into the node config:

```ts
import KYVE from "@kyve/logic";

const pool = "demo-pool";
const jwk = ...

const node = new KYVE(myDataFetcher, myDataValidator, { pool, jwk });
```

###### Running your node

To run your node, simply call the `.run()` function:

```ts
import KYVE from "@kyve/logic";

const pool = "demo-pool";
const jwk = ...

const node = new KYVE(myDataFetcher, myDataValidator, { pool, jwk });

(async () => {
  await node.run();
})();
```

## Querying data

---
_Source: https://npm.io/package/@kyve/logic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
