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.
The SDK also offers out-of-the-box rails to handle payments (between compute consumers and nodes), asynchronous callback consumption, common developer patterns (for example, node allowlists), and more.
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.
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-sdk
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 Registry
entrypoint contract is deployed to the following networks:
v1.0.0
release (latest)
v0.1.0
release
Next steps
Once ready, you may choose to:
- Follow an introductory quick start implementing a consumer, if less familiar with common callback patterns
- Read in-depth about the SDK architecture to better understand what's possible with Infernet
- Or, dive right into the deep end with the developer reference