# set-perpetual-lock (/docs/tx/set-perpetual-lock)

Switches how the signing coldkey's stake lock on the subnet behaves over
time: perpetual mode keeps the lock (and its conviction) in force
indefinitely, while decaying mode lets it wind down over time so the
stake eventually becomes liquid again. A per-coldkey, per-subnet setting
that moves no funds by itself — it changes the behavior of locks created
with `lock_stake`. Enabling perpetual mode means the locked stake stays
illiquid until you switch back to decaying and the lock runs off.

| Signer    | Origin                                 | Pallet          | Wraps                                                                                                |
| --------- | -------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------- |
| `coldkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.set_perpetual_lock`](/code/pallets/subtensor/src/macros/dispatches.rs#L2296-L2305) |

## Parameters [#parameters]

| Parameter | Type    | Required | Description                                                           |
| --------- | ------- | -------- | --------------------------------------------------------------------- |
| `netuid`  | integer | yes      | Subnet whose lock mode is changed.                                    |
| `enabled` | boolean | yes      | True for perpetual mode (lock never decays), false for decaying mode. |

Address parameters (`--hotkey`, `--coldkey`, `--dest`, ...) accept a raw ss58
address, an address-book or proxy-book name, or a local wallet/hotkey name.

## CLI [#cli]

Preview with `--dry-run` (shows fee, effects, and policy result without
submitting), then submit:

```bash
btcli tx set-perpetual-lock \
  --netuid <int> \
  --enabled/--no-enabled --dry-run
btcli tx set-perpetual-lock \
  --netuid <int> \
  --enabled/--no-enabled -w my_coldkey
```

## Python [#python]

```python
import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.SetPerpetualLock(netuid=1, enabled=True)

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)
```

(`bt.Subtensor` is also the async client — `async with bt.Subtensor() as client:`
— see [The client](/docs/concepts/client).) Or build the intent by op name, as
an agent would:

```python
result = sub.execute_tool("set_perpetual_lock", {...}, wallet)
```

## On-chain implementation [#on-chain-implementation]

`SubtensorModule.set_perpetual_lock` — [`pallets/subtensor/src/macros/dispatches.rs#L2298`](/code/pallets/subtensor/src/macros/dispatches.rs#L2296-L2305):

```rust
#[pallet::call_index(138)]
#[pallet::weight(<T as Config>::WeightInfo::set_perpetual_lock())]
pub fn set_perpetual_lock(
    origin: OriginFor<T>,
    netuid: NetUid,
    enabled: bool,
) -> DispatchResult {
    let coldkey = ensure_signed(origin)?;
    Self::do_set_perpetual_lock(&coldkey, netuid, enabled)
}
```

Delegates to [`do_set_perpetual_lock`](/code/pallets/subtensor/src/staking/lock.rs#L655).

Every file is browsable under [/code](/code) exactly as built into the runtime, or as plain text under `/code/raw/<path>` (index: [`/code/index.json`](/code/index.json)).
