# Scheduler

### Calls

#### cancel

Cancel an anonymously scheduled task.

**Namespace**

```
api.tx.scheduler.cancel
```

**Type**

```typescript
function cancel(
  when: u32,
  index: u32
)
```

#### cancelNamed

Cancel a named scheduled task.

**Namespace**

```
api.tx.scheduler.cancelNamed
```

**Type**

```typescript
function cancelNamed(
  id: Bytes
)
```

#### schedule

Anonymously schedule a task.

**Namespace**

```
api.tx.scheduler.schedule
```

**Type**

```typescript
function schedule(
  when: u32,
  maybe_periodic: Option<(u32,u32)>,
  priority: u8,
  call: FrameSupportScheduleMaybeHashed
)
```

#### scheduleAfter

Anonymously schedule a task after a delay.

**Namespace**

```
api.tx.scheduler.scheduleAfter
```

**Type**

```typescript
function scheduleAfter(
  after: u32,
  maybe_periodic: Option<(u32,u32)>,
  priority: u8,
  call: FrameSupportScheduleMaybeHashed
)
```

#### scheduleNamed

Schedule a named task.

**Namespace**

```
api.tx.scheduler.scheduleNamed
```

**Type**

```typescript
function scheduleNamed(
  id: Bytes,
  when: u32,
  maybe_periodic: Option<(u32,u32)>,
  priority: u8,
  call: FrameSupportScheduleMaybeHashed
)
```

#### scheduleNamedAfter

Schedule a named task after a delay.

**Namespace**

```
api.tx.scheduler.scheduleNamedAfter
```

**Type**

```typescript
function scheduleNamedAfter(
  id: Bytes,
  after: u32,
  maybe_periodic: Option<(u32,u32)>,
  priority: u8,
  call: FrameSupportScheduleMaybeHashed
)
```

### Storage

#### agenda

Items to be executed, indexed by the block number that they should be executed on.

**Namespace**

```
api.query.scheduler.agenda
```

**Type**

```typescript
function agenda(
  u32
): Vec<Option<PalletSchedulerScheduledV3>>
```

#### lookup

Lookup from identity to the block number and index of the task.

**Namespace**

```
api.query.scheduler.lookup
```

**Type**

```typescript
function lookup(
  Bytes
): Option<(u32,u32)>
```

### Events

#### CallLookupFailed

The call for the provided hash was not found so the task has been aborted.

**Namespace**

```
api.events.scheduler.CallLookupFailed
```

**Type**

```typescript
type CallLookupFailed = {
  task: (u32,u32),
  id: Option<Bytes>,
  error: FrameSupportScheduleLookupError
}
```

#### Canceled

Canceled some task.

**Namespace**

```
api.events.scheduler.Canceled
```

**Type**

```typescript
type Canceled = {
  when: u32,
  index: u32
}
```

#### Dispatched

Dispatched some task.

**Namespace**

```
api.events.scheduler.Dispatched
```

**Type**

```typescript
type Dispatched = {
  task: (u32,u32),
  id: Option<Bytes>,
  result: Result<Null, SpRuntimeDispatchError>
}
```

#### Scheduled

Scheduled some task.

**Namespace**

```
api.events.scheduler.Scheduled
```

**Type**

```typescript
type Scheduled = {
  when: u32,
  index: u32
}
```

### Errors

#### FailedToSchedule

Failed to schedule a call

**Namespace**

```
api.errors.scheduler.FailedToSchedule
```

#### NotFound

Cannot find the scheduled call.

**Namespace**

```
api.errors.scheduler.NotFound
```

#### RescheduleNoChange

Reschedule failed because it does not change scheduled time.

**Namespace**

```
api.errors.scheduler.RescheduleNoChange
```

#### TargetBlockNumberInPast

Given target block number is in the past.

**Namespace**

```
api.errors.scheduler.TargetBlockNumberInPast
```

### Constants

#### maximumWeight

The maximum weight that may be scheduled per block for any dispatchables of less priority than `schedule::HARD_DEADLINE`.

**Namespace**

```
api.consts.scheduler.maximumWeight
```

**Type**

```typescript
type maximumWeight = WeightV1
```

#### maxScheduledPerBlock

The maximum number of scheduled calls in the queue for a single block. Not strictly enforced, but used for weight estimation.

**Namespace**

```
api.consts.scheduler.maxScheduledPerBlock
```

**Type**

```typescript
type maxScheduledPerBlock = u32
```
