This document provides detailed information about each Chainlink service module and its related methods available in the Hardhat Chainlink plugin.
To use these methods please ensure that your Hardhat environment is configured according to the README.
- Hardhat Chainlink Plugin Documentation
- Data Feeds Services
- Service alias:
dataFeed
- Service alias:
dataFeedProxy
- Service alias:
feedRegistry
- Get Latest Round Data
- Get Round Data
- Get Latest Round Data of Proposed Feed
- Get Round Data of Proposed Feed
- Get Round Feed
- Get Feed
- Get Proposed Feed
- Is Feed Enabled
- Get Previous Round ID
- Get Next Round ID
- Get Decimals
- Get Description
- Get Version
- Get Phase
- Get Phase Feed
- Get Phase Range
- Get Current Phase ID
- Service alias:
l2Sequencer
- Service alias:
ens
- Service alias:
- VRF Service
- Service alias:
vrf
- Create Subscription
- Fund Subscription
- Cancel Subscription
- Add Consumer
- Remove Consumer
- Get Subscription Details
- Request Random Words
- Check Pending Request
- Request Subscription Owner Transfer
- Accept Subscription Owner Transfer
- Get Maximum Consumers
- Get Maximum Number of Words
- Get Maximum Request Confirmations
- Get Minimum Request Confirmations
- Get Maximum Request Gas Limit
- Get Commitment
- Get Configuration
- Get Type and Version
- Service alias:
- Automation Services
- Functions Service
- Service alias:
functions
- Create subscription
- Fund subscription
- Cancel subscription
- Get subscription details
- Request subscription owner transfer
- Accept subscription owner transfer
- Add subscription consumer
- Remove subscription consumer
- Timeout requests
- Estimate the cost of a request
- Initialize SubscriptionManager class
- Initialize ResponseListener class
- Initialize SecretsManager class
- Listen for a response for single Functions request
- Listen for a response for single Functions request (from transaction)
- Listen for responses
- Stop response listener
- Fetch DON public keys
- Encrypt Off-Chain secrets URLs
- Verify Off-Chain secrets URLs
- Encrypt secrets
- Upload encrypted secrets to DON
- List DON hosted encrypted secrets
- Build DON hosted encrypted secrets reference
- Fetch Request Commitments
- Service alias:
- Utilities
- Data Feeds Services
Chainlink Data Feeds are decentralized oracles that provide reliable off-chain data to smart contracts on the blockchain. Using this service, developers can access the latest round answer and other relevant information from the Data Feeds, enabling them to fetch real-world data in their web3 projects.
Service alias: dataFeed
const dataFeed = hre.chainlink.dataFeed;
This section provides methods and functionalities designed to interact with the OffchainAggregator smart contract, which serves as the core component of Chainlink Data Feeds.
- Method: getLatestRoundAnswer
- Description: Get the latest round answer for a Data Feed
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data Feed
- Returns:
(roundAnswer: BigNumber)
roundAnswer
: Latest round answer for a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundAnswer = await dataFeed.getLatestRoundAnswer(dataFeedAddress);
- Method: getRoundAnswer
- Description: Get the round answer for a Data Feed
- Arguments:
(dataFeedAddress: string, roundId: BigNumberish)
dataFeedAddress
: Address of Data FeedroundId
: Round ID of Data Feed
- Returns:
(roundAnswer: BigNumber)
roundAnswer
: Round answer for a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = 1; const roundAnswer = await dataFeed.getRoundAnswer(dataFeedAddress, roundId);
- Method: getLatestRoundData
- Description: Get the latest round data for a Data Feed
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data Feed
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundData = await dataFeed.getLatestRoundData(dataFeedAddress);
- Method: getRoundData
- Description: Get the round data for a Data Feed
- Arguments:
(dataFeedAddress: string, roundId: BigNumberish)
dataFeedAddress
: Address of Data FeedroundId
: Round ID of Data Feed
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = 1; const roundData = await dataFeed.getRoundData(dataFeedAddress, roundId);
- Method: getLatestRoundId
- Description: Get the latest round ID
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data FeedroundId
: Round ID of Data Feed
- Returns:
(roundId: BigNumber)
roundId
: Latest round ID of a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = await dataFeed.getLatestRoundId(dataFeedAddress);
- Method: getDecimals
- Description: Get the decimals for a Data Feed
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data Feed
- Returns:
(decimals: number)
decimals
: Decimals for a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const decimals = await dataFeed.getDecimals(dataFeedAddress);
- Method: getDescription
- Description: Get the description for a Data Feed
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data Feed
- Returns:
(description: string)
description
: Description for a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const description = await dataFeed.getDescription(dataFeedAddress);
- Method: getAggregatorVersion
- Description: Get the version for a Data Feed
- Arguments:
(dataFeedAddress: string)
dataFeedAddress
: Address of Data Feed
- Returns:
(version: BigNumber)
version
: Version for a Data Feed
- Usage:
const dataFeedAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const version = await dataFeed.getVersion(dataFeedAddress);
Service alias: dataFeedProxy
const dataFeedProxy = hre.chainlink.dataFeedProxy;
This section provides methods and functionalities designed to interact with the EACAggregatorProxy smart contract, which acts as a proxy for Chainlink Data Feeds.
- Method: getLatestRoundAnswer
- Description: Get the latest round answer for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(roundAnswer: BigNumber)
roundAnswer
: Latest round answer for a current Data Feed via proxy
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundAnswer = await dataFeedProxy.getLatestRoundAnswer(dataFeedProxyAddress);
- Method: getRoundAnswer
- Description: Get round answer for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string, roundId: BigNumberish)
dataFeedProxyAddress
: Address of Data Feed ProxyroundId
: Round ID of Data Feed Proxy
- Returns:
(roundAnswer: BigNumber)
roundAnswer
: Round answer for a current Data Feed via proxy
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = 1; const roundAnswer = await dataFeedProxy.getRoundAnswer(dataFeedProxyAddress, roundId);
- Method: getLatestRoundData
- Description: Get the latest round data for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feed Proxyanswer
: Round answer for current Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundData = await dataFeedProxy.getLatestRoundData(dataFeedProxyAddress);
- Method: getRoundData
- Description: Get round data for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string, roundId: BigNumberish)
dataFeedProxyAddress
: Address of Data FeedroundId
: Round ID of Data Feed Proxy
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feed Proxyanswer
: Round answer for current Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = 1; const roundData = await dataFeedProxy.getRoundData(dataFeedProxyAddress, roundId);
- Method: getLatestRoundId
- Description: Get the latest round ID of a proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(roundId: BigNumber)
roundId
: Latest round ID of a Data Feed Proxy
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const roundId = await dataFeedProxy.getLatestRoundId(dataFeedProxyAddress);
- Method: getDecimals
- Description: Get decimals for current Data Feed
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(decimals: number)
decimals
: Decimals for a Data Feed
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const decimals = await dataFeedProxy.getDecimals(dataFeedProxyAddress);
- Method: getDescription
- Description: Get description for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(description: string)
description
: Description for a Data Feed
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const description = await dataFeedProxy.getDescription(dataFeedProxyAddress);
- Method: getVersion
- Description: Get version for a current Data Feed via proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(version: BigNumber)
version
: Version for a Data Feed
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const version = await dataFeedProxy.getVersion(dataFeedProxyAddress);
- Method: getAggregator
- Description: Get current Data Feed address via proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of current Data Feed Offchain Aggregator
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const aggregatorAddress = await dataFeedProxy.getAggregator(dataFeedProxyAddress);
- Method: getPhaseId
- Description: Get current phase ID of a proxy
- Arguments:
(dataFeedProxyAddress: string)
dataFeedProxyAddress
: Address of Data Feed Proxy
- Returns:
(phaseId: BigNumber)
phaseId
: Current phase ID of a Data Feed proxy
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const phaseId = await dataFeedProxy.getPhaseId(dataFeedProxyAddress);
- Method: getPhaseAggregators
- Description: Get Data Feed address related to a phase ID of a proxy
- Arguments:
(dataFeedProxyAddress: string, phaseId: BigNumberish)
dataFeedProxyAddress
: Address of Data Feed ProxyphaseId
: Phase ID of Data Feed Proxy
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator related to a phase ID of a proxy
- Usage:
const dataFeedProxyAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const phaseId = 1; const aggregatorAddress = await dataFeedProxy.getPhaseAggregators(dataFeedProxyAddress, phaseId);
Service alias: feedRegistry
const feedRegistry = hre.chainlink.feedRegistry;
This section provides methods and functionalities designed to interact with the Feed Registry smart contracts, which acts is an on-chain mapping of assets to Data Feeds.
Note Chainlink Feed Registry is exclusively available on the Ethereum mainnet.
- Method:
getLatestRoundData
- Description: Get the latest round data for a specific Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundData = await feedRegistry.getLatestRoundData(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
getRoundData
- Description: Get the round data for a specific Data Feed from the Feed Registry based on the provided round ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, roundId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairroundId
: Feed Registry Round ID
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundId = 1; const roundData = await feedRegistry.getRoundData(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, roundId);
- Method:
proposedGetLatestRoundData
- Description: Get the latest round data for a proposed Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundData = await feedRegistry.proposedGetLatestRoundData(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
proposedGetRoundData
- Description: Get the round data for a proposed Data Feed from the Feed Registry based on the provided round ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, roundId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairroundId
: Data Feed Round ID
- Returns:
(roundData: { roundId: BigNumber; answer: BigNumber; startedAt: BigNumber; updatedAt: BigNumber; answeredInRound: BigNumber; })
roundId
: Round ID of Data Feedanswer
: Round answer for a Data FeedstartedAt
: Timestamp of when the round startedupdatedAt
: Timestamp of when the round was updatedansweredInRound
: Round ID of the round in which the answer was computed
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundId = 1; const roundData = await feedRegistry.proposedGetRoundData(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, roundId);
- Method:
getRoundFeed
- Description: Get the Data Feed address for a specific Data Feed from the Feed Registry based on the provided round ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, roundId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairroundId
: Feed Registry Round ID
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundId = 1; const aggregatorAddress = await feedRegistry.getRoundFeed(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, roundId);
- Method:
getFeed
- Description: Get current Data Feed address for a specific token pair from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const aggregatorAddress = await feedRegistry.getFeed(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
getProposedFeed
- Description: Get the proposed Data Feed address for a specific token pair from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const aggregatorAddress = await feedRegistry.getProposedFeed(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
isFeedEnabled
- Description: Check if a specific Data Feed is enabled in the Feed Registry
- Arguments:
(feedRegistryAddress: string, aggregatorAddress: string)
feedRegistryAddress
: Address of Feed RegistryaggregatorAddress
: Address of a Data Feed Offchain Aggregator
- Returns:
(isEnabled: boolean)
isEnabled
: Boolean value indicating if the Data Feed is enabled in the Feed Registry
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const aggregatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const isEnabled = await feedRegistry.isFeedEnabled(feedRegistryAddress, aggregatorAddress);
- Method:
getPreviousRoundId
- Description: Get previous round ID for a specific Data Feed from the Feed Registry based on the provided round ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, roundId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairroundId
: Feed Registry Round ID
- Returns:
(roundId: BigNumber)
roundId
: Previous round ID for a specific Data Feed from the Feed Registry based on the provided round ID
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundId = 1; const previousRoundId = await feedRegistry.getPreviousRoundId(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, roundId);
- Method:
getNextRoundId
- Description: Get next round ID for a specific Data Feed from the Feed Registry based on the provided round ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, roundId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairroundId
: Feed Registry Round ID
- Returns:
(roundId: BigNumber)
roundId
: Next round ID for a specific Data Feed from the Feed Registry based on the provided round ID
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const roundId = 1; const nextRoundId = await feedRegistry.getNextRoundId(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, roundId);
- Method:
getDecimals
- Description: Get the decimals of a specific Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(decimals: number)
decimals
: Decimals of a specific Data Feed from the Feed Registry
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const decimals = await feedRegistry.getDecimals(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
getDescription
- Description: Get the description of a specific Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(description: string)
description
: Description of a specific Data Feed from the Feed Registry
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const description = await feedRegistry.getDescription(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
getVersion
- Description: Get the version of a specific Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(version: BigNumber)
version
: Version of a specific Data Feed from the Feed Registry
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const version = await feedRegistry.getVersion(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
- Method:
getPhase
- Description: Get phase data for a specific Data Feed from the Feed Registry based on the provided phase ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, phaseId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairphaseId
: Feed Registry Phase ID
- Returns:
(phaseData: { phaseId: BigNumber; startingAggregatorRoundId: BigNumber; endingAggregatorRoundId: BigNumber; })
phaseId
: Feed Registry Phase IDstartingAggregatorRoundId
: Starting round ID of the phaseendingAggregatorRoundId
: Ending round ID of the phase
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const phaseId = 1; const phaseData = await feedRegistry.getPhase(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, phaseId);
- Method:
getPhaseFeed
- Description: Get Data Feed address for a specific token pair from the Feed Registry based on the provided phase ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, phaseId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairphaseId
: Feed Registry Phase ID
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const phaseId = 1; const aggregatorAddress = await feedRegistry.getPhaseFeed(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, phaseId);
- Method:
getPhaseRange
- Description: Get the phase range data for a specific Data Feed from the Feed Registry based on the provided phase ID
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string, phaseId: BigNumberish)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pairphaseId
: Feed Registry Phase ID
- Returns:
(phaseRangeData: { startingRoundId: BigNumber; endingRoundId: BigNumber; })
startingRoundId
: Starting round ID of the phaseendingRoundId
: Ending round ID of the phase
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const phaseId = 1; const phaseRangeData = await feedRegistry.getPhaseRange(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick, phaseId);
- Method:
getCurrentPhaseId
- Description: Get current phase ID for a specific Data Feed from the Feed Registry
- Arguments:
(feedRegistryAddress: string, feedRegistryBaseTick: string, feedRegistryQuoteTick: string)
feedRegistryAddress
: Address of Feed RegistryfeedRegistryBaseTick
: Address or denomination of the base tick in a token pairfeedRegistryQuoteTick
: Address or denomination of the quote tick in a token pair
- Returns:
(phaseId: BigNumber)
phaseId
: Current phase ID for a specific Data Feed from the Feed Registry
- Usage:
const feedRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const feedRegistryBaseTick = 'ETH'; const feedRegistryQuoteTick = 'USD'; const phaseId = await feedRegistry.getCurrentPhaseId(feedRegistryAddress, feedRegistryBaseTick, feedRegistryQuoteTick);
Service alias: l2Sequencer
const l2Sequencer = hre.chainlink.l2Sequencer;
This section provides methods and functionalities designed to interact with the L2 Sequencer Uptime Feeds, which acts as data feeds that track the availability status of the sequencer in Layer 2 (L2) networks, specifically in optimistic rollup protocols.
Note L2 Sequencer Uptime Feeds are available only on specific networks, including Arbitrum mainnet, Arbitrum Goerli testnet, Optimism mainnet, Optimism Goerli testnet, and Metis mainnet (Andromeda)
- Method:
isL2SequencerUp
- Description: Checks the availability status of the Layer 2 (L2) Sequencer using the provided address of the Layer 2 Sequencer Uptime Status Feed
- Arguments:
(l2SequencerAddress: string)
l2SequencerAddress
: Address of the Layer 2 Sequencer Uptime Status Feed
- Returns:
(isUp: boolean)
isUp
: Boolean value indicating if the Layer 2 Sequencer is up and operational
- Usage:
const l2SequencerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const isUp = await l2Sequencer.isL2SequencerUp(l2SequencerAddress);
- Method:
getTimeSinceL2SequencerIsUp
- Description: Retrieves the time elapsed since the Layer 2 (L2) Sequencer has been up and operational, based on the provided address of the Layer 2 Sequencer Uptime Status Feed
- Arguments:
(l2SequencerAddress: string, gracePeriodTime: BigNumberish)
l2SequencerAddress
: Address of the Layer 2 Sequencer Uptime Status FeedgracePeriodTime
: Grace period duration in which the Sequencer is allowed to not return results
- Returns:
(l2SequencerData: { isSequencerUp: boolean; timeSinceUp: BigNumber; isGracePeriodOver: boolean; })
isSequencerUp
: Boolean value indicating if the Layer 2 Sequencer is up and operationaltimeSinceUp
: Time elapsed since the Layer 2 Sequencer has been up and operationalisGracePeriodOver
: Boolean value indicating if the grace period is over
- Usage:
const l2SequencerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const gracePeriodTime = 3600; const l2SequencerData = await l2Sequencer.getTimeSinceL2SequencerIsUp(l2SequencerAddress, gracePeriodTime);
Service alias: ens
const ens = hre.chainlink.ens;
This section provides methods and functionalities designed to interact with the Chainlink ENS Resolver.
Note Chainlink ENS is exclusively available on the Ethereum mainnet.
- Method:
resolveAggregatorAddress
- Description: Resolve Data Feed address for a token pair using the Chainlink ENS Resolver
- Arguments:
(baseTick: string, quoteTick: string)
baseTick
: Base tick of the token pairquoteTick
: Quote tick of the token pair
- Returns:
(aggregatorAddress: string)
aggregatorAddress
: Address of Data Feed Offchain Aggregator
- Usage:
const baseTick = 'ETH'; const quoteTick = 'USD'; const aggregatorAddress = await ens.resolveAggregatorAddress(baseTick, quoteTick);
- Method:
resolveAggregatorAddressWithSubdomains
- Description: Resolve Data Feed address for a token pair using the Chainlink ENS Resolver with subdomains
- Arguments:
(baseTick: string, quoteTick: string)
baseTick
: Base tick of the token pairquoteTick
: Quote tick of the token pair
- Returns:
(subdomainsData: { proxy: string; underlyingAggregator: string; proposedAggregator: string; })
proxy
: Address of Data Feed ProxyunderlyingAggregator
: Address of Data Feed Offchain AggregatorproposedAggregator
: Address of proposed Data Feed Offchain Aggregator
- Usage:
const baseTick = 'ETH'; const quoteTick = 'USD'; const subdomainsData = await ens.resolveAggregatorAddressWithSubdomains(baseTick, quoteTick);
Chainlink VRF (Verifiable Random Function) service is a critical component provided by Chainlink that enables smart contracts on the blockchain to securely and transparently access cryptographically secure and unpredictable randomness.
Service alias: vrf
const vrf = hre.chainlink.vrf;
This section provides methods and functionalities designed to interact with the VRF Coordinator smart contract, which serves as the intermediary between smart contracts on the blockchain and the VRF service.
- Method: createSubscription
- Description: Create a new subscription to the VRF service
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(txData: { subscriptionId: BigNumber; transactionHash: string; })
subscriptionId
: VRF Subscription IDtransactionHash
: Transaction hash of the transaction that created the subscription
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await vrf.createSubscription(vrfCoordinatorAddress);
- Method: fundSubscription
- Description: Fund a subscription to the VRF service with LINK tokens
- Arguments:
(vrfCoordinatorAddress: string, linkTokenAddress: string, amountInJuels: BigNumberish, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractlinkTokenAddress
: Address of the LINK token contractamountInJuels
: Amount of LINK tokens to be sent (in Juels)subscriptionId
: VRF Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that funded the subscription
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const linkTokenAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const amountInJuels = 1000000000000000000; const subscriptionId = 1; const txData = await vrf.fundSubscription(vrfCoordinatorAddress, linkTokenAddress, amountInJuels, subscriptionId);
- Method: cancelSubscription
- Description: Cancel a subscription to the VRF service and receive the remaining balance
- Arguments:
(vrfCoordinatorAddress: string, subscriptionId: BigNumberish, receivingAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contractsubscriptionId
: VRF Subscription IDreceivingAddress
: Address to receive the balance of the subscription
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that canceled the subscription
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const receivingAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await vrf.cancelSubscription(vrfCoordinatorAddress, subscriptionId, receivingAddress);
- Method: addConsumer
- Description: Add a new consumer to an existing VRF subscription
- Arguments:
(vrfCoordinatorAddress: string, consumerAddress: string, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractconsumerAddress
: Address of the consumersubscriptionId
: VRF Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that added the consumer
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const consumerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await vrf.addConsumer(vrfCoordinatorAddress, consumerAddress, subscriptionId);
- Method: removeConsumer
- Description: Remove a consumer from an existing VRF subscription
- Arguments:
(vrfCoordinatorAddress: string, consumerAddress: string, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractconsumerAddress
: Address of the consumersubscriptionId
: VRF Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that removed the consumer
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const consumerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await vrf.removeConsumer(vrfCoordinatorAddress, consumerAddress, subscriptionId);
- Method: getSubscriptionDetails
- Description: Get details of an existing VRF subscription
- Arguments:
(vrfCoordinatorAddress: string, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractsubscriptionId
: VRF Subscription ID
- Returns:
(vrfSubscriptionDetails: { balance: BigNumber; reqCount: BigNumber; owner: string; consumers: string[]; })
balance
: Balance of the subscriptionreqCount
: Number of requests made to the subscriptionowner
: Address of the subscription ownerconsumers
: List of addresses of the consumers
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const vrfSubscriptionDetails = await vrf.getSubscriptionDetails(vrfCoordinatorAddress, subscriptionId);
- Method: requestRandomWords
- Description: Request random words from the VRF service
- Arguments:
(vrfCoordinatorAddress: string, keyHash: BytesLike, subscriptionId: BigNumberish, requestConfirmations: BigNumberish, callbackGasLimit: BigNumberish, numWords: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractkeyHash
: Key hash related to maxGasPrice of a VRF. Different keyHashes have different gas pricessubscriptionId
: VRF Subscription ID. Must be funded with the minimum subscription balance required for the selected keyHashrequestConfirmations
: How many blocks you'd like the oracle to wait before responding to the requestcallbackGasLimit
: How much gas you allow for fulfillRandomWords callbacknumWords
: The number of random values you'd like to receive in fulfillRandomWords callback
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that requested the random words
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const keyHash = '0x89630569c9567e43c4fe7b1633258df9f2531b62f2352fa721cf3162ee4ecb46'; const subscriptionId = 1; const requestConfirmations = 10; const callbackGasLimit = 2500000; const numWords = 3; const txData = await vrf.requestRandomWords(vrfCoordinatorAddress, keyHash, subscriptionId, requestConfirmations, callbackGasLimit, numWords);
- Method: isPendingRequestExists
- Description: Check if there is a pending request for an existing VRF subscription
- Arguments:
(vrfCoordinatorAddress: string, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractsubscriptionId
: VRF Subscription ID
- Returns:
(isPendingRequestExists: boolean)
isPendingRequestExists
: Boolean value indicating if there is a pending request for the VRF subscription
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const isPendingRequestExists = await vrf.isPendingRequestExists(vrfCoordinatorAddress, subscriptionId);
- Method: requestSubscriptionOwnerTransfer
- Description: Request to transfer ownership of a VRF subscription to a new owner
- Arguments:
(vrfCoordinatorAddress: string, subscriptionId: BigNumberish, newOwnerAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contractsubscriptionId
: VRF Subscription IDnewOwnerAddress
: Address of the new subscription owner
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that requested the subscription owner transfer
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const newOwnerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await vrf.requestSubscriptionOwnerTransfer(vrfCoordinatorAddress, subscriptionId, newOwnerAddress);
- Method: acceptSubscriptionOwnerTransfer
- Description: Accept the transfer of ownership of a VRF subscription
- Arguments:
(vrfCoordinatorAddress: string, subscriptionId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractsubscriptionId
: VRF Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that accepted the subscription owner transfer
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await vrf.acceptSubscriptionOwnerTransfer(vrfCoordinatorAddress, subscriptionId);
- Method: getMaxConsumers
- Description: Get the maximum number of consumers that can be added to a VRF subscription
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(maxConsumers: number)
maxConsumers
: Maximum number of consumers that can be added to a VRF subscription
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const maxConsumers = await vrf.getMaxConsumers(vrfCoordinatorAddress);
- Method: getMaxNumberOfWords
- Description: Get the maximum number of random words that can be requested from the VRF service
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(maxNumberOfWords: number)
maxNumberOfWords
: Maximum number of random words that can be requested from the VRF service
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const maxNumberOfWords = await vrf.getMaxNumberOfWords(vrfCoordinatorAddress);
- Method: getMaxRequestConfirmations
- Description: Get the maximum number of confirmations allowed for a VRF request
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(maxRequestConfirmations: number)
maxRequestConfirmations
: Maximum number of confirmations allowed for a VRF request
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const maxRequestConfirmations = await vrf.getMaxRequestConfirmations(vrfCoordinatorAddress);
- Method: getMinRequestConfirmations
- Description: Get the minimum number of confirmations required for a VRF request
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(minRequestConfirmations: number)
minRequestConfirmations
: Minimum number of confirmations required for a VRF request
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const minRequestConfirmations = await vrf.getMinRequestConfirmations(vrfCoordinatorAddress);
- Method: getMaxRequestGasLimit
- Description: Get the maximum gas limit for a VRF request
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(maxRequestGasLimit: number)
maxRequestGasLimit
: Maximum gas limit for a VRF request
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const maxRequestGasLimit = await vrf.getMaxRequestGasLimit(vrfCoordinatorAddress);
- Method: getCommitment
- Description: Get the commitment data for a VRF request
- Arguments:
(vrfCoordinatorAddress: string, requestId: BigNumberish)
vrfCoordinatorAddress
: Address of VRF Coordinator contractrequestId
: Request ID
- Returns:
(commitmentData: BytesLike)
commitmentData
: Commitment data for a VRF request
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const requestId = 1; const commitmentData = await vrf.getCommitment(vrfCoordinatorAddress, requestId);
- Method: getConfig
- Description: Get the configuration details of VRF Coordinator
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(configData: { minimumRequestConfirmations: number; maxGasLimit: number; stalenessSeconds: number; gasAfterPaymentCalculation: number; })
minimumRequestConfirmations
: Minimum number of confirmations required for a VRF requestmaxGasLimit
: Maximum gas limit for a VRF requeststalenessSeconds
: Number of seconds after which a VRF request is considered stalegasAfterPaymentCalculation
: Gas used in doing accounting for a VRF request after gas measurement
- Method: getTypeAndVersion
- Description: Get the type and version details of VRF Coordinator
- Arguments:
(vrfCoordinatorAddress: string)
vrfCoordinatorAddress
: Address of VRF Coordinator contract
- Returns:
(typeAndVersion: string)
typeAndVersion
: Type and version details of VRF Coordinator
- Usage:
const vrfCoordinatorAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const typeAndVersion = await vrf.getTypeAndVersion(vrfCoordinatorAddress);
Chainlink Automation service enables conditional execution of your smart contracts functions through a hyper-reliable and decentralized automation platform.
Service alias: automationRegistrar
const automationRegistrar = hre.chainlink.automationRegistrar;
This section provides methods and functionalities designed to interact with the KeeperRegistrar smart contract. Supported versions of Keeper Registrar are v1.2, v2.0.
- Method: registerUpkeep
- Description: Register an upkeep task for Chainlink Keepers to perform on a specified contract
- Arguments:
(keeperRegistrarAddress: string, linkTokenAddress: string, amountInJuels: BigNumberish, upkeepName: string, encryptedEmail: string, upkeepContract: string, gasLimit: BigNumberish, adminAddress: string, checkData: BytesLike, ocrConfig: BytesLike, source: BigNumberish, sender: string)
keeperRegistrarAddress
: Address of Keeper RegistrarlinkTokenAddress
: Address of Link TokenamountInJuels
: Amount of LINK in juels to fund the upkeepupkeepName
: Upkeep name to be registeredencryptedEmail
: Encrypted email address of upkeep contactupkeepContract
: Upkeep contract address to perform task ongasLimit
: Limit of gas to provide the target contract when performing upkeepadminAddress
: Address to cancel upkeep and withdraw remaining fundscheckData
: Data passed to the contract when checking upkeepocrConfig
: OffchainConfig for upkeep in bytes [Keeper Registrar v2_0 ONLY], default value: "0x"source
: ID of the application sending this request [Keeper Registrar v1_1 ONLY], default value: "0"sender
: Address of the sender making the request
- Returns:
(txData: { transactionHash: string; requestHash: string; upkeepId: BigNumber; })
transactionHash
: Transaction hash of the transaction that registered the upkeeprequestHash
: Hash of the registration requestupkeepId
: Upkeep ID
- Usage:
const keeperRegistrarAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const linkTokenAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const amountInJuels = 1000000000000000000; const upkeepName = 'upkeepName'; const encryptedEmail = '0x'; const upkeepContract = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const gasLimit = 2500000; const adminAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const checkData = '0x'; const ocrConfig = '0x'; const source = 1; const sender = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await automationRegistrar.registerUpkeep(keeperRegistrarAddress, linkTokenAddress, amountInJuels, upkeepName, encryptedEmail, upkeepContract, gasLimit, adminAddress, checkData, ocrConfig, source, sender);
- Method: getPendingRequest
- Description: Get information about a pending registration request for an upkeep task
- Arguments:
(keeperRegistrarAddress: string, requestHash: BytesLike)
keeperRegistrarAddress
: Address of Keeper RegistrarrequestHash
: Hash of the registration request
- Returns:
(pendingRequestData: { adminAddress: string; balance: BigNumber; })
adminAddress
: Address to cancel upkeep and withdraw remaining fundsbalance
: Balance of the upkeep
- Usage:
const keeperRegistrarAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const requestHash = '0x'; const pendingRequestData = await automationRegistrar.getPendingRequest(keeperRegistrarAddress, requestHash);
- Method: cancelRequest
- Description: Cancel a pending registration request for an upkeep task
- Arguments:
(keeperRegistrarAddress: string, requestHash: BytesLike)
keeperRegistrarAddress
: Address of Keeper RegistrarrequestHash
: Hash of the registration request
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that canceled the request
- Usage:
const keeperRegistrarAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const requestHash = '0x'; const txData = await automationRegistrar.cancelRequest(keeperRegistrarAddress, requestHash);
- Method: getRegistrationConfig
- Description: Get the registration configuration for upkeep tasks from the Keeper Registrar
- Arguments:
(keeperRegistrarAddress: string)
keeperRegistrarAddress
: Address of Keeper Registrar
- Returns:
(registrationConfig: { autoApproveConfigType: number; autoApproveMaxAllowed: number; approvedCount: number; keeperRegistry: string; minLINKJuels: BigNumber; })
autoApproveConfigType
: Auto approve configuration typeautoApproveMaxAllowed
: Maximum number of upkeep tasks that can be auto approvedapprovedCount
: Number of upkeep tasks that have been auto approvedkeeperRegistry
: Address of Keeper RegistryminLINKJuels
: Minimum amount of LINK in juels required to register an upkeep
- Usage:
const keeperRegistrarAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const registrationConfig = await automationRegistrar.getRegistrationConfig(keeperRegistrarAddress);
- Method: getTypeAndVersion
- Description: Get the type and version for the Keeper Registrar
- Arguments:
(keeperRegistrarAddress: string)
keeperRegistrarAddress
: Address of Keeper Registrar
- Returns:
(typeAndVersion: string)
typeAndVersion
: Type and version for the Keeper Registrar
- Usage:
const keeperRegistrarAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const typeAndVersion = await automationRegistrar.getTypeAndVersion(keeperRegistrarAddress);
Service alias: automationRegistry
const automationRegistry = hre.chainlink.automationRegistry;
This section provides methods and functionalities designed to interact with the KeeperRegistry smart contract. Supported versions of Keeper Registry are v1.2, v1.3, v2.0.
- Method: getState
- Description: Get the current state of Keeper Registry
- Arguments:
(keeperRegistryAddress: string)
keeperRegistryAddress
: Address of Keeper Registry
- Returns:
(stateData: { nonce: number; ownerLinkBalance: BigNumber; expectedLinkBalance: BigNumber; numUpkeeps: BigNumber; paymentPremiumPPB: number; flatFeeMicroLink: number; blockCountPerTurn: number | undefined; checkGasLimit: number; stalenessSeconds: number; gasCeilingMultiplier: number; minUpkeepSpend: BigNumber; maxPerformGas: number; fallbackGasPrice: BigNumber; fallbackLinkPrice: BigNumber; transcoder: string; registrar: string; keepers: string[] | undefined; })
nonce
: Nonce of the Keeper RegistryownerLinkBalance
: LINK balance of the ownerexpectedLinkBalance
: Expected LINK balance of the ownernumUpkeeps
: Number of upkeep tasks registeredpaymentPremiumPPB
: Payment premium rate oracles receive on top of being reimbursed for gas, measured in parts per billionflatFeeMicroLink
: Flat fee paid to oracles for performing upkeeps in micro LINKblockCountPerTurn
: Number of blocks per turn [Keeper Registry v1_2, v1_3 ONLY]checkGasLimit
: Gas limit when checking for upkeepstalenessSeconds
: Number of seconds after which a Keeper is considered stalegasCeilingMultiplier
: Multiplier for gas ceilingminUpkeepSpend
: Minimum amount of LINK in juels an upkeep must spend before cancellingmaxPerformGas
: Maximum amount of gas allowed for an upkeep to perform on this registryfallbackGasPrice
: Fallback gas pricefallbackLinkPrice
: Fallback LINK pricetranscoder
: Address of the transcoderregistrar
: Address of the registrarkeepers
: List of addresses of the keepers [Keeper Registry v2_0 ONLY]
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const stateData = await automationRegistry.getState(keeperRegistryAddress);
- Method: getActiveUpkeepIDs
- Description: Get a list of active upkeep IDs from Keeper Registry
- Arguments:
(keeperRegistryAddress: string, startIndex: BigNumberish, maxCount: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistrystartIndex
: Starting index of Upkeeps to getmaxCount
: Quantity of Upkeeps to get
- Returns:
(activeUpkeepIds: BigNumber[])
activeUpkeepIds
: List of active upkeep IDs
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const startIndex = 0; const maxCount = 10; const activeUpkeepIds = await automationRegistry.getActiveUpkeepIDs(keeperRegistryAddress, startIndex, maxCount);
- Method: getMaxPaymentForGas
- Description: Get maximum payment for the gas limit, calculated using the Keeper Registry parameters
- Arguments:
(keeperRegistryAddress: string, gasLimit: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistrygasLimit
: Gas limit
- Returns:
(maxPaymentForGas: BigNumber)
maxPaymentForGas
: Maximum payment for a given gas limit
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const gasLimit = 2500000; const maxPaymentForGas = await automationRegistry.getMaxPaymentForGas(keeperRegistryAddress, gasLimit);
- Method: isPaused
- Description: Check if the Keeper Registry is currently paused
- Arguments:
(keeperRegistryAddress: string)
keeperRegistryAddress
: Address of Keeper Registry
- Returns:
(isPaused: boolean)
isPaused
: Boolean value indicating if the Keeper Registry is currently paused
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const isPaused = await automationRegistry.isPaused(keeperRegistryAddress);
- Method: getUpkeep
- Description: Get information about a specific upkeep from the Keeper Registry
- Arguments:
(keeperRegistryAddress: string, upkeepId: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistryupkeepId
: Upkeep ID
- Returns:
(upkeepData: { target: string; executeGas: number; checkData: BytesLike; balance: BigNumber; lastKeeper: string | undefined; admin: string; maxValidBlocknumber: BigNumber; amountSpent: BigNumber; })
target
: Address of the contract to perform upkeep onexecuteGas
: Gas limit to provide the target contract when performing upkeepcheckData
: Data passed to the contract when checking upkeepbalance
: Balance of the upkeeplastKeeper
: Keeper which last performs the upkeep [Keeper Registry v1_2, v1_3 ONLY]admin
: Address of upkeep adminmaxValidBlocknumber
: Maximum block number for the upkeep to be performedamountSpent
: Amount of LINK in juels spent on the upkeep
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepId = 1; const upkeepData = await automationRegistry.getUpkeep(keeperRegistryAddress, upkeepId);
- Method: getMinBalanceForUpkeep
- Description: Get the minimum required balance for upkeep from the Keeper Registry
- Arguments:
(keeperRegistryAddress: string, upkeepId: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistryupkeepId
: Upkeep ID
- Returns:
(minBalanceForUpkeep: BigNumber)
minBalanceForUpkeep
: Minimum required balance for upkeep
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepId = 1; const minBalanceForUpkeep = await automationRegistry.getMinBalanceForUpkeep(keeperRegistryAddress, upkeepId);
- Method: fundUpkeep
- Description: Fund an upkeep task with a specified amount of LINK in Juels
- Arguments:
(keeperRegistryAddress: string, upkeepId: BigNumberish, amountInJuels: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistryupkeepId
: Upkeep IDamountInJuels
: Amount of LINK in Juels to fund upkeep
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that funded the upkeep
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepId = 1; const amountInJuels = 1000000000000000000; const txData = await automationRegistry.fundUpkeep(keeperRegistryAddress, upkeepId, amountInJuels);
- Method: cancelUpkeep
- Description: Cancel an upkeep task in Keeper Registry
- Arguments:
(keeperRegistryAddress: string, upkeepId: BigNumberish)
keeperRegistryAddress
: Address of Keeper RegistryupkeepId
: Upkeep ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that canceled the upkeep
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepId = 1; const txData = await automationRegistry.cancelUpkeep(keeperRegistryAddress, upkeepId);
- Method: withdrawFunds
- Description: Withdraw funds from an upkeep task in Keeper Registry
- Arguments:
(keeperRegistryAddress: string, upkeepId: BigNumberish, receivingAddress: string)
keeperRegistryAddress
: Address of Keeper RegistryupkeepId
: Upkeep IDreceivingAddress
: Address to withdraw funds
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that withdrew the funds
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepId = 1; const receivingAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await automationRegistry.withdrawFunds(keeperRegistryAddress, upkeepId, receivingAddress);
- Method: migrateUpkeeps
- Description: Migrate multiple upkeep tasks to another Keeper Registry
- Arguments:
(keeperRegistryAddress: string, upkeepIds: BigNumberish[], destination: string)
keeperRegistryAddress
: Address of Keeper RegistryupkeepIds
: Upkeep IDs to migratedestination
: Address of destination Keeper Registry
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that migrated the upkeeps
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepIds = [1, 2, 3]; const destination = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await automationRegistry.migrateUpkeeps(keeperRegistryAddress, upkeepIds, destination);
- Method: getKeeperInfo
- Description: Get information about a specific keeper from Keeper Registry
- Arguments:
(keeperRegistryAddress: string, keeperAddress: string)
keeperRegistryAddress
: Address of Keeper RegistrykeeperAddress
: Keeper address
- Returns:
(keeperInfo: { payee: string; active: boolean; balance: BigNumber; })
payee
: Address of the payeeactive
: Boolean value indicating if the keeper is activebalance
: Balance of the keeper
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const keeperAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const keeperInfo = await automationRegistry.getKeeperInfo(keeperRegistryAddress, keeperAddress);
- Method: getTypeAndVersion
- Description: Get the type and version for Keeper Registry
- Arguments:
(keeperRegistryAddress: string)
keeperRegistryAddress
: Address of Keeper Registry
- Returns:
(typeAndVersion: string)
typeAndVersion
: Type and version for Keeper Registry
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const typeAndVersion = await automationRegistry.getTypeAndVersion(keeperRegistryAddress);
- Method: getUpkeepTranscoderVersion
- Description: Get the upkeep transcoder version from Keeper Registry
- Arguments:
(keeperRegistryAddress: string)
keeperRegistryAddress
: Address of Keeper Registry
- Returns:
(upkeepTranscoderVersion: string)
upkeepTranscoderVersion
: Upkeep transcoder version from Keeper Registry
- Usage:
const keeperRegistryAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const upkeepTranscoderVersion = await automationRegistry.getUpkeepTranscoderVersion(keeperRegistryAddress);
Chainlink Functions service provides your smart contracts access to trust-minimized compute infrastructure, allowing you to fetch data from APIs and perform custom computation.
Note
Most of the methods under this section are thin wrappers for the methods provided by the functions-toolkit NPM package.
Service alias: functions
const functions = hre.chainlink.functions;
This section provides methods and functionalities designed to interact with the Functions service.
- Method: createSubscription
- Description: Create Functions subscription
- Arguments:
(functionsRouterAddress: string, consumerAddress: string)
functionsRouterAddress
: Address of Functions RouterconsumerAddress
: Address of Functions Consumer (Default: "")
- Returns:
(subscriptionId: BigNumber)
subscriptionId
: Subscription ID
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const consumerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = await functions.createSubscription(functionsRouterAddress, consumerAddress);
- Method: fundSubscription
- Description: Fund Functions subscription
- Arguments:
(functionsRouterAddress: string, linkTokenAddress: string, amountInJuels: BigNumberish, subscriptionId: BigNumberish)
functionsRouterAddress
: Address of Functions RouterlinkTokenAddress
: Address of Link TokenamountInJuels
: Amount of LINK in Juels to fund SubscriptionsubscriptionId
: Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that funded the subscription
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const linkTokenAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const amountInJuels = 1000000000000000000; const subscriptionId = 1; const txData = await functions.fundSubscription(functionsRouterAddress, linkTokenAddress, amountInJuels, subscriptionId);
- Method: cancelSubscription
- Description: Cancel Functions subscription
- Arguments:
(functionsRouterAddress: string, subscriptionId: BigNumberish, receivingAddress: string)
functionsRouterAddress
: Address of Functions RoutersubscriptionId
: Subscription IDreceivingAddress
: Address to receive the balance of Subscription (Default: "")
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that canceled the subscription
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const receivingAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await functions.cancelSubscription(functionsRouterAddress, subscriptionId, receivingAddress);
- Method: getSubscriptionDetails
- Description: Get subscription details
- Arguments:
(functionsRouterAddress: string, subscriptionId: BigNumberish)
functionsRouterAddress
: Address of Functions RoutersubscriptionId
: Subscription ID
- Returns:
(subscriptionDetails: { balance: BigNumber; owner: string; blockedBalance: BigNumber; proposedOwner: string; consumers: string[]; flags: string; })
balance
: Balance of the subscriptionowner
: Address of the subscription ownerblockedBalance
: Blocked balance of the subscriptionproposedOwner
: Address of the proposed subscription ownerconsumers
: List of addresses of the consumersflags
: Subscription flags
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const subscriptionDetails = await functions.getSubscriptionDetails(functionsRouterAddress, subscriptionId);
- Method: requestSubscriptionOwnerTransfer
- Description: Request subscription owner transfer
- Arguments:
(functionsRouterAddress: string, subscriptionId: BigNumberish, newOwnerAddress: string)
functionsRouterAddress
: Address of Functions RoutersubscriptionId
: Subscription IDnewOwnerAddress
: Address of new owner of Subscription
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that requested the subscription owner transfer
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const newOwnerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const txData = await functions.requestSubscriptionOwnerTransfer(functionsRouterAddress, subscriptionId, newOwnerAddress);
- Method: acceptSubscriptionOwnerTransfer
- Description: Accept subscription owner transfer
- Arguments:
(functionsRouterAddress: string, subscriptionId: BigNumberish)
functionsRouterAddress
: Address of Functions RoutersubscriptionId
: Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that accepted the subscription owner transfer
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await functions.acceptSubscriptionOwnerTransfer(functionsRouterAddress, subscriptionId);
- Method: addConsumer
- Description: Add subscription consumer
- Arguments:
(functionsRouterAddress: string, consumerAddress: string, subscriptionId: BigNumberish)
functionsRouterAddress
: Address of Functions RouterconsumerAddress
: Address of Functions ConsumersubscriptionId
: Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that added the consumer
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const consumerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await functions.addConsumer(functionsRouterAddress, consumerAddress, subscriptionId);
- Method: removeConsumer
- Description: Remove subscription consumer
- Arguments:
(functionsRouterAddress: string, consumerAddress: string, subscriptionId: BigNumberish)
functionsRouterAddress
: Address of Functions RouterconsumerAddress
: Address of Functions ConsumersubscriptionId
: Subscription ID
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that removed the consumer
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const consumerAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const txData = await functions.removeConsumer(functionsRouterAddress, consumerAddress, subscriptionId);
- Method: timeoutRequests
- Description: Timeout pending Functions request
- Arguments:
(functionsRouterAddress: string, requestIdsString: string, donId: string, toBlock: string, pastBlocksToSearch: string)
functionsRouterAddress
: Address of Functions RouterrequestIdsString
: Comma-separated requests IDsdonId
: ID of the DON where Functions requests has been senttoBlock
: End block in search range (Default: "latest")pastBlocksToSearch
: Number of blocks to search (before toBlock) (Default: "1000")
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that timed out the requests
- Method: timeoutRequests
- Description: Timeout pending Functions request
- Arguments:
(functionsRouterAddress: string, requestCommitments: RequestCommitment[])
functionsRouterAddress
: Address of Functions RouterrequestCommitments
: Array of RequestCommitment objects
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that timed out the requests
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const requestCommitments = []; const txData = await functions.timeoutRequests(functionsRouterAddress, requestCommitments);
- Method: estimateRequestCost
- Description: Estimate the cost of a request
- Arguments:
(functionsRouterAddress: string, donId: string, subscriptionId: BigNumberish, callbackGasLimit: number, gasPriceWei: BigNumberish)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to which the Functions request will be sentsubscriptionId
: Subscription IDcallbackGasLimit
: Total gas used by the consumer contract's callbackgasPriceWei
: Gas price in wei
- Returns:
(requestCost: BigInt)
requestCost
: Cost of the request
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const subscriptionId = 1; const callbackGasLimit = 2500000; const gasPriceWei = 1000000000; const requestCost = await functions.estimateRequestCost(functionsRouterAddress, donId, subscriptionId, callbackGasLimit, gasPriceWei);
Note The following are methods that are available only in HRE
- Method: initializeSubscriptionManager
- Description: Initialize SubscriptionManager class
- Arguments:
(functionsRouterAddress: string, linkTokenAddress: string)
functionsRouterAddress
: Address of Functions RouterlinkTokenAddress
: Address of Link Token
- Returns:
(subscriptionManager: FunctionsSubscriptionManager)
subscriptionManager
: SubscriptionManager class instance
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const linkTokenAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionManager = await functions.initializeSubscriptionManager(functionsRouterAddress, linkTokenAddress);
- Method: initializeResponseListener
- Description: Initialize ResponseListener class
- Arguments:
(functionsRouterAddress: string)
functionsRouterAddress
: Address of Functions Router
- Returns:
(responseListener: FunctionsResponseListener)
responseListener
: ResponseListener class instance
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const responseListener = await functions.initializeResponseListener(functionsRouterAddress);
- Method: initializeSecretsManager
- Description: Initialize SecretsManager class
- Arguments:
(functionsRouterAddress: string, donId: string)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work with
- Returns:
(secretsManager: FunctionsSecretsManager)
secretsManager
: SecretsManager class instance
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const secretsManager = await functions.initializeSecretsManager(functionsRouterAddress, donId);
- Method: listenForResponse
- Description: Listen for a response for single Functions request
- Arguments:
(functionsRouterAddress: string, requestId: BigNumberish, timeout: number)
functionsRouterAddress
: Address of Functions RouterrequestId
: Request IDtimeout
: Subscription ID (Default: 300_000)
- Returns:
(response: FunctionsResponse)
response
: Response of the request
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const requestId = 1; const timeout = 300000; const response = await functions.listenForResponse(functionsRouterAddress, requestId, timeout);
- Method: listenForResponseFromTransaction
- Description: Listen for a response for single Functions request (from transaction)
- Arguments:
(functionsRouterAddress: string, transactionHash: string, timeout: number, confirmations: number, checkInterval: number)
functionsRouterAddress
: Address of Functions RoutertransactionHash
: Transaction hash to start listen fromtimeout
: Listener timeout (Default: 300000)confirmations
: Number of block confirmations (Default: 2)checkInterval
: Frequency of checking for a response to appear on-chain (Default: 2000)
- Returns:
(response: FunctionsResponse)
response
: Response of the request
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const transactionHash = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const timeout = 300000; const confirmations = 2; const checkInterval = 2000; const response = await functions.listenForResponseFromTransaction(functionsRouterAddress, transactionHash, timeout, confirmations, checkInterval);
- Method: listenForResponses
- Description: Listen for multiple Functions responses
- Arguments:
(functionsRouterAddress: string, subscriptionId: BigNumberish, callback: (response: FunctionsResponse) => any)
functionsRouterAddress
: Address of Functions RoutersubscriptionId
: Subscription IDcallback
: Callback to be called when responses are fulfilled
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const subscriptionId = 1; const callback = (response: FunctionsResponse) => { console.log(response); }; await functions.listenForResponses(functionsRouterAddress, subscriptionId, callback);
- Method: stopListeningForResponses
- Description: Stop response listener
- Arguments:
(functionsRouterAddress: string)
functionsRouterAddress
: Address of Functions Router
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; await functions.stopListeningForResponses(functionsRouterAddress);
- Method: fetchKeys
- Description: Fetch DON public keys
- Arguments:
(functionsRouterAddress: string, donId: string)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to fetch keys from
- Returns:
(keys: { thresholdPublicKey: ThresholdPublicKey; donPublicKey: string; })
thresholdPublicKey
: Threshold public keydonPublicKey
: DON public key
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const keys = await functions.fetchKeys(functionsRouterAddress, donId);
- Method: encryptSecretsUrls
- Description: Encrypt Off-Chain Secrets URLs with DON public key to produce encryptedSecretsReference
- Arguments:
(functionsRouterAddress: string, donId: string, secretsUrls: string[])
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to fetch keys fromsecretsUrls
: URLs of secrets
- Returns:
(encryptedSecretsReference: string)
encryptedSecretsReference
: HEX string of encrypted secrets
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const secretsUrls = ['https://gist.github.com/username/secret']; const encryptedSecretsReference = await functions.encryptSecretsUrls(functionsRouterAddress, donId, secretsUrls);
- Method: verifyOffchainSecrets
- Description: Verify if provided Gists secret URLs are valid
- Arguments:
(functionsRouterAddress: string, donId: string, secretsUrls: string[])
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to fetch keys fromsecretsUrls
: URLs of secrets
- Returns:
(isValid: boolean)
isValid
: True if all secrets URLs are valid
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const secretsUrls = ['https://gist.github.com/username/secret']; const isValid = await functions.verifyOffchainSecrets(functionsRouterAddress, donId, secretsUrls);
- Method: encryptSecrets
- Description: Encrypt secrets with DON public key to produce encryptedSecretsHexstring
- Arguments:
(functionsRouterAddress: string, donId: string, secrets: string)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work withsecrets
: String key/value pairs of secrets
- Returns:
(encryptedSecretsData: { encryptedSecrets: string; })
encryptedSecrets
: HEX string of encrypted secrets
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const secrets = {'test': 'test'}; const encryptedSecretsData = await functions.encryptSecrets(functionsRouterAddress, donId, secrets);
- Method: uploadEncryptedSecretsToDON
- Description: Upload encrypted secrets to DON
- Arguments:
(functionsRouterAddress: string, donId: string, encryptedSecretsHexstring: string, gatewayUrls: string[], slotId: number, minutesUntilExpiration: number)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work withencryptedSecretsHexstring
: HEX string of encrypted secrets. Result of encryptSecrets() methodgatewayUrls
: DON gateway URLsslotId
: Storage slot ID, can be any integer value of zero or greaterminutesUntilExpiration
: Minutes after secrets will be deleted from all DON nodes
- Returns:
(uploadDetails: { version: number; success: boolean; })
version
: Version of the uploaded secretssuccess
: True if secrets were uploaded successfully
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const encryptedSecretsHexstring = '0x89630569c9567e43c4fe7b1633258df9f2531b62f2352fa721cf3162ee4ecb46'; const gatewayUrls = ['https://gateway.don.dev']; const slotId = 1; const minutesUntilExpiration = 60; const uploadDetails = await functions.uploadEncryptedSecretsToDON(functionsRouterAddress, donId, encryptedSecretsHexstring, gatewayUrls, slotId, minutesUntilExpiration);
- Method: listDONHostedEncryptedSecrets
- Description: Get list of DON hosted encrypted secrets
- Arguments:
(functionsRouterAddress: string, donId: string, gatewayUrls: string[])
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work withgatewayUrls
: DON gateway URLs
- Returns:
(secretsList: { result: GatewayResponse; error?: string; })
result
: Gateway responseerror
: Error message
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const gatewayUrls = ['https://gateway.don.dev']; const secretsList = await functions.listDONHostedEncryptedSecrets(functionsRouterAddress, donId, gatewayUrls);
- Method: buildDONHostedEncryptedSecretsReference
- Description: Build DON hosted encrypted secrets reference (encryptedSecretsReference)
- Arguments:
(functionsRouterAddress: string, donId: string, slotId: number, version: number)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work withslotId
: Storage slot ID, can be any integer value of zero or greaterversion
: Reference version, any integer value of zero or greater
- Returns:
(encryptedSecretsReference: string)
encryptedSecretsReference
: HEX string of encrypted secrets reference
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const slotId = 1; const version = 1; const encryptedSecretsReference = await functions.buildDONHostedEncryptedSecretsReference(functionsRouterAddress, donId, slotId, version);
- Method: fetchRequestCommitment
- Description: Fetch Commitments for Function request
- Arguments:
(functionsRouterAddress: string, donId: string, requestId: string, toBlock: number, pastBlocksToSearch: number)
functionsRouterAddress
: Address of Functions RouterdonId
: ID of the DON to work withrequestId
: Request IDtoBlock
: Ending block number to search for the request commitmentpastBlocksToSearch
: Number of blocks from the ending block to search for the request commitment
- Returns:
(requestCommitment: RequestCommitment)
requestCommitment
: RequestCommitment object
- Usage:
const functionsRouterAddress = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const donId = '1'; const requestId = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const toBlock = 1000000; const pastBlocksToSearch = 1000; const requestCommitment = await functions.fetchRequestCommitment(functionsRouterAddress, donId, requestId, toBlock, pastBlocksToSearch);
The plugin utility methods.
Service alias: utils
const utils = hre.chainlink.utils;
- Method: getRoundId
- Description: Obtain the Data Feed Proxy/Registry round ID using the provided phase ID and aggregator round ID
- Arguments:
(phaseId: BigNumberish, aggregatorRoundId: BigNumberish)
phaseId
: Data Feed Proxy/Registry phase IDaggregatorRoundId
: Data Feed round ID
- Returns:
(roundId: BigNumber)
roundId
: Data Feed Proxy/Registry round ID
- Usage:
const phaseId = 1; const aggregatorRoundId = 1; const roundId = await utils.getRoundId(phaseId, aggregatorRoundId);
- Method: parseRoundId
- Description: Parse the given Data Feed Proxy/Registry round ID to extract relevant information
- Arguments:
(roundId: BigNumberish)
roundId
: Data Feed Proxy/Registry round ID
- Returns:
(roundIdData: { phaseId: BigNumber; aggregatorRoundId: BigNumber; })
phaseId
: Data Feed Proxy/Registry phase IDaggregatorRoundId
: Data Feed round ID
- Usage:
const roundId = 1; const roundIdData = await utils.parseRoundId(roundId);
- Method: transferETH
- Description: Transfer ETH to recipient
- Arguments:
(recipient: string, amount: BigNumberish)
recipient
: Recipient addressamount
: Amount of ETH in wei
- Returns:
(txData: { transactionHash: string; })
transactionHash
: Transaction hash of the transaction that transferred ETH
- Usage:
const recipient = '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const amount = 1000000000000000000; const txData = await utils.transferETH(recipient, amount);
- Method: createGist
- Description: Create private GitHub gist
- Arguments:
(githubApiToken: string, content: string)
githubApiToken
: GitHub API tokencontent
: Gist content
- Returns:
(gistId: string)
gistId
: Gist ID
- Usage:
const githubApiToken = '8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const content = 'test'; const gistId = await utils.createGist(githubApiToken, content);
- Method: deleteGist
- Description: Delete private GitHub gist
- Arguments:
(githubApiToken: string, gistURL: string)
githubApiToken
: GitHub API tokengistURL
: Gist URL
- Returns:
(success: boolean)
success
: True if gist was deleted successfully
- Usage:
const githubApiToken = '8A753747A1Fa494EC906cE90E9f37563A8AF630e'; const gistURL = 'https://gist.github.com/username/secret'; const success = await utils.deleteGist(githubApiToken, gistURL);
Note The following are methods that are available only in HRE
- Method: buildFunctionsRequestCBOR
- Description: Build CBOR for Functions request
- Arguments:
(codeLocation: number, codeLanguage: number, source: string, secretsLocation: number, encryptedSecretsReference: string, args: string[], bytesArgs: string[])
codeLocation
: Inline = 0 | Remote = 1 | DONHosted = 2codeLanguage
: JavaScript = 0source
: Functions request source codesecretsLocation
: Inline = 0 | Remote = 1 | DONHosted = 2encryptedSecretsReference
: HEX string, result of buildDONHostedEncryptedSecretsReference methodargs
: Functions request argsbytesArgs
: Functions request bytes args
- Returns:
(cbor: string)
cbor
: HEX string of CBOR
- Usage:
const codeLocation = 0; const codeLanguage = 0; const source = 'return true;'; const secretsLocation = 0; const encryptedSecretsReference = '0x89630569c9567e43c4fe7b1633258df9f2531b62f2352fa721cf3162ee4ecb46'; const args = []; const bytesArgs = []; const cbor = await utils.buildFunctionsRequestCBOR(codeLocation, codeLanguage, source, secretsLocation, encryptedSecretsReference, args, bytesArgs);
- Method: decodeHexString
- Description: Decode HEX String
- Arguments:
(resultHexString: string, expectedReturnType: ReturnType)
resultHexString
: HEX string to decodeexpectedReturnType
: ReturnType
- Returns:
(result: DecodedResult)
result
: Decoded result
- Usage:
const resultHexString = '0x89630569c9567e43c4fe7b1633258df9f2531b62f2352fa721cf3162ee4ecb46'; const expectedReturnType = ReturnType.string; const result = await utils.decodeHexString(resultHexString, expectedReturnType);