NEW

CCIP is now live for all developers. See what's new.

Back

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

NameTypeDescription
databytesThe CBOR encoded bytes data for a Functions request
subscriptionIduint64The subscription ID that will be charged to service the request
callbackGasLimituint32the amount of gas that will be available for the fulfillment callback
donIdbytes32

Return Values

NameTypeDescription
[0]bytes32requestId 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

NameTypeDescription
requestIdbytes32The request ID, returned by sendRequest()
responsebytesAggregated response from the execution of the user's source code
errbytesAggregated 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

NameTypeDescription
requestIdbytes32The requestId returned by FunctionsClient.sendRequest().
responsebytesAggregated response from the request's source code.
errbytesAggregated error either from the request's source code or from the execution pipeline.

Stay updated on the latest Chainlink news