# unsafe_batchTransaction

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://sui-mainnet.g.alchemy.com/v2/{apiKey}

Creates a BCS-serialized batched transaction that is not signed. This can be used to execute multiple actions atomically in one transaction block.


Reference: https://www.alchemy.com/docs/chains/sui/sui-api-endpoints/unsafe-batch-transaction

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The transaction signer's Sui address. |
| single_transaction_params | object[] | Yes | A list of individual transaction instructions to include in the batch. |
| gas | string | No | The gas object to be used. If omitted, one will be selected automatically. |
| gas_budget | string | Yes | The maximum amount of gas to be used for this transaction. |
| txn_builder_mode | enum | No | Whether this is a regular or dev-inspect transaction. |

## Result

**result** (object): The batched transaction block as BCS-encoded data, plus gas and input metadata.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_batchTransaction",
  "params": [
    "0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e",
    [
      {
        "kind": "TransferObject",
        "data": {
          "recipient": "0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69",
          "objectId": "0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc"
        }
      }
    ],
    "0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84",
    "10000000",
    "Commit"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAACACBqEB6aOvXIBwES+Ahkizbvv43uihqC3kbZUE6WoRCKFwEA...",
    "gas": [
      {
        "objectId": "0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84",
        "version": "2",
        "digest": "EnRQXe1hDGAJCFyF2ds2GmPHdvf9V6yxf24LisEsDkYt"
      }
    ],
    "inputObjects": [
      {
        "objectId": "0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc",
        "version": "2",
        "digest": "Cv7n2YaM7Am1ssZGu4khsFkcKHnpgVhwFCSs4kLjrtLW"
      }
    ]
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://sui-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "unsafe_batchTransaction",
  "params": [
    "0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e",
    [
      {
        "kind": "TransferObject",
        "data": {
          "recipient": "0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69",
          "objectId": "0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc"
        }
      }
    ],
    "0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84",
    "10000000",
    "Commit"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'unsafe_batchTransaction',
    params: [
      '0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e',
      [
        {
          kind: 'TransferObject',
          data: {
            recipient: '0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69',
            objectId: '0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc'
          }
        }
      ],
      '0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84',
      '10000000',
      'Commit'
    ]
  })
};

fetch('https://sui-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://sui-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "unsafe_batchTransaction",
    "params": ["0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e", [
            {
                "kind": "TransferObject",
                "data": {
                    "recipient": "0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69",
                    "objectId": "0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc"
                }
            }
        ], "0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84", "10000000", "Commit"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://sui-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"unsafe_batchTransaction\",\n  \"params\": [\n    \"0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e\",\n    [\n      {\n        \"kind\": \"TransferObject\",\n        \"data\": {\n          \"recipient\": \"0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69\",\n          \"objectId\": \"0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc\"\n        }\n      }\n    ],\n    \"0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84\",\n    \"10000000\",\n    \"Commit\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://sui-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"unsafe_batchTransaction\",\n  \"params\": [\n    \"0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e\",\n    [\n      {\n        \"kind\": \"TransferObject\",\n        \"data\": {\n          \"recipient\": \"0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69\",\n          \"objectId\": \"0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc\"\n        }\n      }\n    ],\n    \"0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84\",\n    \"10000000\",\n    \"Commit\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://sui-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"unsafe_batchTransaction\",\n  \"params\": [\n    \"0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e\",\n    [\n      {\n        \"kind\": \"TransferObject\",\n        \"data\": {\n          \"recipient\": \"0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69\",\n          \"objectId\": \"0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc\"\n        }\n      }\n    ],\n    \"0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84\",\n    \"10000000\",\n    \"Commit\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: unsafe_batchTransaction
summary: Create an unsigned batched transaction
description: |
  Creates a BCS-serialized batched transaction that is not signed. This can be used to execute multiple actions atomically in one transaction block.
params:
  - name: signer
    required: true
    description: The transaction signer's Sui address.
    schema:
      type: string
  - name: single_transaction_params
    required: true
    description: A list of individual transaction instructions to include in the batch.
    schema:
      type: array
      items:
        type: object
        description: Individual transaction request parameter.
        properties:
          kind:
            type: string
            description: The kind of transaction (e.g. TransferObject, MoveCall, etc).
          data:
            type: object
            description: The parameters for the specific transaction kind.
  - name: gas
    required: false
    description: The gas object to be used. If omitted, one will be selected automatically.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: The maximum amount of gas to be used for this transaction.
    schema:
      type: string
  - name: txn_builder_mode
    required: false
    description: Whether this is a regular or dev-inspect transaction.
    schema:
      type: string
      enum:
        - Commit
        - DevInspect
result:
  name: result
  description: The batched transaction block as BCS-encoded data, plus gas and input metadata.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: BCS serialized transaction data bytes (base64-encoded, without type tag).
      gas:
        type: array
        description: Gas objects used in the transaction.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: string
            digest:
              type: string
      inputObjects:
        type: array
        description: All input objects used in this transaction.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: string
            digest:
              type: string
examples:
  - name: Create batched transaction
    params:
      - name: signer
        value: '0x7d20dcdb2bca4f508ea9613994683eb4e76e9c4ed371169677c1be02aaf0b58e'
      - name: single_transaction_params
        value:
          - kind: TransferObject
            data:
              recipient: '0x9b9f3d0c8593d68164661b7f3de35308a3ffde34cb4f08879642a6a2b6ceca69'
              objectId: '0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc'
      - name: gas
        value: '0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84'
      - name: gas_budget
        value: '10000000'
      - name: txn_builder_mode
        value: Commit
    result:
      name: result
      value:
        txBytes: AAACACBqEB6aOvXIBwES+Ahkizbvv43uihqC3kbZUE6WoRCKFwEA...
        gas:
          - objectId: '0xe8d8c7ce863f313da3dbd92a83ef26d128b88fe66bf26e0e0d09cdaf727d1d84'
            version: '2'
            digest: EnRQXe1hDGAJCFyF2ds2GmPHdvf9V6yxf24LisEsDkYt
        inputObjects:
          - objectId: '0x4f82f1c8587b98d64c00bfb46c3843bd8bf6ccfa7c65a86138698cd1fdcac3dc'
            version: '2'
            digest: Cv7n2YaM7Am1ssZGu4khsFkcKHnpgVhwFCSs4kLjrtLW
```
