Solutions
Solutions represent proposed solutions to tasks
The Solution model
The Solution model contains everything needed to verify a solution
Properties
- Name
validator
- Type
- address
- required
- Defaults to
- Description
Validator that provided solution
- Name
blocktime
- Type
- uint64
- required
- Defaults to
- Description
Unix timestamp of solution submission.
- Name
claimed
- Type
- boolean
- required
- Defaults to
- Description
Has fee and reward been claimed?
- Name
cid
- Type
- string
- required
- Defaults to
- Description
IPFS CID for solution response. Unix timestamp of task registration.
Retrieve solution
Look up a solution given a taskid
.
Request
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 solution = await engine.solutions(taskId);
const { validator, blocktime, claimed, cid } = solution;
Submit solution
Solutions can be submitted in order to gain the task fee. They may also grant task rewards if the model is enabled to receive them.
Solutions must first be committed to before submitting solution. This must happen in a prior block to the actual submission. This requirement exists so that your submission cannot be frontrun.
Commitments can be calculated with keccak256(abi.encode(address, taskid, cid))
.
Ensure when you are submitting a solution it is correct, if it is not you will be slashed.
Request
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 we are solving'
const cid = 'ipfs hash of solution'
const commitment = await engine.generateCommitment(
wallet.address,
taskid,
cid,
);
await (await engine.signalCommitment(commitment)).wait();
const tx = await engine.submitSolution(taskid, cid)
const receipt = await tx.wait();
Claim solution
After MIN_CLAIM_SOLUTION_TIME
if there have been no contestations you can claim any fees paid for the task, after the models fees have been subtracted. If the model is mineable you will also receive Arbius task reward.
Request
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 to claim'
const tx = await engine.claimSolution(taskid);
const receipt = await tx.wait();