CallbackConsumer
Git Source (opens in a new tab)
Inherits: BaseConsumer
Allows creating one-time requests for off-chain container compute, delivered via callback
Inherits BaseConsumer
to inherit functions to receive container compute responses and emit container inputs
State Variables
subscriptionInputs
subscriptionId => callback input data
Could be restricted to private
visibility but kept internal
for better testing/downstream modification support
mapping(uint32 => bytes) internal subscriptionInputs;
Functions
constructor
Initialize new CallbackConsumer
constructor(address registry) BaseConsumer(registry);
Parameters
Name | Type | Description |
---|---|---|
registry | address | registry address |
_requestCompute
Creates a one-time request for off-chain container compute via callback
Under the hood, creates a new subscription at the Infernet coordinator, with period == 0
and
frequency == 1
, effectively initializing a subscription valid immediately and only for 1 interval
function _requestCompute(
string memory containerId,
bytes memory inputs,
uint16 redundancy,
address paymentToken,
uint256 paymentAmount,
address wallet,
address verifier
) internal returns (uint32);
Parameters
Name | Type | Description |
---|---|---|
containerId | string | compute container identifier(s) used by off-chain Infernet node |
inputs | bytes | optional container inputs |
redundancy | uint16 | number of unique responding Infernet nodes |
paymentToken | address | If providing payment for compute, payment token address (address(0) for ETH, else ERC20 contract address) |
paymentAmount | uint256 | If providing payment for compute, payment in paymentToken per compute request fulfillment |
wallet | address | If providing payment for compute, Infernet Wallet address; this contract must be approved spender of Wallet |
verifier | address | optional verifier contract to restrict payment based on response proof verification |
Returns
Name | Type | Description |
---|---|---|
<none> | uint32 | subscription ID of newly-created one-time subscription |
getContainerInputs
View function to broadcast dynamic container inputs to off-chain Infernet nodes
Modified from BaseConsumer
to expose callback input data, indexed by subscriptionId
function getContainerInputs(uint32 subscriptionId, uint32 interval, uint32 timestamp, address caller)
external
view
override
returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
subscriptionId | uint32 | subscription ID to collect container inputs for |
interval | uint32 | subscription interval to collect container inputs for |
timestamp | uint32 | timestamp at which container inputs are collected |
caller | address | calling address |