# unsafe_paySui

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

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

Creates an unsigned transaction that sends SUI to multiple recipients. The transaction uses SUI coins for both transfer and gas without requiring a separate gas object. 1. Debits each input coin to create new coins for recipients. 2. Consolidates residual SUI into the first coin, which becomes the gas coin. 3. Updates the first coin balance to: total_input - total_output - gas_cost. 4. Deletes all other input coins.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The transaction signer's Sui address. |
| input_coins | string[] | Yes | List of Coin&lt;SUI&gt; object IDs to use, including the one used for gas. |
| recipients | string[] | Yes | List of recipient Sui addresses. |
| amounts | string[] | Yes | List of amounts (same order as recipients). |
| gas_budget | string | Yes | The gas budget for the transaction. |

## Result

**result** (object): Unsigned transaction that transfers SUI to recipients.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_paySui",
  "params": [
    "0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56",
    [
      "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7"
    ],
    [
      "0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361"
    ],
    [
      "2"
    ],
    "2000"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAACAAgCAAAAAAAAAAAgH0Rsxsqm3/Eh0VQFaOkeibfg029uAJUixZJlxiftA2ECAgABAQA...",
    "gas": [
      {
        "objectId": "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
        "version": 1,
        "digest": "jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW"
      }
    ],
    "inputObjects": [
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
          "version": 1,
          "digest": "jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW"
        }
      }
    ]
  },
  "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_paySui",
  "params": [
    "0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56",
    [
      "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7"
    ],
    [
      "0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361"
    ],
    [
      "2"
    ],
    "2000"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'unsafe_paySui',
    params: [
      '0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56',
      ['0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'],
      ['0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361'],
      ['2'],
      '2000'
    ]
  })
};

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_paySui",
    "params": ["0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56", ["0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7"], ["0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361"], ["2"], "2000"]
}
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_paySui\",\n  \"params\": [\n    \"0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56\",\n    [\n      \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\"\n    ],\n    [\n      \"0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361\"\n    ],\n    [\n      \"2\"\n    ],\n    \"2000\"\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_paySui\",\n  \"params\": [\n    \"0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56\",\n    [\n      \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\"\n    ],\n    [\n      \"0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361\"\n    ],\n    [\n      \"2\"\n    ],\n    \"2000\"\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_paySui\",\n  \"params\": [\n    \"0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56\",\n    [\n      \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\"\n    ],\n    [\n      \"0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361\"\n    ],\n    [\n      \"2\"\n    ],\n    \"2000\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_paySui
summary: Send SUI coins to multiple recipients
description: |
  Creates an unsigned transaction that sends SUI to multiple recipients. The transaction uses SUI coins for both transfer and gas without requiring a separate gas object. 1. Debits each input coin to create new coins for recipients. 2. Consolidates residual SUI into the first coin, which becomes the gas coin. 3. Updates the first coin balance to: total_input - total_output - gas_cost. 4. Deletes all other input coins.
params:
  - name: signer
    required: true
    description: The transaction signer's Sui address.
    schema:
      type: string
  - name: input_coins
    required: true
    description: List of Coin&lt;SUI&gt; object IDs to use, including the one used for gas.
    schema:
      type: array
      items:
        type: string
  - name: recipients
    required: true
    description: List of recipient Sui addresses.
    schema:
      type: array
      items:
        type: string
  - name: amounts
    required: true
    description: List of amounts (same order as recipients).
    schema:
      type: array
      items:
        type: string
  - name: gas_budget
    required: true
    description: The gas budget for the transaction.
    schema:
      type: string
result:
  name: result
  description: Unsigned transaction that transfers SUI to recipients.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: Base64-encoded BCS serialized transaction bytes.
      gas:
        type: array
        description: Gas object used for the transaction.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: integer
            digest:
              type: string
      inputObjects:
        type: array
        description: All input SUI coin objects involved.
        items:
          type: object
examples:
  - name: Transfer SUI to one recipient
    params:
      - name: signer
        value: '0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56'
      - name: input_coins
        value:
          - '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
      - name: recipients
        value:
          - '0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361'
      - name: amounts
        value:
          - '2'
      - name: gas_budget
        value: '2000'
    result:
      name: result
      value:
        txBytes: AAACAAgCAAAAAAAAAAAgH0Rsxsqm3/Eh0VQFaOkeibfg029uAJUixZJlxiftA2ECAgABAQA...
        gas:
          - objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
            version: 1
            digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
        inputObjects:
          - ImmOrOwnedMoveObject:
              objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
              version: 1
              digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
```
