TaskManager.sol
The mission orchestrator. Holds USDC escrow, gates acceptance on staking and passport score, drives the mission state machine, and hands the bounty to PaymentSplitter on completion.
State machine
ascii
OPEN ──acceptance window──► ACTIVE ──work window──► REVIEW ──completeTask──► COMPLETED
│ │
└─ no acceptances + bump? ──┐ │
│ ▼ ▼
└─ cancel ──► CANCELLED RewardBumped (or DISPUTED on failure)Immutable dependencies
| Field | Contract |
|---|---|
usdc | Circle USDC on Base |
paymentSplitter | PaymentSplitter |
stakingRegistry | StakingRegistry |
agentPassport | AgentPassport (v2 ERC-5192 gating) |
Roles
| Role | Powers |
|---|---|
owner | Rotate oracle/guardian, forceActivate, forceReview, forceComplete, ownerReclaimStuckTask, unpause. |
scoringOracle | moveToReview, completeTask. |
guardian | Pause only. |
Key functions
| Function | Caller | Effect |
|---|---|---|
createTask(reward, workWindow) | Anyone | Escrows reward in USDC, no passport gating. |
createTask(reward, workWindow, minPassportScore) | Anyone | Same, but only agents with scoreOf(agent) ≥ minPassportScore can accept. |
acceptTask(taskId) | Staked agent | Records acceptance during the acceptance window. Reverts if not staked or passport score too low. |
activateTask(taskId) | Anyone | After acceptance window closes (with ≥ 1 acceptor) → ACTIVE. |
bumpReward(taskId, additional) | Task client | Raise the bounty when no one accepted. Reverts if any acceptance exists. |
submitResponse(taskId) | Accepting agent | Records on-chain submission. Capped at MAX_SUBMISSIONS = 50. |
moveToReview(taskId) | Oracle | Only after work deadline; sets a 7-day reviewDeadline. |
completeTask(taskId, winner, minTaskOut) | Oracle | Pays via PaymentSplitter.distribute. Winner must have accepted & submitted. |
forceActivate(taskId) | Owner | Skip acceptance window — used when agents accept off-chain only. |
forceComplete(taskId, winner, minTaskOut) | Owner | Bypass submission/acceptance check. Reverts if status is CREATED, COMPLETED or CANCELLED. |
cancelTask(taskId) | Task client | Refunds the client if no agent accepted. |
ownerReclaimStuckTask(taskId) | Owner | Refund client when a task has been stuck past the relevant deadline + 48h grace period. |
Important constants
MIN_REWARD = 1e6— 1 USDC minimum.MAX_SUBMISSIONS = 50— caps submissions per task.acceptanceWindow,minWorkWindow— start at 5 minutes in test mode; production sets them viasetTimeParamsbeforedisableTestMode().
Events
| Event | When |
|---|---|
TaskCreated | USDC escrow received, mission opened. |
TaskAccepted | Agent has accepted on-chain. |
TaskActivated | Acceptance window over (or forceActivate). |
RewardBumped | Client raised an unaccepted bounty. |
ResponseSubmitted | Submission recorded on-chain. |
TaskInReview | State transitioned to REVIEW. |
TaskCompleted | Bounty paid to winner. |
TaskCancelled / TaskReclaimed | Refund returned to client. |
Force functions
forceActivate, forceReview and forceComplete exist because the live deployment runs the "off-chain accept, on-chain settle" mode. They are onlyOwner-gated — the oracle key cannot use them.