Task Manager Interface
The ITaskManager
interface provides the core functionality for scheduling and managing automated task execution on the Monad blockchain.
Functions
scheduleTask
function scheduleTask(
address implementation,
uint256 taskGasLimit,
uint64 targetBlock,
uint256 maxPayment,
bytes calldata taskCallData
) external payable returns (bool scheduled, uint256 executionCost, bytes32 taskId);
Schedule a task for future execution. Requires sufficient shMONAD bonded to cover execution costs.
Parameters
Name | Type | Description |
---|---|---|
implementation | address | The contract address that is delegatecalled |
taskGasLimit | uint256 | The gas limit of the task's execution |
targetBlock | uint64 | The desired block number for task execution |
maxPayment | uint256 | Maximum payment willing to pay for execution |
taskCallData | bytes | The encoded function call data for the task |
Return Values
Name | Type | Description |
---|---|---|
scheduled | bool | Whether the task was successfully scheduled |
executionCost | uint256 | The estimated cost of the task |
taskId | bytes32 | Unique identifier for tracking the scheduled task |
rescheduleTask
function rescheduleTask(
uint64 targetBlock,
uint256 maxPayment
) external payable returns (bool rescheduled, uint256 executionCost, bytes32 taskId);
Reschedule the currently executing task.
Parameters
Name | Type | Description |
---|---|---|
targetBlock | uint64 | The block to reschedule to |
maxPayment | uint256 | Maximum payment willing to pay for execution |
Return Values
Name | Type | Description |
---|---|---|
rescheduled | bool | Whether the task was successfully rescheduled |
executionCost | uint256 | The new estimated cost |
taskId | bytes32 | ID of the rescheduled task |
executeTasks
function executeTasks(
address payoutAddress,
uint256 targetGasReserve
) external returns (uint256 feesEarned);
Execute queued tasks up to the target gas reserve.
Parameters
Name | Type | Description |
---|---|---|
payoutAddress | address | The beneficiary of any payouts |
targetGasReserve | uint256 | Amount of gas to reserve for after execution |
Return Value
Type | Description |
---|---|
uint256 | Amount of fees earned from execution |
cancelTask
function cancelTask(bytes32 taskId) external;
Cancel a scheduled task.
Parameters
Name | Type | Description |
---|---|---|
taskId | bytes32 | The id of the task to cancel |
Task Status Functions
function isTaskCancelled(bytes32 taskId) external view returns (bool cancelled);
function isTaskExecuted(bytes32 taskId) external view returns (bool executed);
Query task status.
Parameters
Name | Type | Description |
---|---|---|
taskId | bytes32 | The id of the task to query |
Return Value
Type | Description |
---|---|
bool | Status of the task (cancelled/executed) |
estimateCost
function estimateCost(
uint64 targetBlock,
uint256 taskGasLimit
) external view returns (uint256 cost);
Estimate the cost of executing a task.
Parameters
Name | Type | Description |
---|---|---|
targetBlock | uint64 | The block to schedule the task for |
taskGasLimit | uint256 | The gas limit of the task's execution |
Return Value
Type | Description |
---|---|
uint256 | The estimated cost of the task |
getTaskMetadata
function getTaskMetadata(
bytes32 taskId
) external view returns (TaskMetadata memory);
Get metadata about a task.
Parameters
Name | Type | Description |
---|---|---|
taskId | bytes32 | ID of the task to query |
Return Value
Type | Description |
---|---|
TaskMetadata | Task metadata including owner and status information |
Authorization Management Functions
function addTaskCanceller(bytes32 taskId, address canceller) external;
function removeTaskCanceller(bytes32 taskId, address canceller) external;
function addEnvironmentCanceller(bytes32 taskId, address canceller) external;
function removeEnvironmentCanceller(bytes32 taskId, address canceller) external;
Manage task and environment cancellation authorizations.
Parameters
Name | Type | Description |
---|---|---|
taskId | bytes32 | The task ID for authorization |
canceller | address | The address to authorize/deauthorize |
Task Management
cancelTask
Cancel a scheduled task.
function cancelTask(bytes32 taskId) external;
Parameters:
taskId
: The id of the task to cancel
Task Status Queries
function isTaskCancelled(bytes32 taskId) external view returns (bool cancelled);
function isTaskExecuted(bytes32 taskId) external view returns (bool executed);
These functions check the status of a task:
isTaskCancelled
: Returns whether a task has been cancelledisTaskExecuted
: Returns whether a task has been executed
Cost Estimation
function estimateCost(
uint64 targetBlock,
uint256 taskGasLimit
) external view returns (uint256 cost);
Parameters:
targetBlock
: The block to schedule the task fortaskGasLimit
: The gas limit of the task's execution
Returns:
cost
: The estimated cost of the task
Task Metadata
getTaskMetadata
Get metadata about a task.
function getTaskMetadata(
bytes32 taskId
) external view returns (TaskMetadata memory);
Parameters:
taskId
: ID of the task to query
Returns:
- Task metadata including owner and status information
Block Range Query
function getNextExecutionBlockInRange(
uint64 startBlock,
uint64 endBlock
) external view returns (uint64);
Parameters:
startBlock
: Start block (inclusive)endBlock
: End block (inclusive)
Returns:
- The earliest block number with tasks, or 0 if none found
Authorization Management
Task-Specific Authorization
function addTaskCanceller(bytes32 taskId, address canceller) external;
function removeTaskCanceller(bytes32 taskId, address canceller) external;
Manage addresses authorized to cancel specific tasks:
addTaskCanceller
: Add a canceller for a specific taskremoveTaskCanceller
: Remove a canceller from a specific task
Environment-Wide Authorization
function addEnvironmentCanceller(bytes32 taskId, address canceller) external;
function removeEnvironmentCanceller(bytes32 taskId, address canceller) external;
Manage addresses authorized to cancel all tasks for an environment:
addEnvironmentCanceller
: Add a canceller for all tasks in an environmentremoveEnvironmentCanceller
: Remove a canceller from an environment
Notes:
- The
taskId
parameter is used to verify ownership and identify the environment - Only the task owner can manage cancellers