# unsafe_splitCoin

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

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

Creates a transaction that splits a coin into multiple coins with specific amounts. This is useful for dividing SUI coins before transferring or staking.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The transaction signer's Sui address. |
| coin_object_id | string | Yes | The coin object to be split. |
| split_amounts | string[] | Yes | The amounts to split out from the coin. |
| gas | string | Yes | The gas object to be used in this transaction. If not specified, the node selects one automatically. |
| gas_budget | string | Yes | The gas budget. The transaction fails if the cost exceeds this amount. |

## Result

**result** (object): The unsigned transaction bytes and input objects.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_splitCoin",
  "params": [
    "0x563ee81d153032ef327b349420cf91e28a8d5528cbdcae5c108093a8a3879abb",
    "0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb",
    [
      "2"
    ],
    "0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f",
    "2000"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAACAQAAP5wPUztPcrOOTf2Q8mwp8FLrhVq4+xkS0grC45rDvCKgEAAAAAAAIPTdUyUhkhrkLz3h/2BpV7H2ZXm6WUv66fIHIPSPLJavAAkBAgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACA3BheQlzcGxpdF92ZWMBB4XFtkmIexd3hWGjoJvBpHQrn5nJp5dj6JrMCl3cI+y1A2V0aANFVEgAAgEAAAEBAFY+6B0VMDLvMns0lCDPkeKKjVUoy9yuXBCAk6ijh5q7AQu/K2wDyw9eE9Y0lFNevFeFbGih2P9nNMwhpORt+rwPKeFwAAAAAAAgJRnchOnSctUdRw79lCT5qcCMXqv2+KzvZGW5DwSGctdWPugdFTAy7zJ7NJQgz5Hiio1VKMvcrlwQgJOoo4eau+gDAAAAAAAA0AcAAAAAAAAA",
    "gas": [
      {
        "objectId": "0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f",
        "version": 7397673,
        "digest": "3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt"
      }
    ],
    "inputObjects": [
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0x003f9c0f533b4f72b38e4dfd90f26c29f052eb855ab8fb1912d20ac2e39ac3bc",
          "version": 1089570,
          "digest": "HUrDhmdBEtQW8LBAd2fdQrqznLedy16rPjME6WdZqCsG"
        }
      },
      {
        "MovePackage": "0x0000000000000000000000000000000000000000000000000000000000000002"
      },
      {
        "MovePackage": "0x85c5b649887b17778561a3a09bc1a4742b9f99c9a79763e89acc0a5ddc23ecb5"
      },
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f",
          "version": 7397673,
          "digest": "3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt"
        }
      }
    ]
  },
  "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_splitCoin",
  "params": [
    "0x563ee81d153032ef327b349420cf91e28a8d5528cbdcae5c108093a8a3879abb",
    "0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb",
    [
      "2"
    ],
    "0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f",
    "2000"
  ]
}'
```

### JavaScript

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

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_splitCoin
summary: Create an unsigned transaction to split a coin object into multiple coins.
description: |
  Creates a transaction that splits a coin into multiple coins with specific amounts. This is useful for dividing SUI coins before transferring or staking.
params:
  - name: signer
    required: true
    description: The transaction signer's Sui address.
    schema:
      type: string
  - name: coin_object_id
    required: true
    description: The coin object to be split.
    schema:
      type: string
  - name: split_amounts
    required: true
    description: The amounts to split out from the coin.
    schema:
      type: array
      items:
        type: string
  - name: gas
    required: true
    description: The gas object to be used in this transaction. If not specified, the node selects one automatically.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: The gas budget. The transaction fails if the cost exceeds this amount.
    schema:
      type: string
result:
  name: result
  description: The unsigned transaction bytes and input objects.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: BCS serialized transaction data bytes, base64 encoded.
      gas:
        type: array
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: integer
            digest:
              type: string
      inputObjects:
        type: array
        items:
          type: object
examples:
  - name: Split coin into one output
    params:
      - name: signer
        value: '0x563ee81d153032ef327b349420cf91e28a8d5528cbdcae5c108093a8a3879abb'
      - name: coin_object_id
        value: '0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb'
      - name: split_amounts
        value:
          - '2'
      - name: gas
        value: '0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f'
      - name: gas_budget
        value: '2000'
    result:
      name: result
      value:
        txBytes: AAACAQAAP5wPUztPcrOOTf2Q8mwp8FLrhVq4+xkS0grC45rDvCKgEAAAAAAAIPTdUyUhkhrkLz3h/2BpV7H2ZXm6WUv66fIHIPSPLJavAAkBAgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACA3BheQlzcGxpdF92ZWMBB4XFtkmIexd3hWGjoJvBpHQrn5nJp5dj6JrMCl3cI+y1A2V0aANFVEgAAgEAAAEBAFY+6B0VMDLvMns0lCDPkeKKjVUoy9yuXBCAk6ijh5q7AQu/K2wDyw9eE9Y0lFNevFeFbGih2P9nNMwhpORt+rwPKeFwAAAAAAAgJRnchOnSctUdRw79lCT5qcCMXqv2+KzvZGW5DwSGctdWPugdFTAy7zJ7NJQgz5Hiio1VKMvcrlwQgJOoo4eau+gDAAAAAAAA0AcAAAAAAAAA
        gas:
          - objectId: '0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f'
            version: 7397673
            digest: 3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt
        inputObjects:
          - ImmOrOwnedMoveObject:
              objectId: '0x003f9c0f533b4f72b38e4dfd90f26c29f052eb855ab8fb1912d20ac2e39ac3bc'
              version: 1089570
              digest: HUrDhmdBEtQW8LBAd2fdQrqznLedy16rPjME6WdZqCsG
          - MovePackage: '0x0000000000000000000000000000000000000000000000000000000000000002'
          - MovePackage: '0x85c5b649887b17778561a3a09bc1a4742b9f99c9a79763e89acc0a5ddc23ecb5'
          - ImmOrOwnedMoveObject:
              objectId: '0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f'
              version: 7397673
              digest: 3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt
```
