Infernet
SDK
Reference
Consumers
SubscriptionConsumer

SubscriptionConsumer

Git Source (opens in a new tab)

Inherits: BaseConsumer

Allows creating recurring subscriptions for off-chain container compute

Inherits BaseConsumer to inherit functions to receive container compute responses and emit container inputs

Functions

constructor

Initialize new SubscriptionConsumer

constructor(address registry) BaseConsumer(registry);

Parameters

NameTypeDescription
registryaddressregistry address

_createComputeSubscription

Creates a recurring request for off-chain container compute via callback response

function _createComputeSubscription(
    string memory containerId,
    uint32 frequency,
    uint32 period,
    uint16 redundancy,
    bool lazy,
    address paymentToken,
    uint256 paymentAmount,
    address wallet,
    address verifier
) internal returns (uint32);

Parameters

NameTypeDescription
containerIdstringcompute container identifier(s) used by off-chain Infernet node
frequencyuint32max number of times to process subscription (i.e, frequency == 1 is a one-time request)
perioduint32period, in seconds, at which to progress each responding interval
redundancyuint16number of unique responding Infernet nodes
lazyboolwhether to lazily store subscription responses in Inbox
paymentTokenaddressIf providing payment for compute, payment token address (address(0) for ETH, else ERC20 contract address)
paymentAmountuint256If providing payment for compute, payment in paymentToken per compute request fulfillment
walletaddressIf providing payment for compute, Infernet Wallet address; this contract must be approved spender of Wallet
verifieraddressoptional verifier contract to restrict payment based on response proof verification

Returns

NameTypeDescription
<none>uint32subscription ID of newly-created subscription

_cancelComputeSubscription

Cancels a created subscription

Can only cancel owned subscriptions (address(this) == Coordinator.subscriptions[subscriptionId].owner)

function _cancelComputeSubscription(uint32 subscriptionId) internal;

Parameters

NameTypeDescription
subscriptionIduint32ID of subscription to cancel