# authorize-order (/docs/tx/authorize-order)

Supports direct post-quantum owners, proxies, derivatives, and multisigs. This
grants relayers the complete specified trade; funds move only on execution.
Cancel with the same nonce and complete order to revoke its unfilled part.

| Signer    | Origin                                 | Pallet      | Wraps                                                                            |
| --------- | -------------------------------------- | ----------- | -------------------------------------------------------------------------------- |
| `coldkey` | signed account (pallet role may apply) | LimitOrders | [`LimitOrders.authorize_order`](/code/pallets/limit-orders/src/lib.rs#L770-L797) |

## Parameters [#parameters]

| Parameter    | Type    | Required | Description                                                      |
| ------------ | ------- | -------- | ---------------------------------------------------------------- |
| `nonce`      | integer | yes      | Permanent owner-local u64 order nonce.                           |
| `order`      | object  | yes      | Complete V1 or V2 VersionedOrder, including every economic term. |
| `order_data` | string  | no       | Optional pinned canonical VersionedOrder SCALE bytes as hex.     |

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 authorize-order \
  --nonce <int> \
  --order '<json>' --dry-run
btcli tx authorize-order \
  --nonce <int> \
  --order '<json>' -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.AuthorizeOrder(nonce=0, order={...})

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

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

`LimitOrders.authorize_order` — [`pallets/limit-orders/src/lib.rs#L773`](/code/pallets/limit-orders/src/lib.rs#L770-L797):

```rust
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::authorize_order())]
#[transactional]
pub fn authorize_order(
    origin: OriginFor<T>,
    order: VersionedOrder<AccountId32>,
) -> DispatchResult {
    let who = ensure_signed(origin)?;
    ensure!(order.signer() == &who, Error::<T>::Unauthorized);
    let (nonce, terms) = order
        .authorized_terms()
        .ok_or(Error::<T>::InvalidAuthorizationMode)?;
    ensure!(
        LimitOrdersEnabled::<T>::get(),
        Error::<T>::LimitOrdersDisabled
    );
    ensure!(
        T::AuthenticatedOrderSignerFilter::contains(&who),
        Error::<T>::OrderSignerFrozen
    );
    let id = Self::approve_order(&who, nonce, &terms)?;
    Self::deposit_event(Event::OrderApproved {
        order_id: id,
        signer: who,
        nonce,
    });
    Ok(())
}
```

Delegates to [`approve_order`](/code/pallets/limit-orders/src/authorization.rs#L262).

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