Adding Events to River Stream
Adding events to a River Stream
Events can be added to a River Stream Node over rpc using the service interface exposed by the protocol in protocol.proto
. The following guide will illustrate a concrete example of making an addEvent
request.
Requirements
- protobuf@3
- bufbuild/buf/buf
Dependencies
To run the below recipe, you’ll want to create a Typescript project with a package.json
file with the below dependencies. The river dependencies require building harmony-web
(see README.md
)
- ethers
- @river/waterproof
- @river/sdk
UserStream
.Adding an event to UserStream
Users that have initialized their UserStream can add events to those streams. Adding other message
events to a different stream follows from this guide given all events are added using the addEvent
RPC method implemented by the node’s StreamService
.
Create a typescript file and follow the below steps to add an event. You will need to set RIVER_STREAM_SERVER_URL
as well, which you can set to the test node at https://node1-test.towns.com
.
Import package dependencies
Create a new random delegate wallet and signer context
Create client instance of river StreamService
Initialize UserStream with wallet
In the above function, createUserStream
adds an inception event to the user stream associated with the user’s streamId, which is derived from the user’s userId.
Helper script to run all above functions to addEvent to new UserStream
Was this page helpful?