Subscription-Oracle Template
Help data provider creating subscription Oracle's Endpoint
Introduction
Subscription oracle template serves as bootstrap tool for data provider to setup and run their service in minutes.
Purpose : to provide a subscription service based on Zap oracle platform to manage subscriptions and distribute information through authenticated websocket connections.
Work flow
This workflow has been provided in the template , following information explains how things works within source code
ORACLE
Oracle is registered and created an endpoint with curve set for a subscription service (not to be queried)
Node/Yarn installed
Modify Config.ts with your custom information such as Mnemonic and optional custom URL for parity node ( default to infura)
Method
getDataneeds to be implemented to get data from database or other source and emit data to authenticated connections,
Oracle creates authenticated websocket server
Oracle run
yarn serverwhich will start listening to connections, verify user and emitting data to connected users
USER
This template also includes bootstrap for user to use their Ethereum address to authenticate and connect to receive data from this type of subscription Oracle's endpoint.
User approve -> bond -> subscribe to Oracle's endpoint
User connect to server websocket with params:
{
signature: {{sign endpoint's name with user's address}},
endpoint: {{endpoint name}},
address: {{user's address}}
}
After successful authenticated, user will be able to connect with websocket until the block remaining subscriptions is 0
User listen to channel
signalDatafrom Oracle and receive data
Setup
yarnCreate
priv_config.tsbased onconfig.tstemplate with oracle's informationIn
src/server.tsmodify methodgetDatato get custom data of your own. This data will be broadcasted to users
Run Server:
yarn server
User Connecting to server:
In
src/user.tsmodify signature, address and endpointyarn user
Last updated
Was this helpful?