# unsafe_publish

> 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 publishes a Move module package to the Sui blockchain. The transaction includes the compiled module bytecode, a list of dependency addresses, and gas settings.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| sender | string | Yes | The transaction signer's Sui address. |
| compiled_modules | string[] | Yes | List of compiled Move module byte arrays (base64-encoded). |
| dependencies | string[] | Yes | List of object IDs for all transitive Move dependencies. |
| gas | string | No | Object ID of the gas coin to use. Auto-selected if omitted. |
| gas_budget | string | Yes | Maximum gas budget allowed for the transaction. |

## Result

**result** (object): Unsigned transaction containing the Move package publish operation.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_publish",
  "params": [
    "0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca",
    [
      "UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw=="
    ],
    [
      "0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff"
    ],
    "2"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAEBYQBviFz6Y6H4RjBva6ARJNNMc6TT7ATjOibU4ESkWPM8r1nMCMq1OKoR1XrCk9D6J9FtMT9G+kqiBZ3lsU7wwuIDBE8TbGiR+lASjfxn4meOl/IjFf3ci1P8x8FTKwafVU0w2reNWEcaeElutxwsbne6Jo8DkDoOobmA6nL3RXhPeThmlRJ0z5Vlc6AGAAAAAAAg52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbwBAAAAAAAAAAEAAAAAAAAA",
    "gas": {
      "objectId": "0x3a0ea1b980ea72f745784f793866951274cf9565",
      "version": 434291,
      "digest": "52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbw="
    },
    "inputObjects": [
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0x3a0ea1b980ea72f745784f793866951274cf9565",
          "version": 434291,
          "digest": "52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbw="
        }
      }
    ]
  },
  "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_publish",
  "params": [
    "0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca",
    [
      "UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw=="
    ],
    [
      "0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff"
    ],
    "2",
    "string"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'unsafe_publish',
    params: [
      '0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca',
      [
        'UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw=='
      ],
      ['0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff'],
      '2',
      'string'
    ]
  })
};

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_publish",
    "params": ["0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca", ["UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw=="], ["0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff"], "2", "string"]
}
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_publish\",\n  \"params\": [\n    \"0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca\",\n    [\n      \"UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw==\"\n    ],\n    [\n      \"0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff\"\n    ],\n    \"2\",\n    \"string\"\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_publish\",\n  \"params\": [\n    \"0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca\",\n    [\n      \"UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw==\"\n    ],\n    [\n      \"0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff\"\n    ],\n    \"2\",\n    \"string\"\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_publish\",\n  \"params\": [\n    \"0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca\",\n    [\n      \"UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw==\"\n    ],\n    [\n      \"0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff\"\n    ],\n    \"2\",\n    \"string\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_publish
summary: Publish a Move module package
description: |
  Creates an unsigned transaction that publishes a Move module package to the Sui blockchain. The transaction includes the compiled module bytecode, a list of dependency addresses, and gas settings.
params:
  - name: sender
    required: true
    description: The transaction signer's Sui address.
    schema:
      type: string
  - name: compiled_modules
    required: true
    description: List of compiled Move module byte arrays (base64-encoded).
    schema:
      type: array
      items:
        type: string
  - name: dependencies
    required: true
    description: List of object IDs for all transitive Move dependencies.
    schema:
      type: array
      items:
        type: string
  - name: gas
    required: false
    description: Object ID of the gas coin to use. Auto-selected if omitted.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: Maximum gas budget allowed for the transaction.
    schema:
      type: string
result:
  name: result
  description: Unsigned transaction containing the Move package publish operation.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: BCS-serialized unsigned transaction, base64-encoded.
      gas:
        type: object
        description: The gas object used for this transaction.
        properties:
          objectId:
            type: string
          version:
            type: integer
          digest:
            type: string
      inputObjects:
        type: array
        description: All input objects used in the transaction (e.g., gas coin).
        items:
          type: object
examples:
  - name: Publish a Move module
    params:
      - name: sender
        value: '0x9c74337b14141ba3b0357c6625f756b47e76c7f7fa6370dec809cfc6500f54ca'
      - name: compiled_modules
        value:
          - UDYCDa2aWEDMU0HrzbHIwSynps1KS/SmcWkdXjWE8j1Q/EXOnhbI2+0QILrztBoHkxDT8VpkxGe2ZgprmWO4Dw==
      - name: dependencies
        value:
          - '0x06850c139e7f8923edd306226efe08d7ed699eafa8f8b8e59a7fa6aa31f481ff'
      - name: gas_budget
        value: '2'
    result:
      name: result
      value:
        txBytes: AAEBYQBviFz6Y6H4RjBva6ARJNNMc6TT7ATjOibU4ESkWPM8r1nMCMq1OKoR1XrCk9D6J9FtMT9G+kqiBZ3lsU7wwuIDBE8TbGiR+lASjfxn4meOl/IjFf3ci1P8x8FTKwafVU0w2reNWEcaeElutxwsbne6Jo8DkDoOobmA6nL3RXhPeThmlRJ0z5Vlc6AGAAAAAAAg52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbwBAAAAAAAAAAEAAAAAAAAA
        gas:
          objectId: '0x3a0ea1b980ea72f745784f793866951274cf9565'
          version: 434291
          digest: 52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbw=
        inputObjects:
          - ImmOrOwnedMoveObject:
              objectId: '0x3a0ea1b980ea72f745784f793866951274cf9565'
              version: 434291
              digest: 52EjC2IvYUY3YUndrVNlQfdL5hj0pWzgMM0rSmicQbw=
```
