# Create Order

Create a transaction for a payment order. Create a payment order to purchase territory for `target_acc`. Specify the space size and time of the territory to be paid for by `gib_count` and `days`. `order_type` specifies whether the order type is purchase, expansion or renewal.

```rust
/// Creates a payment order to purchase, expand, or renew a territory for a specified account.
///
/// This function creates a payment order for the `target_acc` to purchase a territory.
/// The space size and duration of the territory are specified by `gib_count` and `days`, respectively.
/// The `order_type` parameter specifies whether the order is for a purchase, expansion, or renewal.
///
/// # Arguments
///
/// * `target_acc` - A reference to a string slice that holds the target account for the payment order.
/// * `territory_name` - A reference to a string slice that holds the name of the territory.
/// * `order_type` - The type of order (purchase, expansion, or renewal).
/// * `gib_count` - The amount of space in GiB to be purchased.
/// * `days` - The duration in days for which the territory is to be purchased.
/// * `expired` - The expiration timestamp for the order.
///
/// # Returns
///
/// This function returns a `Result` which is:
/// * `Ok((TxHash, CreatePayOrder))` - A tuple containing the transaction hash and the `CreatePayOrder` struct.
/// * `Err(Box<dyn std::error::Error>)` - An error if the transaction fails.
///

pub async fn create_order(
    &self,
    target_acc: &str,
    territory_name: &str,
    order_type: OrderType,
    gib_count: u32,
    days: u32,
    expired: u32,
) -> Result<(TxHash, CreatePayOrder), Box<dyn std::error::Error>>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.cess.network/developer/cess-sdk/sdk-rust/chain/storage_handler/create_order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
