# Split

Similar to the transfer function, this particular function generates a hexadecimal representation of a transaction that can distribute tokens to multiple addresses at once. It should be noted that this function is only applicable to tokens that have the splittable property set to true. For more details on which token templates possess this attribute, please refer to the STAS features table.

To create a split transaction, we need a STAS UTXO, a fee UTXO, and the private keys linked with these UTXOs. Instead of the destination address required in the transfer function, we need an array that contains all the destination addresses and their corresponding amounts.

The splitDestinations array is made up of objects that contain two fields. Please keep in mind that the sum of the outputs' amounts must match the amount in the STAS UTXO input to ensure a valid transaction is created.

```javascript
const splitDestinations = [
    {
        satoshis : 10,
        address : "someAddressString"
    },
    {
        satoshis : 10,
        address : "someOtherAddressString"
    }
]
```

{% hint style="info" %}
If the token owner needs to receive change from the STAS UTXO input, it must be included in the splitDestination array. The total amount in the outputs of the array should match the input satoshis amount.
{% endhint %}

```javascript
const splitHex = await stasSplit.signed(
    ownerPrivatekey, 
    stasUtxo, 
    splitDestinations, 
    paymentUtxo, 
    paymentPrivateKey
)
```

{% hint style="success" %}
After executing the function, you will receive a transaction hexadecimal representation that is now ready to be broadcasted to the miner.
{% endhint %}


---

# 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://docs.stastoken.com/library/split.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.
