Chainlink Functions Beacon (CLF)
Chainlink Functions Beacon is a private, permissionless implementation for our enterprise partners. If you wish want to build with the CLF tooling to start monetizing your data today, please reach out to an Instruxi solutions expert. For developers looking for purpose built oracles like KYC, identity, invoice processing, etc. see the subsequent documentation.
Primary vs. Secondary Functions Consumer
Primary Functions Consumer:
- Directly interacts with Chainlink's decentralized oracle network (DON)
- Must manage its own subscription
- Handle callbacks from oracles themselves
- Consumer pays for compute from subscription-level LINK balance
Secondary Functions Consumer:
- Interact through an intermediary contract (the Chainlink Functions Beacon)
- Pay on a per-transaction basis using native token not LINK subscription
- Receives callbacks through the intermediary client (the primary consumer)
Getting Started with Chainlink Functions Beacon Client
Learn how to integrate with the Chainlink Functions Beacon for off-chain computations and API calls. This guide walks you through creating a client contract (secondary) that interacts with the Chainlink Functions Beacon contract (primary). See Chainlink Functions official documentation.
Prerequisites
- Ethereum development environment (Hardhat/Foundry)
- Web3 wallet with testnet tokens
- Basic Solidity knowledge
Integration Steps (Hardhat)
- Install Dependencies
npm install @openzeppelin/contracts @chainlink/contracts
- Create Your Client Contract
- Inherit from
Ownable
- Import the beacon interface:
interface IChainlinkFunctionsBeacon {
function requestComputation(bytes32 data, bytes32 source) external returns (bytes32);
}
- Implement Required Functions
- Constructor to set beacon address
requestBeaconComputation()
to make requestsoracleCallback()
to receive responses- Event handlers for tracking request status
- Handle Responses
Your contract must implement the callback function:
function oracleCallback(
bytes32 requestId,
bytes memory response,
bytes memory err
) external onlyBeacon
Usage Example
contract SimpleBeaconClient {
function makeRequest() external {
bytes32 requestId = beacon.requestComputation(
data, // Your encoded request data
source // Provider source hash
);
}
}
Security Considerations
- Use
onlyBeacon
modifier for callbacks
Updated 18 days ago