A protocol for verified data streams.
yarn add @kyve/core
import KYVE from "@kyve/core";
const node = new KYVE();
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 later on.
To pass data into KYVE, simply call uploader.next()
:
const myDataUploader = async (uploader: UploadFunctionSubscriber, config: any) => {
// use your custom logic here
const data = ...
uploader.next({ data });
}
You can also optionally add custom tags to your transactions:
const myDataUploader = async (uploader: UploadFunctionSubscriber, config: any) => {
// use your custom logic here
const data = ...
const tags = [...]
uploader.next({ data, tags });
}
The config value can be set in the DAO for the pool You can find the list of pools here
The listener will automatically return new and unvalidated transactions from the uploader, which you can pass into your logic.
const myDataValidator = async (listener: ListenFunctionObservable,
validator: ValidateFunctionSubscriber,
config: any) => {
listener.subscribe(async (ret: ListenFunctionReturn) => {
// validate the data with your custom logic
const isValid = ...
// pass the result into KYVE
validator.next({ valid: isValid, id: ret.id });
});
}
import KYVE from "@kyve/logic";
const node = new KYVE(myDataFetcher, myDataValidator);
Next you need to set up the pool in the DAO. You can create a new pool here. After you have created the pool, insert its ID, the amount of $KYVE you want to stake for this pool and your arweave keyfile into the node config:
import KYVE from "@kyve/core";
const pool = 1;
const stake = 100
const jwk = ...
const node = new KYVE(myDataFetcher, myDataValidator, { pool, stake, jwk });
To run your node, simply call the .run()
function:
(async () => {
await node.run();
})();