Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

PatrickAlphaC/chainlink-mix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chainlink-mix

This is a repo to work with and use Chainlink smart contracts in a python environment. If you're brand new to Chainlink, check out the beginer walkthroughs in remix to learn the basics.

You can also check out the more advanced Chainlink tutorials there as well.

Installation

  1. Install Brownie, if you haven't already. Here is a simple way to install brownie.
pip install eth-brownie
  1. Download the mix. #TODO

Until the mix is uploaded, you can just do the following:

git clone https://github.com/PatrickAlphaC/chainlink-mix
cd chainlink-mix 

Once it becomes a mix, it will look like:

brownie bake chainlink-mix
cd chainlink-mix
  1. Set your WEB3_INFURA_PROJECT_ID. You can get this by getting a free trial of Infura. At the moment, it does need to be infura.

Chainlink Price Feeds

This mix provides a simple template for working with Chainlink Smart Contracts. The easiest way to start is to fork the mainnet chain to a local ganache chain. This will allow you to deploy local smart contracts to interact with the Chainlink Price Feeds.

Running Scripts

This will deploy a smart contract to kovan and then read you the latest price via Chainlink Price Feeds.

brownie run scripts/price_feed_scripts/deploy_price_consumer_v3.py --network kovan
brownie run scripts/price_feed_scripts/read_price_feed.py --network kovan

Otherwise, you can fork mainnet and use that in a local ganache development environment.

brownie console --network mainnet-fork
>>> price_feeds = PriceFeed.deploy('0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', {'from': accounts[0]})
.
.
>>> latest_price = price_feeds.getLatestPrice()
>>> latest_price
59169208540

Chainlink VRF

This will deploy a smart contract to kovan and get a Random number via Chainlink VRF.

brownie run scripts/price_feed_scripts/deploy_vrf.py --network kovan
brownie run scripts/price_feed_scripts/fund_vrf.py --network kovan
brownie run scripts/price_feed_scripts/request_randomness.py --network kovan
brownie run scripts/price_feed_scripts/read_random_number.py --network kovan

Chainlink API Call

This will deploy a smart contract to kovan and then make an API call via Chainlink API Call.

brownie run scripts/price_feed_scripts/deploy_api_consumer.py --network kovan
brownie run scripts/price_feed_scripts/fund_chainlink_api.py --network kovan
brownie run scripts/price_feed_scripts/request_api.py --network kovan
brownie run scripts/price_feed_scripts/read_api.py --network kovan

Testing

To run basic tests from mainnet-fork network

brownie test

There are 3 types of tests you can run:

  1. Development tests
    1. These test using a local ganache chain. They are unit tests and do not interact with Chainlink nodes.
    2. Right now this is blank
  2. Mainnet-fork tests
    1. These run on a mainnet forked local ganache chain. They are used to interact with pricefeed contracts deployed to mainnet.
  3. Testnet/Staging tests
    1. These are the pre-production tests. They are used to test a specific testnet.
    2. Right now we have them hard coded to kovan.

To test development (Currently blank)

brownie test --network development

To test mainnet-fork

This will test Chainlink API Calls and Chainlink VRF

brownie test --network mainnet-fork

To test staging/testnet

This will test Chainlink Price Feeds

brownie test --network kovan

Resources

To get started with Brownie:

Any questions? Join our Discord

License

This project is licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published