Tasks

Tasks represent requests for jobs to be performed. Think of them like a transaction mixed with a block, a fee is proposed along with the data required to "mine" it, and miners receive the fees and potentially the task reward which is how the Arbius token comes into existence.

The Task model

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

Properties

  • Name
    model
    Type
    bytes32
    Description

    Model id

  • Name
    fee
    Type
    uint256
    Description

    Amount of fee offered for completion

  • Name
    owner
    Type
    address
    Description

    Which address is allowed to rescind the task (after delay)

  • Name
    blocktime
    Type
    uint64
    Description

    Unix timestamp of task registration.

  • Name
    version
    Type
    uint8
    Description

    Version, currently unused and always 0.

  • Name
    cid
    Type
    string
    Description

    IPFS CID for input request.


READEngine

Retrieve task

Look up a task 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 task = await engine.tasks(taskId);
const { model, fee, owner, blocktime, version, cid } = task;

WRITEEngine

Submit task

Submit a new task to be completed by others. Watch for SolutionSubmitted events to see when someone has provided a solution. Wait for longer to see for any ContestationSubmitted events to ensure it is valid. Once the MIN_CLAIM_SOLUTION_TIME has passed, you can be relatively certain the tasks solution is valid. For integration into smart contracts, consider a two part process to initiate the task then to later confirm the task has no (or failed) contestation. If a task has a valid contestation you will receive your fees back, so you can try again.

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 model = 'model id we are using';

// ensure this follows model template
const input = {
  prompt: "cat rocket ship"
};

const params = {
  version: 0,
  owner: wallet.address,
  model,
  fee: ethers.utils.parseEther('0.1'),
  input: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(JSON.stringify(input))),
}

const tx = await engine.submitTask(
  params.version,
  params.owner,
  params.model,
  params.fee,
  params.input,
)
const receipt = await tx.wait();

WRITEEngine

Retract task

Retract a given task. This should only be done if you set too low of a fee and no solver is willing to take it up. You will have to wait MIN_RETRACTION_WAIT time to be able to retract.

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 taskid = 'task id..';

const tx = await engine.retractTask(taskid)
const receipt = await tx.wait();