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.
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
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
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
- 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