Onchain Subscriber Example
This example provides usecase of Zap data users utilize data provided by Zap Oracles to trigger function/event in their onchain contracts
Whats on-chain subscriber
On-chain subscriber is a contract that talks to Zap contracts and Zap Oracles to get data and decide what to do with that data. Use cases can be anything from using data received to settle a prediction betting with others; calling out other contracts (voting contracts, survey, random number generator, ...) or doing calculation with data received and emitting events with result. Whatever you want to achieve with on blockchain automation, you can do that being on-chain subscriber.
Work flow
Requirements:
Owner has to have dots bonded to an Endpoint to pay for query
On-chain subscriber contract has to call query to Endpoint
On-chain subscriber contract has to implement
callback
function that will be called by Oracle.
Code
Using template
To make it easier for you to setup contract with custom logic , we created a template that includes most of things you need to get it up and running
Setup environment and Create on-chain subscriber
Clone the repo:
cd subscriber-template
yarn
Edit callback function
Deploy:
On mainnet :
yarn deploy
Or
truffle migrate --network <network name>
Check for successfully contract deployment on chain
Calling on-chain subscriber
Once contract is deployed on chain, you now can call call functions bond
queryProvider
Last updated