FunctionsClient API Reference
Consumer contract developers inherit FunctionsClient to create Chainlink Functions requests.
Events
RequestSent
event RequestSent(bytes32 id)
RequestFulfilled
event RequestFulfilled(bytes32 id)
Errors
OnlyRouterCanFulfill
error OnlyRouterCanFulfill()
Methods
constructor
constructor(address router)
_sendRequest
function _sendRequest(bytes data, uint64 subscriptionId, uint32 callbackGasLimit, bytes32 donId) internal returns (bytes32)
Sends a Chainlink Functions request to the stored router address
Parameters
Name | Type | Description |
---|---|---|
data | bytes | The CBOR encoded bytes data for a Functions request |
subscriptionId | uint64 | The subscription ID that will be charged to service the request |
callbackGasLimit | uint32 | the amount of gas that will be available for the fulfillment callback |
donId | bytes32 |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes32 | requestId The generated request ID for this request |
fulfillRequest
function fulfillRequest(bytes32 requestId, bytes response, bytes err) internal virtual
User defined function to handle a response from the DON
Either response or error parameter will be set, but never both
Parameters
Name | Type | Description |
---|---|---|
requestId | bytes32 | The request ID, returned by sendRequest() |
response | bytes | Aggregated response from the execution of the user's source code |
err | bytes | Aggregated error from the execution of the user code or from the execution pipeline |
handleOracleFulfillment
function handleOracleFulfillment(bytes32 requestId, bytes response, bytes err) external
Chainlink Functions response handler called by the Functions Router during fullilment from the designated transmitter node in an OCR round
Either response or error parameter will be set, but never both
Parameters
Name | Type | Description |
---|---|---|
requestId | bytes32 | The requestId returned by FunctionsClient.sendRequest(). |
response | bytes | Aggregated response from the request's source code. |
err | bytes | Aggregated error either from the request's source code or from the execution pipeline. |