Javascript implementation of a standalone zkitter node
zkitter-js is an npm module and a CLI tool designed to make building on Zkitter easier.
To initialize Zkitter and sync with the network:
import {Zkitter} from"zkitter-js";constzkitter=awaitZkitter.initialize({ arbitrumHttpProvider:'https://...',});// Sync with arbitrum registrarawaitzkitter.syncUsers();// Sync with zk groups on zkitterawaitzkitter.syncGroup();// Get all historical messages (30 days) from Waku storeawaitzkitter.queryAll();// Subscribe to all future messages from everyoneawaitzkitter.subscribe();
To implement custom database instead of using default LevelDB:
import { Zkitter, GenericDBAdapterInterface, Post, Proof } from'zkitter-js';import postgres from'postgres';constsql=postgres({ /* options */ });classPostgresDBimplementsGenericDBAdapterInterface {asyncinsertPost(post:Post, proof:Proof) {constexisting=awaitsql` select * from posts where hash = ${post.hash()} `if (!existing) {awaitsql` insert into posts (...) values (...) ` } }}constzkitter=awaitZkitter.initialize({ db:newPostgresDB(), arbitrumHttpProvider:'https://...',});