# set-mech-weight-delegate (/docs/tx/set-mech-weight-delegate)

Signed by the registered validator hotkey. The delegate may submit direct,
legacy commit/reveal, or timelocked weight calls *for* this hotkey and
mechanism only, paying normal transaction fees itself. Authorization does
not transfer stake or ownership and is independent on every mechanism.
Pass `delegate=None` (or use the CLI's `weights delegate revoke`) to
revoke it. Existing delegated calls remain subject to the validator's
registration, permit, stake, rate-limit, and weight rules.

| Signer   | Origin                                 | Pallet          | Wraps                                                                                                      |
| -------- | -------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------------- |
| `hotkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.set_mech_weight_delegate`](/code/pallets/subtensor/src/macros/dispatches.rs#L3279-L3288) |

## Verify [#verify]

After inclusion, confirm the effect with the
[`mech-weight-delegate`](/docs/query/mech-weight-delegate) read:

```bash
btcli query mech-weight-delegate --netuid <integer> --mechid <integer> --hotkey <ss58|name> --json
```

## Parameters [#parameters]

| Parameter  | Type    | Required | Description                                                                                                                                    |
| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `netuid`   | integer | yes      | Subnet containing the validator hotkey.                                                                                                        |
| `mechid`   | integer | no       | Mechanism index within the subnet. 0 is the default (and for most subnets the only) mechanism.                                                 |
| `delegate` | string  | no       | Account authorized to submit weights for this hotkey; null revokes. The runtime accepts any account, but delegated intents sign with a hotkey. |

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-mech-weight-delegate \
  --netuid <int> --dry-run
btcli tx set-mech-weight-delegate \
  --netuid <int> -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.SetMechWeightDelegate(netuid=1)

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_mech_weight_delegate", {...}, wallet)
```

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

`SubtensorModule.set_mech_weight_delegate` — [`pallets/subtensor/src/macros/dispatches.rs#L3281`](/code/pallets/subtensor/src/macros/dispatches.rs#L3279-L3288):

```rust
#[pallet::call_index(170)]
#[pallet::weight(T::DbWeight::get().reads_writes(5, 2))]
pub fn set_mech_weight_delegate(
    origin: OriginFor<T>,
    netuid: NetUid,
    mecid: MechId,
    delegate: Option<T::AccountId>,
) -> DispatchResult {
    Self::do_set_mech_weight_delegate(origin, netuid, mecid, delegate)
}
```

Delegates to [`do_set_mech_weight_delegate`](/code/pallets/subtensor/src/subnets/weights.rs#L18).

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)).
