ZapProject
  • INTRODUCTION TO ZAP ORACLES
  • ZAP CONTRACTS
  • TOKEN DOTS FACTORY
  • TOOLS
    • ZapJS Packages
    • Zap-term
    • Zap Admin
  • FOR USERS
    • Bond/Unbond to Oracles
    • Getting data from Oracles
    • Subscriptions
    • Bond/Unbond to Token Dots
    • Templates
      • Onchain Subscriber Example
      • Offchain Subscriber Example
  • FOR DEVELOPERS
    • Creating Oracle
      • Oracle Template
      • Subscription-Oracle Template
      • Onchain Oracle Template
    • Bonding Curve
      • Curve Encoding
    • Token Providers
      • Token Dot Providers
      • Example Contest
Powered by GitBook
On this page
  • Introduction
  • Work flow
  • Setup
  • Source Code

Was this helpful?

  1. FOR DEVELOPERS
  2. Creating Oracle

Subscription-Oracle Template

Help data provider creating subscription Oracle's Endpoint

PreviousOracle TemplateNextOnchain Oracle Template

Last updated 5 years ago

Was this helpful?

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 with your custom information such as Mnemonic and optional custom URL for parity node ( default to infura)

  • Method needs 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 server which will start listening to connections, verify user and emitting data to connected users

Dont have Oracle and Endpoint registered ? You can easily do so in couple provided tools:

Integrate into your application :

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 signalData from Oracle and receive data

Use our tools to easily approve, bond, subscribe to Oracles Endpoint

UI /Terminal

Integrate into your application :

Setup

  • yarn

  • Create priv_config.ts based on config.ts template with oracle's information

  • In src/server.ts modify method getData to get custom data of your own. This data will be broadcasted to users

Run Server:

  • yarn server

User Connecting to server:

  • In src/user.ts modify signature, address and endpoint

  • yarn user

Config.ts
getData
Zap Admin
Zap-term
@zapjs/provider
Zap Admin
Zap-term
@zapjs/subscriber
Source Code