{"id":19107389,"url":"https://github.com/smartcontractkit/chainlink-mix","last_synced_at":"2025-04-12T23:38:54.887Z","repository":{"id":40400445,"uuid":"321226812","full_name":"smartcontractkit/chainlink-mix","owner":"smartcontractkit","description":"Working with smart contracts with eth-brownie, python, and Chainlink. ","archived":false,"fork":false,"pushed_at":"2024-06-11T05:35:12.000Z","size":214,"stargazers_count":511,"open_issues_count":9,"forks_count":195,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-12T23:38:32.664Z","etag":null,"topics":["brownie","chainlink","eth-brownie","ethereum","infura","python","smart-contracts"],"latest_commit_sha":null,"homepage":"https://chain.link/","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartcontractkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-14T03:55:10.000Z","updated_at":"2025-03-27T14:32:24.000Z","dependencies_parsed_at":"2022-07-14T05:20:31.108Z","dependency_job_id":"0ca219f1-f507-46f5-bcf1-ad311a847032","html_url":"https://github.com/smartcontractkit/chainlink-mix","commit_stats":null,"previous_names":[],"tags_count":9,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fchainlink-mix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fchainlink-mix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fchainlink-mix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fchainlink-mix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartcontractkit","download_url":"https://codeload.github.com/smartcontractkit/chainlink-mix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brownie","chainlink","eth-brownie","ethereum","infura","python","smart-contracts"],"created_at":"2024-11-09T04:12:27.276Z","updated_at":"2025-04-12T23:38:54.867Z","avatar_url":"https://github.com/smartcontractkit.png","language":"Solidity","readme":"\u003e ⚠️⚠️⚠️\n\u003e This repo uses the eth-brownie development toolkit which is [no longer maintained by its creators](https://github.com/eth-brownie/brownie?tab=readme-ov-file#brownie).\n\u003e Therefore this repo is not maintained actively either.\n\u003e we recommend you check out the [Chainlink starter kits](https://github.com/smartcontractkit/starter-kits) to find other repos that you can use to\n\u003e get started quickly. We recommend the use of the Hardhat or Foundry starter kits for most use cases.\n\n# chainlink-mix\n\n\u003e NOTE: The new default is Sepolia.\n\u003e NOTE: This has been recently updated for better compatibility with local blockchains. Check out the scripts to learn more.\n\n\u003cbr/\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://chain.link\" target=\"_blank\"\u003e\n\u003cimg src=\"./img/chainlink-brownie.png\" width=\"225\" alt=\"Chainlink Brownie logo\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/smartcontractkit/chainlink-mix.svg)](http://isitmaintained.com/project/smartcontractkit/chainlink-mix \"Average time to resolve an issue\")\n[![Percentage of issues still open](http://isitmaintained.com/badge/open/smartcontractkit/chainlink-mix.svg)](http://isitmaintained.com/project/smartcontractkit/chainlink-mix \"Percentage of issues still open\")\n\nThis 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 beginner walk-through in remix to [learn the basics.](https://docs.chain.link/docs/beginners-tutorial)\n\nYou can also check out the more advanced Chainlink tutorials there as well.\n\n- [chainlink-mix](#chainlink-mix)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Testnet Development](#testnet-development)\n  - [Local Development](#local-development)\n  - [Running Scripts and Deployment](#running-scripts-and-deployment)\n    - [Chainlink Price Feeds](#chainlink-price-feeds)\n    - [Chainlink VRF](#chainlink-vrf)\n    - [Chainlink API Call](#chainlink-api-call)\n    - [Chainlink Automation Deployment](#chainlink-automation-deployment)\n    - [Local Development](#local-development-1)\n  - [Testing](#testing)\n    - [To test development / local](#to-test-development--local)\n    - [To test mainnet-fork](#to-test-mainnet-fork)\n    - [To test a testnet](#to-test-a-testnet)\n  - [Adding additional Chains](#adding-additional-chains)\n  - [Linting](#linting)\n  - [Resources](#resources)\n  - [License](#license)\n\n## Prerequisites\n\nPlease install or have installed the following:\n\n- [nodejs and npm](https://nodejs.org/en/download/)\n- [python](https://www.python.org/downloads/)\n\n## Installation\n\n1. [Install Brownie](https://eth-brownie.readthedocs.io/en/stable/install.html), if you haven't already. Here is a simple way to install brownie.\n\n```bash\npython3 -m pip install --user pipx\npython3 -m pipx ensurepath\n# restart your terminal\npipx install eth-brownie\n```\n\nOr, if that doesn't work, via pip\n\n```bash\npip install eth-brownie\n```\n\n2. Download the mix and install dependencies.\n\n```bash\nbrownie bake chainlink-mix\ncd chainlink-mix\npip install -r requirements.txt\n```\n\nThis will open up a new Chainlink project. Or, you can clone from source:\n\n```bash\ngit clone https://github.com/PatrickAlphaC/chainlink-mix\ncd chainlink-mix\n```\n\n## Testnet Development\n\nIf you want to be able to deploy to testnets, do the following.\n\nSet your `WEB3_INFURA_PROJECT_ID`, and `PRIVATE_KEY` [environment variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html).\n\nYou can get a `WEB3_INFURA_PROJECT_ID` by getting a free trial of [Infura](https://infura.io/). At the moment, it does need to be infura with brownie. If you get lost, you can [follow this guide](https://ethereumico.io/knowledge-base/infura-api-key-guide/) to getting a project key. You can find your `PRIVATE_KEY` from your ethereum wallet like [metamask](https://metamask.io/).\n\nYou'll also need testnet ETH and LINK. You can get LINK and ETH into your wallet by using the [faucets located here](https://faucets.chain.link/). If you're new to this, [watch this video.](https://www.youtube.com/watch?v=P7FX_1PePX0). Look at the `sepolia` section for those specific testnet faucets.\n\nYou can add your environment variables to a `.env` file. You can use the [.env.example](https://github.com/smartcontractkit/chainlink-mix/blob/master/.env.example) as a template, just fill in the values and rename it to '.env'. Then, uncomment the line `# dotenv: .env` in `brownie-config.yaml`\n\nHere is what your `.env` should look like:\n\n```\nexport WEB3_INFURA_PROJECT_ID=\u003cPROJECT_ID\u003e\nexport PRIVATE_KEY=\u003cPRIVATE_KEY\u003e\n```\n\nAND THEN RUN `source .env` TO ACTIVATE THE ENV VARIABLES\n(You'll need to do this every time you open a new terminal, or [learn how to set them easier](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html))\n\n![WARNING](https://via.placeholder.com/15/f03c15/000000?text=+) **WARNING** ![WARNING](https://via.placeholder.com/15/f03c15/000000?text=+)\n\nDO NOT SEND YOUR PRIVATE KEY WITH FUNDS IN IT ONTO GITHUB\n\nOtherwise, you can build, test, and deploy on your local environment.\n\n## Local Development\n\nFor local testing [install ganache-cli](https://www.npmjs.com/package/ganache-cli)\n\n```bash\nnpm install -g ganache-cli\n```\n\nor\n\n```bash\nyarn add global ganache-cli\n```\n\nAll the scripts are designed to work locally or on a testnet. You can add a ganache-cli or ganache UI chain like so:\n\n```\nbrownie networks add Ethereum ganache host=http://localhost:8545 chainid=1337\n```\n\nAnd update the brownie config accordingly. There is a `deploy_mocks` script that will launch and deploy mock Oracles, VRFCoordinators, Link Tokens, and Price Feeds on a Local Blockchain.\n\n## Running Scripts and Deployment\n\nThis 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](https://docs.chain.link/docs/get-the-latest-price).\n\n\u003e NOTE: It's highly encouraged that you work with a local chain before testing on a testnet. You'll be a much faster developer!\n\nIf Sepolia network is not added to brownie by default, run:\n\n```\nbrownie networks add Ethereum sepolia host=https://sepolia.infura.io/v3/$WEB3_INFURA_PROJECT_ID chainid=11155111 explorer=https://sepolia.etherscan.io/\n```\n\n### Chainlink Price Feeds\n\nThis will deploy a smart contract to Sepolia and then read you the latest price via [Chainlink Price Feeds](https://docs.chain.link/docs/get-the-latest-price).\n\n```\nbrownie run scripts/price_feed_scripts/01_deploy_price_consumer_v3.py --network sepolia\nbrownie run scripts/price_feed_scripts/02_read_price_feed.py --network sepolia\n```\n\nOr, you can use [ENS](https://docs.chain.link/docs/ens)\n\n```\nbrownie run scripts/price_feed_scripts/02_read_price_feed_with_ens.py --network sepolia\n```\n\nOtherwise, you can fork mainnet and use that in a local ganache development environment.\n\n```bash\nbrownie console --network mainnet-fork\n\u003e\u003e\u003e price_feeds = PriceFeedConsumer.deploy('0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', {'from': accounts[0]})\n.\n.\n\u003e\u003e\u003e latest_price = price_feeds.getLatestPrice()\n\u003e\u003e\u003e latest_price\n59169208540\n```\n\nYou can also use [ENS](https://docs.chain.link/docs/ens) to get prices. See the [ens price feed script](./scripts/price_feed_scripts/read_price_with_ens.py) for more information.\n\n### Chainlink VRF\n\nThis will deploy a smart contract to Sepolia and get a Random number via [Chainlink VRF](https://docs.chain.link/docs/get-a-random-number).\n\nIf you haven't created and funded a subscription on [vrf.chain.link](https://vrf.chain.link/) you can do so on the UI, or by running:\n\n```\nbrownie run scripts/vrf_scripts/create_subscription.py --network sepolia\n```\n\nBefore running the next scripts. Running `01_deploy_vrf` will also add your consumer contract to the registry.\n\n```\nbrownie run scripts/vrf_scripts/01_deploy_vrf_consumer.py --network sepolia\nbrownie run scripts/vrf_scripts/02_request_randomness.py --network sepolia\nbrownie run scripts/vrf_scripts/03_read_random_number.py --network sepolia\n```\n\n### Chainlink API Call\n\nThis will deploy a smart contract to Sepolia and then make an API call via [Chainlink API Call](https://docs.chain.link/docs/make-a-http-get-request).\n\n```\nbrownie run scripts/chainlink_api_scripts/01_deploy_api_consumer.py --network sepolia\nbrownie run scripts/chainlink_api_scripts/02_request_api.py --network sepolia\nbrownie run scripts/chainlink_api_scripts/03_read_data.py --network sepolia\n```\n\n### Chainlink Automation Deployment\n\nThis is just to show you how to deploy the Automation Compatible contracts, you can learn more about registering \u0026 using them in the [Automate Contracts](https://docs.chain.link/chainlink-automation/compatible-contracts/) section of the Chainlink documentation.\n\n```\nbrownie run scripts/automation_scripts/01_deploy_automation_counter.py --network sepolia\nbrownie run scripts/automation_scripts/02_check_upkeep.py --network sepolia\n```\n\n### Local Development\n\nFor local development, you might want to deploy mocks. You can run the script to deploy mocks. Depending on your setup, it might make sense to _not_ deploy mocks if you're looking to fork a mainnet. It all depends on what you're looking to do though. Right now, the scripts automatically deploy a mock so they can run.\n\n## Testing\n\n```\nbrownie test\n```\n\nFor more information on effective testing with Chainlink, check out [Testing Smart Contracts](https://blog.chain.link/testing-chainlink-smart-contracts/)\n\nTests are really robust here! They work for local development and testnets. There are a few key differences between the testnets and the local networks. We utilize mocks so we can work with fake oracles on our testnets.\n\nThere is a `test_unnecessary` folder, which is a good exercise for learning some of the nitty-gritty of smart contract development. It's overkill, so pytest will skip them intentionally. It also has a `test_samples` folder, which shows an example Chainlink API call transaction receipt.\n\n### To test development / local\n\n```bash\nbrownie test\n```\n\n### To test mainnet-fork\n\nThis will test the same way as local testing, but you will need a connection to a mainnet blockchain (like with the infura environment variable.)\n\n```bash\nbrownie test --network mainnet-fork\n```\n\n### To test a testnet\n\nSepolia is currently supported. Please check the Chainlink docs for which products are supported on which chains.\n\n```bash\nbrownie test --network sepolia\n```\n\n## Adding additional Chains\n\nIf the blockchain is EVM Compatible, adding new chains can be accomplished by something like:\n\n```\nbrownie networks add Ethereum binance-smart-chain host=https://bsc-dataseed1.binance.org chainid=56\n```\n\nor, for a fork:\n\n```\nbrownie networks add development binance-fork cmd=ganache-cli host=http://127.0.0.1 fork=https://bsc-dataseed1.binance.org accounts=10 mnemonic=brownie port=8545\n```\n\n## Linting\n\n```\npip install black\npip install autoflake\nautoflake --in-place --remove-unused-variables --remove-all-unused-imports -r .\nblack .\n```\n\nIf you're using [vscode](https://code.visualstudio.com/) and the [solidity extension](https://github.com/juanfranblanco/vscode-solidity), you can create a folder called `.vscode` at the root folder of this project, and create a file called `settings.json`, and add the following content:\n\n```json\n{\n  \"solidity.remappings\": [\n    \"@chainlink/=[YOUR_HOME_DIR]/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@0.2.2\",\n    \"@openzeppelin/=[YOUR_HOME_DIR]/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.3.2\"\n  ]\n}\n```\n\nThis will quiet the linting errors it gives you.\n\n## Resources\n\nTo get started with Brownie:\n\n- [Chainlink Documentation](https://docs.chain.link/docs)\n- Check out the [Chainlink documentation](https://docs.chain.link/docs) to get started from any level of smart contract engineering.\n- Check out the other [Brownie mixes](https://github.com/brownie-mix/) that can be used as a starting point for your own contracts. They also provide example code to help you get started.\n- [\"Getting Started with Brownie\"](https://medium.com/@iamdefinitelyahuman/getting-started-with-brownie-part-1-9b2181f4cb99) is a good tutorial to help you familiarize yourself with Brownie.\n- For more in-depth information, read the [Brownie documentation](https://eth-brownie.readthedocs.io/en/stable/).\n\nAny questions? Join our [Discord](https://discord.gg/2YHSAey)\n\n## License\n\nThis project is licensed under the [MIT license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fchainlink-mix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartcontractkit%2Fchainlink-mix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fchainlink-mix/lists"}