Quick Start Guide
This guide will walk you through:
- Creating a stream.
- Funding your Stores & Queries.
- Storing real-time data.
- 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.
-
CLI Example:
logstore create-stream ${streamId} --host https://polygon-rpc.com/ --wallet ${privateKey}
-
Streamr UI Demo:
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.
LSAN is currently used primarily for access management. You can mitigate the use of LSAN tokens by engaging the network directly through the Streamr SDK.
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.
- Watch on YouTube: View our detailed video guide on its usage.
- Streamr Hub Project: Dive deeper into the project's specifics and explore its functionalities on Streamr Hub.
- Source Code: Review the project's source code on GitHub.
- CodeSandbox Demo: Interactive usage demo on CodeSandbox.