NEW

Chainlink is collaborating with Swift and 12+ leading financial institutions. Read the announcement.

Chainlink Functions Concepts

Chainlink Functions do not require your consumer contracts to hold LINK tokens and send them to oracles when making requests. Instead, you must create a subscription account and fund it to pre-pay for your Chainlink Functions requests, so your consumer contracts don't need to hold LINK when calling Chainlink Functions.

Before you explore how Chainlink Functions works in the Architecture guide, it is best to understand the core concepts in this guide.

Request and Receive Data

This model is similar to the Basic Request Model: Consumer contracts initiate the cycle by creating requests to Functions Oracle contracts. Oracle nodes watch for events emitted by the Functions Oracle contract and run the computation off-chain. Finally, oracle nodes use the Chainlink OCR protocol to aggregate all the responses before passing the aggregated responses to the consumer contracts in callbacks. Note: As long as you use vanilla Node.js (no modules imports), you can decentralize any computation you want such as API calls, computing maths operations, etc.

Decentralized Oracle Network (DON)

Chainlink Functions are powered by a Decentralized Oracle Network. The oracle nodes are independent of each other and are responsible for running the same function such as API calls, computing maths operations, etc. The nodes use the Chainlink OCR protocol to aggregate all the nodes' responses. Finally, a DON's oracle sends the aggregate response to the consumer contract in a callback.

Subscriptions

  • Subscriptions App: A user interface that interacts with the Subscriptions Contract. Note: The Subscriptions App is not available now, we recommend using the functions hardhat starter kit to interact with the Subscriptions Contract.
  • Subscriptions Contract (aka Functions Billing Registry Contract): The contract that holds user funds to pay for Chainlink Functions requests.
  • subscription account: An account that holds LINK tokens and makes them available to fund requests to Chainlink DON. A Subscription ID uniquely IDentifies each account.
  • Subscription ID: 64-bit unsigned integer representing the unique IDentifier of the Subscription account.
  • Subscription owner: The wallet address that creates and manages a Subscription account. Any account can add LINK tokens to the subscription balance, but only the owner can add approved consuming contracts or withdraw funds.
  • Subscription balance: The amount of LINK maintained on your Subscription account. Requests from consumer contracts will continue to be funded until the balance runs out, so be sure to maintain sufficient funds in your Subscription balance to pay for the requests and keep your applications running.
  • Subscription reservation: The amount of LINK blocked on the Subscription balance. It corresponds to the total LINK amount to be paid by in-flight requests.
  • Effective balance: The amount of LINK available on your Subscription account. Effective balance = Subscription balance - Subscription reservation.
  • Subscription consumers: Consumer contracts are approved to use funding from your Subscription account while making Chainlink Functions requests. The consumers receive response data in a callback.

What's next

Stay updated on the latest Chainlink news