# Transaction request

The **APP** can request the **PKSA** to sign and/or broadcast a transaction.

Before sending its request, the **APP** must create a "sign request data" object (`sign_req_data`) it will send to the **PKSA**

### sign\_req\_data

```javascript
{
    key_type: string
    ops: Array
    broadcast: boolean
    nonce: number
}
```

{% tabs %}
{% tab title="Properties" %}

* **`key_type`**: the key type required to sign the transactions. It can be one of `posting`|`active`
* **`ops`**: an array of operations objects (see [Hive API doc](https://developers.hive.io/apidefinitions/#condenser_api.broadcast_transaction) for more info)
* **`broadcast`**: `true` if the **PKSA** must broadcast the transaction to the blockchain. `false` if the **PKSA** must return a signed transaction but not broadcast it to the blockchain.
* **`nonce`**: current UNIX time in ms (`Date.now()` in Javascript). If a transaction request ever fails, do **NOT** reuse the `sign_req_data` object before **first updating the nonce**!
  {% endtab %}
  {% endtabs %}

The **APP** must then encrypt the `sign_req_data` object using the encryption key previously shared with the **PKSA** (`auth_key`). By encrypting the `sign_req_data` object, the **HAS** will be unaware of what's going on between the app and the PKSA and unable to tamper with the sign request process.

Finally, the **APP** sends its request to the **HAS** using the following message:

### sign\_req

```
{ 
    cmd: "sign_req"
    account: string
    data: string
    token: string // DEPRECATED - protocol < 1 only    
}
```

{% tabs %}
{% tab title="Properties" %}

* **`account`**: the Hive account name that must sign the transactions
* **`data`**: the Base64 representation of an encrypted `sign_req_data` object<br>
* **`token`**: the authentication token - ***Deprecated since protocol V1***
  {% endtab %}
  {% endtabs %}

The **HAS** will reply with a `sign_wait` message:

### sign\_wait

```javascript
{
    cmd: "sign_wait",
    uuid: string,
    expire: number
}
```

{% tabs %}
{% tab title="Properties" %}

* **`uuid`**: a unique identifier given by the **HAS** to the request
* **`expire`**: UNIX time when the request will expire
  {% endtab %}
  {% endtabs %}

{% hint style="info" %}

### Signing transactions using delegated authority

Authority delegation on the Hive blockchain allows users to grant specific permissions to others, enabling them to sign transactions or perform actions on their behalf while retaining control over their account.

This can be easily achieved with HiveAuth.

Let's assume that the @alice account has delegated authority to @bob's account and that @bob wants to broadcast transactions to the blockchain on behalf of @alice.

1. create one or multiple operations using `"alice"` as the operation initiator, then add them to the `sign_req_data`
2. create a `sign_req` object and use `"bob"` as the signing account.
   {% endhint %}
