npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hardhat-chainlink-plugin

v0.1.0

Published

Hardhat TypeScript plugin to run a chainlink node and interact with it

Downloads

3

Readme

Chainlink hardhat plugin

This plugin makes spinning up a local Chainlink node faster and easier, allowing developers to build smart contracts using the Chainlink services.

Getting Started

Prerequisites

  • node > 16.X
  • npm > 7
  • docker

Installation

Step 1:

Install hardhat-chainlink-plugin hardhat plugin.

npm install hardhat-chainlink-plugin

Step 2:

Open Docker Desktop

Step 3:

Run hardhat node

npx hardhat node

Step 4:

Spin up a chainlink node using the following command, which will set-up some env variables. Please do not start it from docker desktop.

npx hardhat chainlink:run-node

IMPORTANT!

Each time this command runs it will remove all containers and re-create them (before running docker compose up we first run docker compose down)

This behavior is analogous to the hardhat EVM node losing all previous history each time it is restarted.

If you want to restart only pass an additional true parameter (restartOnly) like this npx hardhat chainlink:run-node true

If you visit http://127.0.0.1:6688 in your browser, you should see the chainlink node login page displayed.

You can use details: username [email protected] and password password123456789 to login to your local chainlink node.

To see the available tasks to interact with your node run

npx hardhat

Step 5:

Next, for your chainlink node to fulfill request it needs to be funded with ETH. To fund your node first you need to get the node info.

Running the command below does just that.

npx hardhat chainlink:node-info --network localhost

Output will look like this

┌─────────┬──────────────────────────────────────────────┐
│ (index) │                    Values                    │
├─────────┼──────────────────────────────────────────────┤
│ Address │ '0x786729C810294D47E935aE636F66f6cE35E9B99d' │
│ Balance │            '0.000000000000000000'            │
│ ChainID │                   '31337'                    │
└─────────┴──────────────────────────────────────────────┘

Copy the node address and replace it in the command below to fund your wallet.

npx hardhat chainlink:fund-eth 0x244f78C560F6cfcB3baBEe375ae064C6e9259989 20 --network localhost

Now check the node info again, to see the updated balance.

npx hardhat chainlink:node-info --network localhost

Output:

┌─────────┬──────────────────────────────────────────────┐
│ (index) │                    Values                    │
├─────────┼──────────────────────────────────────────────┤
│ Address │ '0x786729C810294D47E935aE636F66f6cE35E9B99d' │
│ Balance │            '20.000000000000000000'            │
│ ChainID │                   '31337'                    │
└─────────┴──────────────────────────────────────────────┘

If you login again to your Node UI from http://127.0.0.1:6688 or simply refresh the page if you are still login. You will see the node updated password on the dashboard.

Step 6:

Deploy Link token on hardhat. Link Token will be used by Consumer contract to pay for Oracle request.

npx hardhat chainlink:deploy-link --network localhost

Output

┌────────────────────┬──────────────────────────────────────────────┐
│      (index)       │                    Values                    │
├────────────────────┼──────────────────────────────────────────────┤
│ Link Token Address │ '0x5FbDB2315678afecb367f032d93F642f64180aa3' │
└────────────────────┴──────────────────────────────────────────────┘

Step 7:

Deploy Oracle contract.

Pass the chainlink node address as the first parameter and Link Token address as the second parameter.

npx hardhat chainlink:deploy-oracle 0xBe576260A47175829f250732421522B7ec204D06 0x5FbDB2315678afecb367f032d93F642f64180aa3 --network localhost

Output

┌────────────────┬──────────────────────────────────────────────┐
│    (index)     │                    Values                    │
├────────────────┼──────────────────────────────────────────────┤
│ Oracle Address │ '0x5FbDB2315678afecb367f032d93F642f64180aa3' │
└────────────────┴──────────────────────────────────────────────┘

Step 8:

Create a chainlink Job.

Pass your node username, password, deployed Oracle address and job type (direct | cron).

npx hardhat chainlink:create-job 0x5FbDB2315678afecb367f032d93F642f64180aa3 direct

Output

┌────────────┬────────────────────────────────────────┐
│  (index)   │                 Values                 │
├────────────┼────────────────────────────────────────┤
│   Status   │               'Success'                │
│   Error    │                  null                  │
│   JobID    │                  '1'                   │
│ ExternalID │ '95cd6192-8dc8-4e1d-903d-3e7b885bc9d5' │
└────────────┴────────────────────────────────────────┘

TROUBLESHOOTING

If you turn off the hardhat node all history will get wiped. In that case you will also need to run the chainlink node again using the chainlink:run-node command.

If the chainlink node becomes out of sync (info not updating) then you can run chainlink:run-node true which will restart the node without destroying the containers.

Take note of the ExternalID of the Job.

Running locally

If you want to test out this commands in this repository you will need to change the initial setup a bit by first running npm install && npm run build and only after that will you be able to run the hardhat node from the root of this repository.