Models

Models represent Machine Learning models.

The Model model

The Model model contains all the information about the Model, such as its fees, information on how to run it, and whether or not it grants tasks rewards.

Properties

  • Name
    fee
    Type
    uint256
    Description

    Flat fee imposed on each task using this model.

  • Name
    addr
    Type
    address
    Description

    Address the model receives fees to.

  • Name
    rate
    Type
    uint256
    Description

    Multiplier for reward generation. 0 means not mineable. 1e18 means 1x.

  • Name
    cid
    Type
    string
    Description

    CID containing template schema.


READEngine

Retrieve model

Look up a model based on its ID.

Request

CALL
Engine
import { ethers } from 'ethers'
import Config from './config.json'
import EngineArtifact from './artifacts/EngineV1.sol/EngineV1.json';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);

const engine = new ethers.Contract(
  Config.engineAddress,
  EngineArtifact.abi,
  provider,
)

const modelid = 'model id to look up';
const model = await engine.models(modelid);
const { fee, addr, rate, cid } = model;

WRITEEngine

Register model

Register a new model with Arbius. This allows other validators know it is available, and makes it available for task creators to specify. You can provide a smart contract address as the parameter for addr to build tokenized models, or just have fees go to a regular address. Fee can be 0 if you would like it to be free to use. All fees are in Arbius tokens.

Ensure your cid parameter points to a valid schema.

It is highly recommended to read the guide Adding Models before attempting to register a model.

Request

WRITE
Engine
import { ethers } from 'ethers'
import Config from './config.json'
import EngineArtifact from './artifacts/EngineV1.sol/EngineV1.json';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);

const wallet = new ethers.Wallet(
  process.env.PRIVATE_KEY,
  provider,
);

const engine = new ethers.Contract(
  Config.engineAddress,
  EngineArtifact.abi,
  wallet,
)

const params = {
  addr: wallet.address,
  fee: ethers.utils.parseEther('0.1'),
  template: {},
}

const tx = await engine.registerModel(
  params.addr,
  params.fee,
  ethers.utils.hexlify(ethers.utils.toUtf8Bytes(params.template)),
)
const receipt = await tx.wait();