Infernet
SDK
Introduction

Infernet SDK

The Infernet SDK is a set of smart contracts that let users subscribe to outputs from off-chain compute workloads. Developers can inherit one of two simple interfaces, CallbackConsumer or SubscriptionConsumer in their smart contracts, and consume one-time or recurring computation.

The SDK closely resembles, and will come as second nature to those familiar with, common data callback systems. Smart contracts can request compute on- or off-chain (via EIP-712 signed subscriptions), and receive a callback from an Infernet Node when their compute workload has been processed and a response generated.

As the name implies, one of the primary use-cases for the SDK is to bring Machine Learning inference, on-chain. Developers can use Infernet to delegate computationally-intensive operations like ML-inference or ZK-proving workloads off-chain, consuming outputs and optional proofs in their smart contracts via on-chain callback. In this way, we primitively circumvent the limitations of common Blockchain smart contract execution environments.

🙋‍♂️

James is writing a Governor contract for his DAO. He wants all proposals to be run through his automated risk model when created, with a quantiatative risk score posted on-chain. Via Infernet, James can kickoff a request to run his risk model, with on-chain parameters like the proposal details as inputs, and receive both a risk score output and succinct proof of execution on-chain.

🙋‍♀️

Emily is developing a new NFT collection that lets minters automatically add new traits to their NFTs by posting what they'd like in plaintext (think, "an Infernet-green hoodie"). Via Infernet, Emily can kickoff an off-chain Stable Diffusion workload that parses her NFT's Base64 image, adds new traits read from on-chain, and returns a new image that can be updated directly in her smart contract.

Simple, yet flexible

Today, Infernet supports:

  • Any arbitrary compute workload (see: Ritual ML Workflows for details)
  • On-chain compute request origination via the Coordinator
  • Off-chain compute request origination, fulfilled on-chain, via the EIP712Coordinator
  • Compute workloads that track their input and generate output and a succinct ZK proof
  • One-time requests (receive callback response) via CallbackConsumer
  • Recurring requests (subscriptions with versatile parameterization) via SubscriptionConsumer
  • Exposing dynamic input parameters or model features on-chain via getContainerInputs()

And much more accessible to developers with less than 20 lines of Solidity code to import and implement.

Install the SDK

You can install the Infernet SDK directly as a dependency in your smart contract project.

If you are starting a new project or have yet to choose a Solidity development framework, we recommend using Foundry: forge (opens in a new tab) so that you can make the most of our mock testing fixtures and helper utilities.

To install via Foundry: forge (opens in a new tab):

forge install ritual-net/infernet

It is also recommended to update your remappings.txt to simplify useful imports:

infernet/core=lib/infernet/contracts/src
infernet/tests=lib/infernet/contracts/test

Deployed contracts

For reference, the Infernet SDK's EIP712Coordinator is deployed to the following networks:

NetworkCoordinator Address
Ethereum Mainnet (opens in a new tab)0xa612fca4652ef94ae3d0e0aefedb1932c5f1b61d (opens in a new tab)
Base (opens in a new tab)0x8D871Ef2826ac9001fB2e33fDD6379b6aaBF449c (opens in a new tab)

Next steps

Once ready, you may choose to: