Infernet
SDK
Reference
Consumers
BaseConsumer

BaseConsumer

Git Source (opens in a new tab)

Handles receiving container compute responses from Infernet coordinator

Handles exposing container inputs to Infernet nodes via getContainerInputs()

Declares internal INBOX reference to allow downstream consumers to read from Inbox

Contains a single public entrypoint rawReceiveCompute callable only by the Infernet coordinator. Once msg.sender is verified, parameters are proxied to internal function _receiveCompute

Does not inherit Coordinated for rawReceiveCompute coordinator-permissioned check to keep error scope localized

State Variables

COORDINATOR

Coordinator

Internal visibility since COORDINATOR is consumed by inheriting contracts

Coordinator internal immutable COORDINATOR;

INBOX

Inbox

Internal visibility since INBOX can be consumed by inheriting readers

Inbox internal immutable INBOX;

Functions

constructor

Initialize new BaseConsumer

constructor(address registry);

Parameters

NameTypeDescription
registryaddressregistry address

_receiveCompute

Callback entrypoint to receive container compute responses from validated Coordinator source

Called by rawReceiveCompute once validated that msg.sender == address(COORDINATOR)

Same function parameters as rawReceiveCompute

function _receiveCompute(
    uint32 subscriptionId,
    uint32 interval,
    uint16 redundancy,
    address node,
    bytes calldata input,
    bytes calldata output,
    bytes calldata proof,
    bytes32 containerId,
    uint256 index
) internal virtual;

Parameters

NameTypeDescription
subscriptionIduint32id of subscription being responded to
intervaluint32subscription interval
redundancyuint16after this call succeeds, how many nodes will have delivered a response for this interval
nodeaddressaddress of responding Infernet node
inputbytesoptional off-chain container input recorded by Infernet node (empty, hashed input, processed input, or both), empty for lazy subscriptions
outputbytesoptional off-chain container output (empty, hashed output, processed output, both, or fallback: all encodeable data), empty for lazy subscriptions
proofbytesoptional off-chain container execution proof (or arbitrary metadata), empty for lazy subscriptions
containerIdbytes32if lazy subscription, subscription compute container ID, else empty
indexuint256if lazy subscription, Inbox lazy store index, else empty

getContainerInputs

View function to broadcast dynamic container inputs to off-chain Infernet nodes

Developers can modify this function to return dynamic inputs

function getContainerInputs(uint32 subscriptionId, uint32 interval, uint32 timestamp, address caller)
    external
    view
    virtual
    returns (bytes memory);

Parameters

NameTypeDescription
subscriptionIduint32subscription ID to collect container inputs for
intervaluint32subscription interval to collect container inputs for
timestampuint32timestamp at which container inputs are collected
calleraddresscalling address

rawReceiveCompute

Callback entrypoint called by Infernet Coordinator to return container compute responses

Callable only by address(COORDINATOR), else throws NotCoordinator() error

function rawReceiveCompute(
    uint32 subscriptionId,
    uint32 interval,
    uint16 redundancy,
    address node,
    bytes calldata input,
    bytes calldata output,
    bytes calldata proof,
    bytes32 containerId,
    uint256 index
) external;

Parameters

NameTypeDescription
subscriptionIduint32id of subscription being responded to
intervaluint32subscription interval
redundancyuint16after this call succeeds, how many nodes will have delivered a response for this interval
nodeaddressaddress of responding Infernet node
inputbytesoptional off-chain container input recorded by Infernet node (empty, hashed input, processed input, or both), empty for lazy subscriptions
outputbytesoptional off-chain container output (empty, hashed output, processed output, both, or fallback: all encodeable data), empty for lazy subscriptions
proofbytesoptional off-chain container execution proof (or arbitrary metadata), empty for lazy subscriptions
containerIdbytes32if lazy subscription, subscription compute container ID, else empty
indexuint256if lazy subscription, Inbox lazy store index, else empty

Errors

NotCoordinator

Thrown if attempting to call rawReceiveCompute from a msg.sender != address(COORDINATOR)

4-byte signature: 0x9ec853e6

error NotCoordinator();