GithubHelp home page GithubHelp logo

prin-r / ckb-band-oracle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duanyytop/ckb-band-oracle

0.0 1.0 0.0 351 KB

An oracle fetching oracle data from BandChain and posting to Nervos CKB

Home Page: https://explorer.nervos.org/aggron/address/ckt1qyqgh64jswu4wcg6u9edff8m456whsetkh6qh2wel7

License: MIT License

JavaScript 99.40% Shell 0.60%

ckb-band-oracle's Introduction

CKB Band Oracle

License Github Actions CI Telegram Group

An oracle fetching oracle data from Band Protocol and posting to Nervos CKB

ckb-oracle-bridge (Live Demo) provides a server to fetch Band Protocol oracle data and a web application to display oracle data and uses rich-node as ckb rpc and indexer server.

How to work

ckb-band-oracle is a node.js server fetching band oracle data and posting data to Nervos CKB per block.

band shows the workflow fetching oracle data of 11 tokens from BandChain.

Note: BandChain oracle data is updated every five minutes

poster shows the workflow posting oracle data to Nervos CKB per block.

ckb-band-oracle has five stages to post band oracle data to Nervos CKB

  • Generate some live cells whose count is equal to oracle tokens' count to carry band oracle data
  • Fetch latest band oracle data from BandChain
  • Generate transaction whose outputs data contain band oracle data and send to Nervos CKB
  • Fetch latest band oracle data from BandChain
  • Update cells data which contain band oracle data with new oracle data per block

Band Oracle Data Format

Now ckb-band-oracle provides 11 tokens' oracle prices which are ['BTC', 'ETH', 'DAI', 'REP', 'ZRX', 'BAT', 'KNC', 'LINK', 'COMP', 'BAND', 'CKB'].

And the cell data format:

utf8ToHex('band') + hex(index of token list) + u32(timestamp) + u64(price)

For example:

0x62616e64055f437c0c00000000000650e7 means the index of token list is 05 (BAT) and the timestamp is 5f437c0c(1598258188) and the price of BAT is $0.413927.

Note: utf8ToHex('band') = 0x62616e64

ckb-band-oracle provides two methods to generate and parse band oracle data in utils

Getting Started

Before starting the project, you should edit the .env file with your private key to sign above transactions later. You should make sure the balance of the account is enough and if you have not enough Testnet CKB, you can claim free Testnet ckb from CKB Faucet.

$ git clone https://github.com/duanyytop/ckb-band-oracle
$ cd ckb-band-oracle
$ yarn install
$ yarn start

Resource

  • Band Protocol - A cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts
  • CKB JavaScript SDK - JavaScript SDK of Nervos CKB which can help developers to interact ckb node
  • CKB Rich Node - Remote server which supports ckb rpc and ckb indexer
  • CKB Indexer - Core Module of CKB Rich Node
  • CKB Explorer - CKB blockchain explorer
  • CKB Faucet - A faucet where you can claim free Testnet CKBytes

ckb-band-oracle's People

Contributors

duanyytop avatar prin-r avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.