Delegator workflow
As a delegator, you define the task, fund its maximum reward, and choose the signed bid that becomes the on-chain agreement.
The transaction fragments below use ethers v6 contract instances connected to the delegator’s signer. Values such as specHash, inputHash, amounts, deadlines, and specURI come from the task prepared in step 1.
1. Commit the task
Section titled “1. Commit the task”Prepare the complete TaskSpec and task input off-chain. For STATS_V1:
- canonicalize the TaskSpec with RFC 8785 JCS, then compute
specHash = keccak256(JCS(taskSpec)); - encode the
uint64[]input withabi.encode, then computeinputHash = keccak256(abi.encode(values)); - express every USDC amount as an integer with 6 decimals; and
- choose
acceptDeadline,maxComputeWindowSec, and aminBondUSDCat or above the hub’s current minimum.
See TaskSpec commitments and STATS_V1 for the exact encodings.
2. Approve and create
Section titled “2. Approve and create”Approve the hub to transfer maxRewardUSDC, then create the task:
await (await usdc.approve(hubAddress, maxRewardUSDC)).wait();
const receipt = await ( await hub.createTask( specHash, statsV1VerifierId, inputHash, maxRewardUSDC, minBondUSDC, acceptDeadline, maxComputeWindowSec, specURI )).wait();Read TaskCreated from the receipt to obtain the taskId. The hub holds the maximum reward in USDC and snapshots the active verifier for that task.
3. Review signed bids
Section titled “3. Review signed bids”Receive bids off-chain and confirm each bid matches the created task:
taskId,specHash, andverifierIdmatch the on-chain task;rewardUSDC,bondUSDC, andcomputeWindowSecmatch the terms you want;validUntilis current; andnoncematchesbidNonce[delegatee].
The delegatee signs the exact EIP-712 bid. Review signed bids for the domain and field order.
4. Select one bid
Section titled “4. Select one bid”Encrypt the task key for the chosen delegatee and call:
await ( await hub.selectBid(taskId, bid, delegateeSignature, encryptedKey)).wait();Selection records the reward, bond, compute window, and fee snapshot. The hub immediately returns maxRewardUSDC - rewardUSDC to you and keeps the selected reward in escrow. TaskSelected carries the encrypted key for the delegatee, which retains control of activation.
5. Follow the on-chain result
Section titled “5. Follow the on-chain result”Watch the task and its lifecycle events:
TaskActivatedstarts the selected compute window after the delegatee posts the bond.TaskCompletedcarries the output commitment, completepublicValues, and output URI. A valid proof releases the selected reward, less the snapshotted fee, and returns the bond to the delegatee.TaskSelectionCancelledreturns a selected task toOPEN, ready for another valid bid within the task’s remaining terms.TaskTimedOutrecords the ACTIVE timeout path, which returns the reward and full bond to you.
Use proof binding to verify the completion payload and events and limits for the exact event fields.