All pallets

SafeMode docs

Look up any call, event, or storage item with code examples. Runtime v472 · Block #9,197,056

Developer documentation for the SafeMode pallet of the Subtensor blockchain, part of the Bittensor decentralized AI network. This page is designed for developers integrating with the chain: look up any call, event, or storage item, copy code examples in TypeScript, Python, or Rust, and filter by your role. For in-depth explanations, version history, and relationships between items, see the Reference section.

SafeMode

Enter safe-mode permissionlessly for [`Config::EnterDuration`] blocks.

Index: 20 30 items

Calls 8

enter

call details

Enter safe-mode permissionlessly by reserving a deposit.

import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build enter call (no parameters)
const tx = api.tx.SafeMode.enter();

force_enter

call details

Force-enter safe-mode without deposit (privileged origin only).

Emits: Entered
Modifies: EnteredUntil
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build force_enter call (no parameters)
const tx = api.tx.SafeMode.force_enter();

extend

call details

Extend safe-mode duration permissionlessly by reserving a deposit.

import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build extend call (no parameters)
const tx = api.tx.SafeMode.extend();

force_extend

call details

Force-extend safe-mode without deposit (privileged origin only).

Emits: Extended
Modifies: EnteredUntil
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build force_extend call (no parameters)
const tx = api.tx.SafeMode.force_extend();

force_exit

call details

Force-exit safe-mode immediately (privileged origin only).

Emits: Exited
Modifies: EnteredUntil
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build force_exit call (no parameters)
const tx = api.tx.SafeMode.force_exit();

force_slash_deposit

call details

Slash a deposit from a safe-mode activator/extender (privileged origin only).

Parameters

NameTypeFormatDescription
accountAccountIdSS58 Addressaccount: Account address (32 bytes, SS58-encoded)
blocku32Integerblock: Block number
Modifies: Deposits
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build force_slash_deposit call (typed, named args)
const account = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const block = 0;

const tx = api.tx.SafeMode.force_slash_deposit({
  account,
  block,
});

release_deposit

call details

Release a deposit from a past safe-mode activation/extension.

Parameters

NameTypeFormatDescription
accountAccountIdSS58 Addressaccount: Account address (32 bytes, SS58-encoded)
blocku32Integerblock: Block number
Modifies: Deposits
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build release_deposit call (typed, named args)
const account = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const block = 0;

const tx = api.tx.SafeMode.release_deposit({
  account,
  block,
});

force_release_deposit

call details

Force-release a deposit even during safe-mode (privileged origin only).

Parameters

NameTypeFormatDescription
accountAccountIdSS58 Addressaccount: Account address (32 bytes, SS58-encoded)
blocku32Integerblock: Block number
Modifies: Deposits
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build force_release_deposit call (typed, named args)
const account = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const block = 0;

const tx = api.tx.SafeMode.force_release_deposit({
  account,
  block,
});

Events 8

Entered

event details

Emitted when safe-mode is entered, pausing certain network operations.

When it fires

  • Safe-mode was not already entered
  • Either: caller provided deposit (permissionless) or caller is ForceEnterOrigin

Fields

NameTypeFormatDescription
untilu32IntegerBlock number when safe-mode will auto-exit
Emitted by: enter/ force_enter
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to Entered events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.Entered.get(block.hash);
  for (const evt of events) {
    console.log("Entered:", evt.payload);
  }
});

Extended

event details

Emitted when safe-mode duration is extended.

When it fires

  • Safe-mode is currently entered
  • Either: caller provided extend deposit or caller is ForceExtendOrigin

Fields

NameTypeFormatDescription
untilu32IntegerNew block number when safe-mode will auto-exit
Emitted by: extend/ force_extend
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to Extended events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.Extended.get(block.hash);
  for (const evt of events) {
    console.log("Extended:", evt.payload);
  }
});

Exited

event details

Emitted when safe-mode ends, either by timeout or force.

When it fires

  • Safe-mode was entered

Fields

NameTypeFormatDescription
reasonExitReason—Exit reason: Timeout (natural expiry) or Force (governance)
Emitted by: force_exit
Modifies: EnteredUntil
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to Exited events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.Exited.get(block.hash);
  for (const evt of events) {
    console.log("Exited:", evt.payload);
  }
});

DepositPlaced

event details

Emitted when an account reserves funds for entering or extending safe-mode.

When it fires

  • Account has sufficient free balance
  • Permissionless entry/extend is configured

Fields

NameTypeFormatDescription
accountAccountIdSS58 AddressAccount that placed the deposit
amountTaoBalance—Deposit amount (RAO)
Emitted by: enter/ extend
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to DepositPlaced events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.DepositPlaced.get(block.hash);
  for (const evt of events) {
    console.log("DepositPlaced:", evt.payload);
  }
});

DepositReleased

event details

Emitted when a reserved deposit is returned to its owner.

When it fires

  • Account has a deposit at the specified block
  • Either: ReleaseDelay passed (normal) or ForceDepositOrigin called force_release

Fields

NameTypeFormatDescription
accountAccountIdSS58 AddressAccount that received back the deposit
amountTaoBalance—Released deposit amount (RAO)
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to DepositReleased events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.DepositReleased.get(block.hash);
  for (const evt of events) {
    console.log("DepositReleased:", evt.payload);
  }
});

DepositSlashed

event details

Emitted when a deposit is slashed (not returned) due to abuse.

When it fires

  • Account has a deposit at the specified block
  • ForceDepositOrigin authorized slash

Fields

