Git Product home page Git Product logo

data-feed-consumer's Introduction

Data Feed Consumer

Consumer smart contract that reads from Orakl Network Data Feed.

Warning: This repository and smart contract are meant to be for deployment on Baobab.

Currently, you can access the following data feeds from Orakl Network.

Contract Addresses

Reference following link to check deployed addresses

Feeds

Others

Prerequisites

Create a copy of .env.example file and fill in values for PROVIDER, and MNEMONIC or PRIV_KEY (the difference is explained below) environment variables. These variables will be used for connection to JSON-RPC endpoint, deployment and use of your DataFeedConsumer smart contract.

cp .env.example .env

PROVIDER can be set to any JSON-RPC endpoint. The list of free available JSON-RPC endpoint can be found in official Klaytn documentation.

This repository supports connection to wallet either through mnemonic or private key.

Mnemonic

MNEMONIC can be generated using npm mnemonics package.

npx mnemonics

After mnemonic is generated, you need to convert it to public address and fund it with KLAY. If you do not have any KLAY in your account, you cannot deploy smart contracts or make any transactions.

You can convert your newly generated mnemonic with following hardhat task. Please replace the [MENONIC] with your mnemonic.

npx hardhat address --mnemonic [MNEMONIC]

The script will print out a public address corresponding to your mnemonic. Then, you can use this address to receive free KLAY using Baobab's faucet.

Private key

If you already have a wallet, you can reuse its private key, and connect to JSON-RPC endpoint with it. In case you use Metamask, read how to export an account's private key.. After you extract private key, store it in PRIV_KEY variable inside of .env file.

Installation

yarn install

Compilation

yarn compile

Deploy

# aggregator example
npx hardhat deploy --network baobab --deploy-scripts deploy/DataFeedConsumer
# router example
npx hardhat deploy --network baobab --deploy-scripts deploy/DataFeedRouterConsumer

Request the latest value from Data Feed

Before running the script below, one must deploy DataFeedConsumer smart contract. This step has to be performed only once. To deploy DataFeedConsumer, run npx hardhat deploy --network baobab.

Reading information from feed is free of charge for public data feeds. You pay only for deployment of smart contract and execution of its functions.

npx hardhat run scripts/read-data.ts --network baobab

Request the latest value from Data Feed through RouterContract

Pair name's fixed with "BTC-USDT", try out getting latest value of different pairs by changing pair name from the script.

npx hardhat run scripts/read-data-through-router.ts --network baobab

data-feed-consumer's People

Contributors

martinkersner avatar nick-bisonai avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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