# unsafe_pay

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

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

Create an unsigned transaction to send Coin&lt;T&gt; to a list of recipients,  where T can be any coin type. The specified gas object must not appear  in the input_coins array. If not provided, the node will select one automatically.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The transaction signer's Sui address. |
| input_coins | string[] | Yes | List of Coin&lt;T&gt; object IDs to use for sending value. |
| recipients | string[] | Yes | The recipient addresses. Must have the same length as `amounts`. |
| amounts | string[] | Yes | The amounts to transfer to each recipient, in the same order. |
| gas | string | No | Object ID of the gas coin to use. Must not be in input_coins. |
| gas_budget | string | Yes | The gas budget for the transaction. |

## Result

**result** (object): Unsigned transaction for sending Coin&lt;T&gt;.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_pay",
  "params": [
    "0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f",
    [
      "0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9"
    ],
    [
      "0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d"
    ],
    [
      "10"
    ],
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "2000"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAADAQCmN5wZs6qaqHj8Her2nB27HeQiTei2LeBOSWK1k+A36Q4DMCEAAAAAIF...",
    "gas": [
      {
        "objectId": "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
        "version": 1,
        "digest": "jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW"
      }
    ],
    "inputObjects": [
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9",
          "version": 556794638,
          "digest": "6afcUrFL3VjDUHd7EUTPgCM2Tbw2vt1X96kVDhZqWh6r"
        }
      },
      {
        "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_pay",
  "params": [
    "0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f",
    [
      "0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9"
    ],
    [
      "0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d"
    ],
    [
      "10"
    ],
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "2000"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'unsafe_pay',
    params: [
      '0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f',
      ['0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9'],
      ['0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d'],
      ['10'],
      '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7',
      '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_pay",
    "params": ["0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f", ["0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9"], ["0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d"], ["10"], "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7", "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_pay\",\n  \"params\": [\n    \"0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f\",\n    [\n      \"0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9\"\n    ],\n    [\n      \"0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d\"\n    ],\n    [\n      \"10\"\n    ],\n    \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\",\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_pay\",\n  \"params\": [\n    \"0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f\",\n    [\n      \"0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9\"\n    ],\n    [\n      \"0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d\"\n    ],\n    [\n      \"10\"\n    ],\n    \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\",\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_pay\",\n  \"params\": [\n    \"0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f\",\n    [\n      \"0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9\"\n    ],\n    [\n      \"0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d\"\n    ],\n    [\n      \"10\"\n    ],\n    \"0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7\",\n    \"2000\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_pay
summary: Send Coin&lt;T&gt; to a list of addresses
description: |
  Create an unsigned transaction to send Coin&lt;T&gt; to a list of recipients,  where T can be any coin type. The specified gas object must not appear  in the input_coins array. If not provided, the node will select one automatically.
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;T&gt; object IDs to use for sending value.
    schema:
      type: array
      items:
        type: string
  - name: recipients
    required: true
    description: The recipient addresses. Must have the same length as `amounts`.
    schema:
      type: array
      items:
        type: string
  - name: amounts
    required: true
    description: The amounts to transfer to each recipient, in the same order.
    schema:
      type: array
      items:
        type: string
  - name: gas
    required: false
    description: Object ID of the gas coin to use. Must not be in input_coins.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: The gas budget for the transaction.
    schema:
      type: string
result:
  name: result
  description: Unsigned transaction for sending Coin&lt;T&gt;.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: Base64-encoded BCS serialized transaction bytes.
      gas:
        type: array
        description: Gas object(s) selected for the transaction.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: integer
            digest:
              type: string
      inputObjects:
        type: array
        description: All objects involved in this transaction (coins, gas, etc.).
        items:
          type: object
examples:
  - name: Transfer Coin&lt;T&gt; to 1 recipient
    params:
      - name: signer
        value: '0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f'
      - name: input_coins
        value:
          - '0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9'
      - name: recipients
        value:
          - '0x8933942921bd522d69d7af12f875ba4f4963ad01431df8403597dfa8692f417d'
      - name: amounts
        value:
          - '10'
      - name: gas
        value: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
      - name: gas_budget
        value: '2000'
    result:
      name: result
      value:
        txBytes: AAADAQCmN5wZs6qaqHj8Her2nB27HeQiTei2LeBOSWK1k+A36Q4DMCEAAAAAIF...
        gas:
          - objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
            version: 1
            digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
        inputObjects:
          - ImmOrOwnedMoveObject:
              objectId: '0xa6379c19b3aa9aa878fc1deaf69c1dbb1de4224de8b62de04e4962b593e037e9'
              version: 556794638
              digest: 6afcUrFL3VjDUHd7EUTPgCM2Tbw2vt1X96kVDhZqWh6r
          - ImmOrOwnedMoveObject:
              objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
              version: 1
              digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
```
