Quick Start Guide
This guide will help you get started with SuiPulse by walking through a simple example of creating and managing a data stream.
Prerequisites
- Node.js 16 or later
- npm or yarn
- Basic familiarity with Sui blockchain
Installation
Install the SuiPulse SDK:
npm install @suipulse/sdk
Basic Usage
1. Initialize the Client
import { SuiPulse, Network } from "@suipulse/sdk";
import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";
// Create a keypair
const keypair = Ed25519Keypair.fromSecretKey(/* your private key */);
// Initialize SuiPulse
const suiPulse = new SuiPulse(keypair, Network.MAINNET);
2. Create a Data Stream
const result = await suiPulse.createStream({
name: "my-first-stream",
description: "A simple example stream",
metadata: new Uint8Array(Buffer.from("Initial metadata")),
isPublic: true,
});
const streamId = result.streamId;
console.log("Stream created:", streamId);
3. Update Stream Data
await suiPulse.updateStream(streamId, {
data: new Uint8Array(Buffer.from("Updated stream data")),
});
4. Subscribe to Updates
const unsubscribe = await suiPulse.subscribeToEvents(
"StreamUpdated",
(event) => {
if (event.parsedJson.stream_id === streamId) {
console.log("Stream updated:", event);
}
}
);
// Later: stop listening for updates
unsubscribe();
Next Steps
Now that you've created your first stream, you can:
- Learn about Data Streams in detail
- Explore Snapshots for state management
- Set up Access Control for your streams