# Create a batch transaction compatible with Squid router

To create a compatible Batch inside Squid Hook, we first need to create a the full encoded data for the batch preCompile, then encode this transaction data before integrating it into Squid. This works both on the source and the destination chain.

Each of the calls to be included in the batch precompile need to be encoded using  encodeFunctionData which is available on your contract instance.

```javascript
      let iface = new ethers.utils.Interface(contractABI);
      let encodedTx = iface.encodeFunctionData("functionName", [
       arg1,
       arg2
      ]);
```

You need to repeat this operation for each of the encoded calls (subcalls) that you'd like to integrate in the batch precompile. For instance, a simple use-case would be to send an `increaseAllowance` then an ERC20 transfer easily by encoding 2 transactions.

When you've got all your encoded transactions data, you need to encoded the full batch transaction.

For instance, it can looks like this:

```javascript
      let iface = new ethers.utils.Interface(batchABI);
      let encodedTx = iface.encodeFunctionData("batchAll", [
          [destinationAddress1, destinationAddress2],
          ["0", "0"], // native balance
          [encodedTx1, encodedTx2],
          [],
      ]);       
```

You can refer to the previous page "Understand the batch precompile" to better grasp how to generate a valid transaction using the batch Precompile.

Remember, there are 3 different batch functions:

* batchSome will continue to execute the following subcallls even is one is failing
* batchSomeUntilFailure will abort on failure as its name suggests, avoiding failure
* batchAll will make all subcall revert if one is failing


---

# 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://jungle-toolkit.gitbook.io/evm-xcm-jungle-toolkit/build-batches-on-source-and-destination-chains-using-squid-and-batch-precompile/create-a-batch-transaction-compatible-with-squid-router.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.