NameTypeFormatDescription
accountAccountIdSS58 AddressAccount whose deposit was slashed
amountTaoBalance—Slashed deposit amount (RAO)
Modifies: Deposits
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to DepositSlashed events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.DepositSlashed.get(block.hash);
  for (const evt of events) {
    console.log("DepositSlashed:", evt.payload);
  }
});

CannotDeposit

event details

Emitted when deposit reservation fails during safe-mode entry/extend.

When it fires

  • Account attempted permissionless entry/extend
  • Currency operation failed
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to CannotDeposit events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.CannotDeposit.get(block.hash);
  for (const evt of events) {
    console.log("CannotDeposit:", evt.payload);
  }
});

CannotRelease

event details

Emitted when deposit release fails.

When it fires

  • Release was attempted
  • Currency operation failed
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Subscribe to CannotRelease events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SafeMode.CannotRelease.get(block.hash);
  for (const evt of events) {
    console.log("CannotRelease:", evt.payload);
  }
});

Storage 2

Deposits

storage details

Deposits reserved by accounts for entering or extending safe-mode.

Modifier: Optional Keys: 2 Returns: TaoBalance

Keys

NameTypeFormatDescription
key1AccountIdSS58 Address—
key2u32Integer—
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query Deposits storage
const key1 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const key2 = 0;

const result = await api.query.SafeMode.Deposits.getValue(key1, key2);
console.log("Deposits:", result);

EnteredUntil

storage details

The block number until which safe-mode remains active.

Modifier: Optional Keys: 0 Returns: u32 (Integer)
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query EnteredUntil storage (no keys - plain value)
const result = await api.query.SafeMode.EnteredUntil.getValue();
console.log("EnteredUntil:", result);

Constants 5

EnterDepositAmount

constant details

TAO deposit required for permissionless safe-mode entry.

Type: Option
Value (hex): 0x00
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query EnterDepositAmount constant
const value = await api.constants.SafeMode.EnterDepositAmount();
console.log("EnterDepositAmount:", value);

EnterDuration

constant details

Duration in blocks for permissionless safe-mode entry.

Type: u32
Value: 0
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query EnterDuration constant
const value = await api.constants.SafeMode.EnterDuration();
console.log("EnterDuration:", value);

ExtendDepositAmount

constant details

TAO deposit required for each permissionless safe-mode extension.

Type: Option
Value (hex): 0x00
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query ExtendDepositAmount constant
const value = await api.constants.SafeMode.ExtendDepositAmount();
console.log("ExtendDepositAmount:", value);

ExtendDuration

constant details

Duration in blocks added by each permissionless safe-mode extension.

Type: u32
Value: 0
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query ExtendDuration constant
const value = await api.constants.SafeMode.ExtendDuration();
console.log("ExtendDuration:", value);

ReleaseDelay

constant details

Blocks to wait after safe-mode ends before deposits can be released.

Type: Option
Value (hex): 0x00
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query ReleaseDelay constant
const value = await api.constants.SafeMode.ReleaseDelay();
console.log("ReleaseDelay:", value);

Errors 7

Entered

error details #0

Safe-mode is already active. You cannot enter again.

Common Causes

  • Trying to call enter() when safe-mode was already activated
  • Previous safe-mode activation hasn't expired yet
  • Another account already entered safe-mode

How to Fix

Query EnteredUntil to check safe-mode status,Wait for safe-mode to end, or call extend() if you want to prolong it,If you need to exit early, governance can call force_exit

Exited

error details #1

Safe-mode is not currently active. The operation requires safe-mode.

Common Causes

  • Trying to extend() when safe-mode isn't active
  • Trying to force_exit() when safe-mode already ended
  • Safe-mode auto-expired (passed EnteredUntil block)

How to Fix

Query EnteredUntil to confirm safe-mode status,If you need safe-mode, call enter() to activate it,Check if safe-mode auto-expired and needs re-entry

NotConfigured

error details #2

The safe-mode functionality you're trying to use is disabled.

Common Causes

  • EnterDepositAmount is None (permissionless entry disabled)
  • ExtendDepositAmount is None (permissionless extension disabled)
  • ReleaseDelay is None (permissionless release disabled)

How to Fix

Check constant configuration for the operation you're attempting,Use force_ variants if you have governance privileges,Contact governance to enable the functionality if needed

NoDeposit

error details #3

No deposit found for the specified account and block.

Common Causes

  • Wrong account address in release_deposit call
  • Wrong block number in release_deposit call
  • Deposit was already released or slashed

How to Fix

Query Deposits(account, block) to verify deposit exists,Check the exact block number when the deposit was made,Verify you're using the correct account address

AlreadyDeposited

error details #4

This account already has a deposit at this block number.

Common Causes

  • Attempting to enter/extend twice in the same block
  • Transaction was included multiple times

How to Fix

Wait for a new block before making another deposit,Check if your previous transaction was already included

CannotReleaseYet

error details #5

ReleaseDelay hasn't passed since safe-mode ended.

Common Causes

  • Calling release_deposit too soon after safe-mode ended
  • Safe-mode hasn't ended yet
  • Not accounting for ReleaseDelay constant

How to Fix

Check current block vs (safe-mode end block + ReleaseDelay),Wait for ReleaseDelay more blocks,Use force_release_deposit if you have governance privileges

CurrencyError

error details #6

The underlying currency operation failed.

Common Causes

  • Insufficient balance for deposit
  • Balance is locked and can't be reserved
  • Currency pallet returned an unexpected error

How to Fix

Check free balance vs deposit amount,Verify no other locks on your balance,Check Balances.Account for detailed balance breakdown