Skip to main content

Quick Start Guide

The Log Store Network is a platform for data availability, specializing in high-frequency, time-indexed cryptographic attestations, effectively serving as a decentralized, time-series database. Built atop the Streamr Network, it facilitates the collection of real-time signed metrics and attestations from both off-chain and real-world occurrences through a peer-to-peer data transport layer.

This guide will walk you through:

  1. Creating a stream.
  2. Funding your Stores & Queries.
  3. Storing real-time data.
  4. Querying the network.

Installation

CLI Tool & JavaScript Client: Begin by installing our CLI tool and JavaScript client to interact with the Log Store Network. The CLI tool, suitable for command-line interactions, can be installed with:

npm i -g @logsn/cli

For programmatic access, the JavaScript Client/SDK is available via:

npm i @logsn/client

Additionally, our smart contracts are accessible on the Polygon Network, with details available on our GitHub repository.

Configuration

Configure the CLI tool by initializing it with logstore init and editing the ~/.logstore-cli/default.json file. Alternatively, use the --host and --wallet flags for direct configuration.

Creating a Stream

A stream must be created before data storage or querying can occur. This can be achieved through the CLI, Streamr Client, or Streamr UI.

Funding Stores & Queries

The Log Store Network is an Alpha, and therefore uses LSAN tokens for its operations. The AlphaNet explains this in detail. Obtain test tokens via our Discord and/or learn about minting LSAN.

Publishing Data

After obtaining LSAN tokens, you can publish data to your stream. This requires prior staking of LSAN tokens, which can be done using both the CLI tool and the Client.

CLI Example:

logstore store stake ${streamId} ${stakeAmountInWei} --host https://polygon-rpc.com/ --wallet ${privateKey}

Client Example:

import { StreamrClient } from "streamr-client";
import { LogStoreClient } from "@logsn/client";

const privateKey = "privateKey";
const streamId = "0xpublic_key/path/identifier";
const stakeAmount = 10000;

(async (){
// Initialize the LogStore client
const streamrClient = new StreamrClient({
auth: {
privateKey,
},
})
const logStoreClient = new LogStoreClient(streamrClient);

// Get the stream
const stream = await streamrClient.getStream(streamId);

// Stake to the stream
const stakeAmount = 10;
const response = await logStoreClient.stakeOrCreateStore(
stream.id,
stakeAmount
);

// Publish messages to this stream
await streamrClient.publish(
stream.id,
{
hello: 'world',
}
);
})();

Querying Data

Similar to publishing, querying data from a stream requires staking LSAN tokens, with the ability to query any stream post-stake.

CLI Example:

logstore query stake --host https://polygon-rpc.com/ --wallet ${privateKey} ${amountInWei}

Client Example:

import { StreamrClient } from "streamr-client";
import { LogStoreClient } from "@logsn/client";

const streamId = "0xpublic_key/path/identifier";
const stakeAmount = 10000;

(async (){
// Initialize the Log Store client
const streamrClient = new StreamrClient({
auth: {
privateKey,
},
})
const logStoreClient = new LogStoreClient(streamrClient);

// Stake to the stream
const stakeAmount = 10;
const response = await logStoreClient.queryStake(
stakeAmount
);

// Query from the stream
const query = await logStoreClient.query(
streamId,
{
// Should see the recently sent messages, along with 3 identical ones from storage
last: 6,
},
(message) => {
// Do something with the messages as they are received
console.log(JSON.stringify(message));
}
);
})();

Schema Validation

The Log Store also supports a schema validation feature. This enables automatic validation of streaming data against defined schemas, ensuring that only data conforming to these schemas is stored.

For a comprehensive understanding of this feature, including how to use it on your stream, please refer to the detailed section in our SDK documentation on Schema Validation.

Quick Start Examples

  • Examples repository: Explore how to integrate the Log Store using basic demonstration examples.
  • Multi-Chain Gas Station: Discover our real-time gas fee tracker data lake for multiple blockchains. This technology is seamlessly integrated and available for diverse applications.