> For the complete documentation index, see [llms.txt](https://web3task.gitbook.io/web3task/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://web3task.gitbook.io/web3task/contracts/tasksmanager.md).

# TasksManager

The main contract that manages the tasks.

### TaskCannotBeChanged

```solidity
error TaskCannotBeChanged(uint256 taskId, enum IWeb3Task.Status status)
```

*Emitted when a task cannot be changed.*

### TitleUpdated

```solidity
event TitleUpdated(uint256 taskId, string title)
```

*Emitted when a title is updated.*

### DescriptionUpdated

```solidity
event DescriptionUpdated(uint256 taskId, string description)
```

*Emitted when a description is updated.*

### EndDateUpdated

```solidity
event EndDateUpdated(uint256 taskId, uint256 endDate)
```

*Emitted when an end date is updated.*

### MetadataUpdated

```solidity
event MetadataUpdated(uint256 taskId, string metadata)
```

*Emitted when metadata is updated.*

### setTitle

```solidity
function setTitle(uint256 _taskId, string _title) public virtual
```

This function sets a new `title` for a task.

Emits a {TitleUpdated} event.

### setDescription

```solidity
function setDescription(uint256 _taskId, string _description) public virtual
```

This function sets a new `description` for a task.

Emits a {DescriptionUpdated} event.

### setEndDate

```solidity
function setEndDate(uint256 _taskId, uint256 _endDate) public virtual
```

This function sets a new `endDate` for a task.

Emits an {EndDateUpdated} event.

### setMetadata

```solidity
function setMetadata(uint256 _taskId, string _metadata) public virtual
```

This function sets a new `metadata` for a task.

Emits a {MetadataUpdated} event.

{% hint style="info" %}
**NOTE**

This function is not restricted by the task status. It can be called at any time by the authorized operators.\_
{% endhint %}

### validateTask

```solidity
function validateTask(uint256 _taskId) internal view
```

This function checks if a task can be changed.

Requirements:

* `_taskId` must be a valid task id withing the right timestamp.
* `task.status` must not be `Status.Completed` or `Status.Canceled`.
* `msg.sender` must be an authorized operator (see {AccessControl}).

***

### TasksManager Summarize

The`TasksManager` smart contract inherits from `AccessControl`, `Web3Task`, and `Multicall` contracts. This contract is designed to manage tasks and provides functions to update task details.&#x20;

* **Task Updates**: The contract provides functions to update the title, description, end date, and metadata of a task. Each function first validates the task using the `validateTask` function, then updates the corresponding attribute and emits an event.
* **Task Validation**: The function `validateTask(uint256 _taskId)` checks if a task can be changed. It first retrieves the task using the provided task ID. If the task's status is `Completed` or, it reverts with an `TaskCannotBeChanged` error. If the sender is not an authorized operator for the task's creator role, it reverts with an `Unauthorized` error.
* **Events**: The contract emits several events when a task's details are updated. These include `TitleUpdated`, `DescriptionUpdated`, `EndDateUpdated`, and `MetadataUpdated`. Each event includes the task ID and the new value of the updated attribute.

This contract is designed to be used as a base contract for the other contracts that need to manage tasks. It provides a simple and efficient way to update task details, and it ensures that only authorized users can perform these updates.
