# execute-orders (/docs/tx/execute-orders)

Each signed order includes complete terms, its signature, and an optional
partial fill. Authorized terms also bind an owner-local nonce. With
should\_fail true, any failed order reverts the whole batch.

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

## Parameters [#parameters]

| Parameter     | Type    | Required | Description                          |
| ------------- | ------- | -------- | ------------------------------------ |
| `orders`      | array   | yes      | Complete SignedOrder objects.        |
| `should_fail` | boolean | no       | Revert the batch if any order fails. |

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 execute-orders \
  --orders <a,b,c> --dry-run
btcli tx execute-orders \
  --orders <a,b,c> -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.ExecuteOrders(orders=[...])

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

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

`LimitOrders.execute_orders` — [`pallets/limit-orders/src/lib.rs#L616`](/code/pallets/limit-orders/src/lib.rs#L614-L641):

```rust
#[pallet::call_index(0)]
#[pallet::weight(Pallet::<T>::execute_orders_weight(orders))]
pub fn execute_orders(
    origin: OriginFor<T>,
    orders: BoundedVec<SignedOrder<T::AccountId>, T::MaxOrdersPerBatch>,
    should_fail: bool,
) -> DispatchResult {
    let relayer = ensure_signed(origin)?;
    ensure!(
        LimitOrdersEnabled::<T>::get(),
        Error::<T>::LimitOrdersDisabled
    );

    Self::check_authorized_batch_bound(&orders)?;
    for signed_order in orders {
        let order_id = Self::derive_order_id(&signed_order.order);
        if let Err(reason) = Self::try_execute_order(signed_order, order_id, &relayer) {
            if should_fail {
                // All-or-nothing: abort the batch, reverting prior orders.
                return Err(reason);
            }
            // Best-effort: individual order failures do not revert the batch.
            Self::deposit_event(Event::OrderSkipped { order_id, reason });
        }
    }

    Ok(())
}
```

Delegates to [`check_authorized_batch_bound`](/code/pallets/limit-orders/src/authorization.rs#L153), [`derive_order_id`](/code/pallets/limit-orders/src/lib.rs#L835).

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