title: Tasks API - A general system for recognizing and executing service work doc: - audience: Runtime Dev description: | The Tasks API allows you to define some service work that can be recognized by a script or an off-chain worker. Such a script can then create and submit all such work items at any given time. `#[pallet:tasks_experimental]` provides a convenient way to define such work items. It can be attached to an `impl` block inside a pallet, whose functions can then be annotated by the following attributes: 1. `#[pallet::task_list]`: Define an iterator over the available work items for a task 2. `#[pallet::task_condition]`: Define the conditions for a given work item to be valid 3. `#[pallet::task_weight]`: Define the weight of a given work item 4. `#[pallet::task_index]`: Define the index of a given work item Each such function becomes a variant of the autogenerated enum `Task` for this pallet. All such enums are aggregated into a `RuntimeTask` by `construct_runtime`. An example pallet that uses the Tasks API is available at `substrate/frame/example/tasks`. migrations: db: [] runtime: [] crates: - name: frame-system - name: frame-support - name: frame-support-procedural - name: pallet-example-tasks host_functions: []