Quickstart
Example pseudo code for publishing data associated with a schema (public or private)
Pre-requisites
Steps
1. Define your schema as a string and plug it into the schema encoder
import { SDK, zeroBytes32, SchemaEncoder } from "@somnia-chain/streams"
const gpsSchema = `uint64 timestamp, int32 latitude, int32 longitude, int32 altitude, uint32 accuracy, bytes32 entityId, uint256 nonce`
const schemaEncoder = new SchemaEncoder(gpsSchema)2. Compute your unique schema identifier from the schema
const sdk = new SDK({
public: getPublicClient(),
wallet: getWalletClient(),
})
const schemaId = await sdk.streams.computeSchemaId(gpsSchema)
console.log(`Schema ID ${schemaId}`)3. Encode the data you want to store that is compatible with the schema
4. Publish data (with our without a public schema)
5. Direct data read without reactivity
Last updated