Chainlink Functions Billing
Concepts
For Chainlink Functions to fulfill your requests, you must maintain a sufficient amount of LINK in your subscription balance. Because Chainlink Functions follows the Request and Receive Data model, billing is also done in two steps:
- During the Request step. the cost to fulfill a Chainlink Functions request is estimated and blocked on the Subscription balance by adding it to the Subscription reservation.
- During the Receive step, the exact cost of the fulfillment is calculated and billed to the Subscription account.
You can break down total costs into the following components:
- Gas cost: This cost is paid back to the Transmitter oracle for fulfilling the request.
- Fees:
- DON fees: These fees are paid to the DON in LINK to compensate the nodes for their work.
- Registry fees: These fees are paid in LINK for the maintenance of the Subscriptions Contract.
Gas cost calculation includes the following variables:
- Gas price: The current gas price fluctuates depending on network conditions.
- Callback gas: The amount of gas used for the callback request. See the Cost Calculation section.
- Estimated gas overhead: The amount of gas used by the Subscriptions contract and Functions Oracle contract. It is an estimate of the total gas cost of fulfilling a request. See the Cost Simulation section.
- Gas Report: The exact amount of gas used by the Functions Oracle contract when fulfilling a request. See the Cost Calculation section.
- Gas after payment: The amount of gas used to cover additional operations such as decrementing the subscription balance and incrementing the oracle’s withdrawable balance.
- Callback gas limit: This specifies the maximum amount of gas to spend for a client callback. It is an estimate of the total gas cost to fulfil a request. See the Cost Simulation section.
- Native to LINK conversion: This allows your subscription balance to be billed only in LINK tokens.
- Convert the network’s native currency to LINK: The total gas cost in native units is converted to LINK using the correct Price Feed. On Sepolia, the conversion uses the ETH/LINK Price Feed. On Polygon Mumbai, the conversion uses the MATIC/LINK Price Feed.
- Fallback Wei to LINK ratio: In the unlikely event that the Native to LINK price data feed is unavailable, the fallback conversion is used. You can find this ratio by running the
gitConfig
function in the Oracle Registry proxy contract. See the Supported Networks page to find the contract addresses for each network.
Cost Simulation (Reservation)
During the Request step:
-
The total cost in LINK is estimated using the following formula:
(Gas price * (Estimated gas overhead + Callback gas limit + Gas after payment)) / Native to Link conversion = total estimated gas cost in LINK total estimated cost in LINK = total gas cost + DON fees + Registry fees
-
The total estimated cost is then added to the Subscription reservation.
Cost Calculation (Fulfillment)
When a DON’s oracle reports the response, subscription accounts are charged based on the gas amount used in the callback:
-
The total cost in LINK is calculated using the following formula:
(Gas price * (Gas Report + Callback gas + Gas after payment)) / Native to Link conversion = total gas cost in LINK total cost in LINK = total gas cost + DON fees + Registry fees
-
The Subscription contract performs several accounting movements:
- Debit the Subscription balance of the total cost.
- Pay the Registry fee.
- Pay the oracle that reported the response: Repayment of total gas cost and proportional share of the DON fees.
- Pay the oracles participating in the DON with the rest of the DON fees.
- Decrease the Subscription reservation of the total estimated cost.
Fees
Item | Ethereum Sepolia testnet | Polygon Mumbai testnet |
---|---|---|
Registry fees | 0.2 LINK | 0.2 LINK |
DON fees | 0 LINK | 0 LINK |