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.
Calls 8
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 safe-mode without deposit (privileged origin only).
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 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 safe-mode without deposit (privileged origin only).
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 safe-mode immediately (privileged origin only).
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();Slash a deposit from a safe-mode activator/extender (privileged origin only).
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | account: Account address (32 bytes, SS58-encoded) |
block | u32 | Integer | block: Block number |
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 a deposit from a past safe-mode activation/extension.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | account: Account address (32 bytes, SS58-encoded) |
block | u32 | Integer | block: Block number |
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 a deposit even during safe-mode (privileged origin only).
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | account: Account address (32 bytes, SS58-encoded) |
block | u32 | Integer | block: Block number |
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
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
| Name | Type | Format | Description |
|---|---|---|---|
until | u32 | Integer | Block number when safe-mode will auto-exit |
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);
}
});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
| Name | Type | Format | Description |
|---|---|---|---|
until | u32 | Integer | New block number when safe-mode will auto-exit |
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);
}
});Emitted when safe-mode ends, either by timeout or force.
When it fires
- Safe-mode was entered
Fields
| Name | Type | Format | Description |
|---|---|---|---|
reason | ExitReason | — | Exit reason: Timeout (natural expiry) or Force (governance) |
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);
}
});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
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | Account that placed the deposit |
amount | TaoBalance | — | 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 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);
}
});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
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | Account that received back the deposit |
amount | TaoBalance | — | 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);
}
});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
| Name | Type | Format | Description |
|---|---|---|---|
account | AccountId | SS58 Address | Account whose deposit was slashed |
amount | TaoBalance | — | Slashed 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 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);
}
});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);
}
});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 reserved by accounts for entering or extending safe-mode.
TaoBalance Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | AccountId | SS58 Address | — |
key2 | 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 Deposits storage
const key1 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const key2 = 0;
const result = await api.query.SafeMode.Deposits.getValue(key1, key2);
console.log("Deposits:", result);The block number until which safe-mode remains active.
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
TAO deposit required for permissionless safe-mode entry.
Option0x00import { 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);Duration in blocks for permissionless safe-mode entry.
u320import { 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);TAO deposit required for each permissionless safe-mode extension.
Option0x00import { 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);Duration in blocks added by each permissionless safe-mode extension.
u320import { 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);Blocks to wait after safe-mode ends before deposits can be released.
Option0x00import { 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
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
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
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
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
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
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
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