{"id":19107352,"url":"https://github.com/smartcontractkit/hardhat-chainlink","last_synced_at":"2025-04-13T01:11:43.085Z","repository":{"id":65389578,"uuid":"575562636","full_name":"smartcontractkit/hardhat-chainlink","owner":"smartcontractkit","description":"Integrates Chainlink into Hardhat projects. This package is currently in the BETA testing phase and is not recommended for production usage yet.","archived":false,"fork":false,"pushed_at":"2024-09-10T07:01:30.000Z","size":545,"stargazers_count":64,"open_issues_count":6,"forks_count":33,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-03-21T03:45:28.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@chainlink/hardhat-chainlink","language":"TypeScript","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":"2022-12-07T19:47:00.000Z","updated_at":"2024-12-20T14:39:50.000Z","dependencies_parsed_at":"2024-01-16T22:27:18.256Z","dependency_job_id":"e0806cf1-adb2-409e-9638-1e1dcfb463a1","html_url":"https://github.com/smartcontractkit/hardhat-chainlink","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fhardhat-chainlink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fhardhat-chainlink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fhardhat-chainlink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fhardhat-chainlink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartcontractkit","download_url":"https://codeload.github.com/smartcontractkit/hardhat-chainlink/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650753,"owners_count":21139681,"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":[],"created_at":"2024-11-09T04:12:15.941Z","updated_at":"2025-04-13T01:11:43.051Z","avatar_url":"https://github.com/smartcontractkit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hardhat Chainlink Plugin\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://chain.link\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/smartcontractkit/hardhat-starter-kit/main/box-img-lg.png\" width=\"225\" alt=\"Chainlink Hardhat logo\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\nThe Hardhat Chainlink plugin allows users to seamlessly interact with Chainlink services in their Hardhat-based projects.\nIt provides atomic methods to interact with smart contracts related to the following Chainlink services: Data Feeds, VRF, Automation and Functions.\nThis plugin offers a convenient way to integrate Chainlink functionality into your web3 development workflow.\n\n\u003e **Warning**\n\u003e\n\u003e **This package is currently in the BETA testing phase and is not recommended for production usage yet.**\n\u003e\n\u003e **Open issues to submit bugs.**\n\n## Installation\n\u003e **Note**  \nIf you are starting a new Hardhat project, we recommend following the [Hardhat Getting Started](https://hardhat.org/hardhat-runner/docs/getting-started#overview) documentation first.\n\nYou can install the Hardhat Chainlink plugin using either npm or yarn.\nChoose the package manager that you prefer and run one of the following commands:\n\nUsing npm:\n```console\nnpm install @chainlink/hardhat-chainlink\n```\n\nUsing yarn:\n\n```console\nyarn add @chainlink/hardhat-chainlink\n```\n\nAfter installation, add the plugin to your Hardhat config:\n\n`hardhat.config.js`:\n```js\nrequire(\"@chainlink/hardhat-chainlink\");\n```\n\n`hardhat.config.ts`:\n```ts\nimport \"@chainlink/hardhat-chainlink\";\n```\n\n## Usage\n\nThe Hardhat Chainlink plugin offers multiple ways to interact with Chainlink services,\ngiving you the flexibility to choose the approach that suits your workflow best.\n\nBelow is a mapping of the names of supported Chainlink services:\n- `dataFeed`: Data Feeds\n- `dataFeedProxy`: Data Feed Proxies\n- `feedRegistry`: Feed Registries\n- `l2Sequencer`: L2 Sequencers\n- `ens`: ENS (Ethereum Name Service)\n- `automationRegistry`: Automation Registries\n- `automationRegistrar`: Automation Registrars\n- `vrf`: VRF (Verifiable Random Functions)\n- `functions`: Functions service\n\nThe number of confirmations to wait for transactions to Chainlink services can be set using\nthe corresponding parameter in the `chainlink` parameters group of `hardhat.config.ts`:\n```ts\nmodule.exports = {\n  ...,\n  chainlink: {\n    confirmations // Number of confirmations to wait for transactions (default: 1)\n  },\n  ...\n}\n```\n\n### 1. CLI\n\nInteract with the Hardhat Chainlink plugin through the command line interface (CLI) using the following format:\n```\nnpx hardhat chainlink:{service} [method] [--args]\n```\nThis approach serves both as a CLI method and Hardhat tasks.\nHowever, it's important to note that the methods in each service are \"hidden\" with subtasks and won't be shown when you call `npx hardhat`.\nInstead, you can call the methods by passing its name as a parameter for the related task.\n\nIf the subtask and/or args are not passed directly, they will be interactively inquired during the CLI command execution.\n\n\u003e **Note**  \nArguments for methods called with CLI should be provided as a valid JSON string.\n\nTo get a list of all available methods (subtasks) and their arguments for a specific service, you can use:\n```\nnpx hardhat chainlink:{task}:subtasks\n```\n\nExample of calling a subtask with arguments directly in the CLI:\n```shell\nnpx hardhat chainlink:dataFeed getLatestRoundAnswer --args '{\"dataFeedAddress\": \"0xE62B71cf983019BFf55bC83B48601ce8419650CC\"}'\n```\n\nExample of interacting with the CLI interactively, where the subtask and arguments are inquired:\n```shell\nnpx hardhat chainlink:dataFeed\n# The CLI will ask you to select a subtask (getLatestRoundAnswer) and provide arguments interactively.\n```\n\n### 2. Hardhat Tasks\n\nIntegrate the Hardhat Chainlink plugin as a subtask in your own Hardhat tasks. Use the following format to run a subtask:\n```\nhre.run(\"chainlink:{service}:{method}\", { ...args });\n```\n\nThis method is well-suited for more complex workflows and automation.\nYou can call the {service} and {method} directly in your custom Hardhat tasks, passing the required arguments as an object containing the necessary parameters.\n\nExample of calling a subtask in a custom Hardhat task with arguments:\n```js\ntask(\"myTask\", \"My custom task\", async (taskArgs, hre) =\u003e {\n  await hre.run(\"chainlink:dataFeed:getLatestRoundAnswer\", {\n    dataFeedAddress: \"0xE62B71cf983019BFf55bC83B48601ce8419650CC\",\n  });\n});\n```\n\n### 3. Methods in Hardhat Environment\n\nDirectly access Chainlink services as methods in the Hardhat Environment using the following format:\n```\nhre.chainlink.{service}.{method}(...args);\n```\nThis approach is ideal for seamless integration with your existing Hardhat project.\nYou can use familiar JavaScript syntax to call the Chainlink services as methods within your scripts and tasks.\n\nExample of calling a subtask as a method in the Hardhat Environment:\n```js\nasync function myFunction() {\n  const dataFeedAddress = \"0xE62B71cf983019BFf55bC83B48601ce8419650CC\";\n  const result = await hre.chainlink.dataFeed.getLatestRoundAnswer(dataFeedAddress);\n  console.log(result);\n}\n```\n---\nChoose the method that fits your project's requirements and coding style.\nAll three approaches provide the same set of functionalities, allowing you to interact with Chainlink services efficiently and effectively.\nFor a more in-depth understanding of available services and methods, please explore their [tests](test).\n\n## Registries\nThe Hardhat Chainlink plugin provides registries that contain information about smart contracts related\nto various Chainlink services and other data, such as the [denominations library](https://docs.chain.link/data-feeds/feed-registry#denominations-library),\nwhich is useful for interacting with the Feed Registry.\n\nIn general, these registries help you access essential contract addresses deployed on different networks,\nmaking it easier to integrate Chainlink services into your projects.\n\nBelow is a list of the objects containing address data for service configurations for the Chainlink services\nprovided by the Hardhat Chainlink plugin:\n- `dataFeeds`: Addresses of Data Feeds-related contracts: Aggregators and Proxies, and their parameters.\n- `feedRegistries`: Feed Registries' contract addresses.\n- `l2Sequencers`: L2 Sequencer Uptime Feeds' contract addresses.\n- `keeperRegistries`: Addresses of Automation-related contracts: Keeper Registry and Keeper Registrar.\n- `linkTokens`: Link Tokens' contract addresses.\n- `vrfCoordinators`: Addresses of VRF Coordinators and their parameters.\n- `functionsRouters`: Addresses of Functions Routers and their parameters.\n- `denominations`: Records from Denominations library to interact with Feed Registries contracts.\n\nYou can access them using one of the following methods:\n\n### 1. CLI\n\nAccess the registries through the CLI using the following command:\n```\nnpx hardhat chainlink:registries [method]\n```\n\nThis command allows you to query records available in the registries.\nThe CLI will inquire about the necessary additional information, such as the preferable network, to retrieve the required record from the registry.\n\nTo get a list of all available getter-method for a specific registry, you can use:\n```\nnpx hardhat chainlink:registries:subtasks\n```\n\nThe CLI will also inquire about the registry getter-method interactively if not provided directly.\n\nExample of getting a record from registry directly in the CLI:\n```shell\nnpx hardhat chainlink:registries getDataFeed\n# The CLI will ask you to select a preferred network and subsequent parameters.\n```\n\n### 2. Methods in Hardhat Environment\n\nAccess the registries as methods directly in the Hardhat Environment:\n```\nconst registry = hre.chainlink.registries.{registryName};\n```\n\nReplace the `{registryName}` placeholder with the name of the registry (e.g., dataFeeds, feedRegistries, keeperRegistries).\n\nExample of getting data from registry in the Hardhat Environment:\n```js\nasync function myFunction() {\n  const dataFeedAddress = hre.chainlink.registries.dataFeeds.ethereum.ETH.USD.contractAddress;\n  console.log(dataFeedAddress);\n  // 0xE62B71cf983019BFf55bC83B48601ce8419650CC\n}\n```\n---\nFor a more in-depth understanding of the structure of these records, please explore their [interfaces](src%2Fregistries%2Finterfaces).\n\n## Sandbox\n\nThe `sandbox` module of Hardhat Chainlink plugin provides the ability to test dApps against Chainlink services locally and run simulations.\n\n### Functions request simulation\n\nThis plugin enables you to run local Functions request simulations.\nA simulation is an execution of your custom JavaScript code in a locally spun up Deno sandbox environment.\nIt is useful for debugging and for checking whether the source code you supply to Chainlink Functions can reasonably be expected to work when passed on-chain.\n\n\u003e **Note**  \nInstall [Deno](https://deno.com/) and add it to PATH, run ```deno --version``` to verify installation. Instructions: [https://deno.com/#installation](https://deno.com/#installation).\n\nFunctions' requests simulations could be performed following the [sandbox documentation](SANDBOX.md#service-alias-functionssimulation).\n\n### Local testing\n\u003e **Note**  \n\u003e Install and run Docker Daemon, and Docker Desktop for convenience. Instructions: [docs.docker.com/get-docker](https://docs.docker.com/get-docker/).\n\nThis plugin enables you to spin up a local Chainlink node, set up Chainlink services, and then conduct local tests.\n\n#### Configure local Chainlink node\n\nBefore you start a Chainlink node, it's important to configure it.\nTo achieve this, additional parameters have been included in the `chainlink` group of `hardhat.config.ts`:\n```ts\nmodule.exports = {\n  chainlink: {\n    node: {\n      chain_id, // Chain ID (default: \"1337\")\n      chain_name, // Chain name (default: \"local\")\n      http_url, // JSON RPC HTTP endpoint (default: \"http://host.docker.internal:8545\")\n      ws_url, // JSON RPC WebSocket endpoint (default: \"ws://host.docker.internal:8545\")\n      cl_keystore_password, // Password to encode Chainlink keys in database (default: \"password1234567890\")\n      cl_api_user, // Email of Chainlink API user/admin (default: \"user@chain.link\")\n      cl_api_password, // Password of Chainlink API user/admin (default: \"password1234567890\")\n      pg_user, // Postgres DB user name (default: \"chainlink\")\n      pg_password, // Postgres DB user password (default: \"password1234567890\")\n      pg_db, // Postgres DB name (default: \"chainlink\")\n    }\n  },\n  ...\n}\n```\n\u003e **Note**\n\u003e Passwords must contain both letters and numbers and be at least 16 characters long.\n\n### Manage local Chainlink node\n\nOnce local Chainlink node parameters are specified, Chainlink node could be started/restarted/stopped and managed with the plugin following the [sandbox documentation](SANDBOX.md#service-alias-node).\nIn order to login use credentials provided with `cl_api_user` and `cl_api_password`.\n\nAlternatively, you can manage a Chainlink node either with Chainlink CLI or Chainlink node GUI.\n\n#### Chainlink CLI\n\nChainlink node CLI is available directly on a machine running Chainlink node, so first you have to connect with `bash` to a Docker container to be able to run commands.\n\nHere are some of the things you can do with the CLI:\n* Create/Delete Chainlink Jobs\n* Manage Chainlink accounts' transactions\n* Manage Chainlink External Initiators\n* See/Create Chainlink node's keys: ETH, OCR, P2P\n* and more...\n\nHere is example command to get list of ETH keys that are used by a Chainlink node:\n```bash\nchainlink keys eth list \n```\nThe most useful commands to manage Chainlink node with CLI you can find here: https://docs.chain.link/chainlink-nodes/resources/miscellaneous.\n\n#### Chainlink GUI\n\nChainlink node GUI is by default available on the port `6688`, this port is exposed with a docker-compose file to a host machine.\n\nHere are some of the things you can do with the GUI:\n* Create/Delete Chainlink Jobs\n* Create Chainlink Bridge\n* See Chainlink Jobs runs\n* See Chainlink node's keys: ETH, OCR, P2P, VRF\n* See Chainlink node's current configuration\n* and more...\n\n## Documentation\n\nFor detailed usage instructions and more information, refer to:\n* [DOCUMENTATION.md](DOCUMENTATION.md) for interaction with Chainlink services;\n* [SANDBOX.md](SANDBOX.md) for local testing in Sandbox.\n\n## Contribution\n\nWe welcome contributions from the community.\n\nIf you find any issues, have suggestions for improvements, or want to add new features to the plugin,\nplease don't hesitate to open an issue or submit a pull request.\n\nYour contributions help us improve the Hardhat Chainlink plugin and provide better tools for the entire community.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fhardhat-chainlink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartcontractkit%2Fhardhat-chainlink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fhardhat-chainlink/lists"}