# unsafe_requestAddStake

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

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

Creates an unsigned transaction to stake SUI by selecting one or more SUI coins,  specifying the amount, and choosing a validator's address. This operation deposits the funds  into the validator’s staking pool. Gas must be paid with a separate coin.


Reference: https://www.alchemy.com/docs/chains/sui/sui-api-endpoints/unsafe-request-add-stake

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The address of the transaction signer. |
| coins | string[] | Yes | A list of Coin&lt;SUI&gt; object IDs to be used for staking. |
| amount | string | Yes | The amount to stake (in SUI base units). |
| validator | string | Yes | The address of the validator to which the stake is delegated. |
| gas | string | No | The object ID of the gas coin to be used. If not provided, one will be auto-selected. |
| gas_budget | string | Yes | Maximum gas budget for the transaction. |

## Result

**result** (object): The unsigned transaction for adding stake.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_requestAddStake",
  "params": [
    "0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361",
    [
      "0x74274e3dcc1bcf7360b291e0fd7d5a66c468d56c766664028d34cdd760c00090"
    ],
    "2",
    "0x88127002d43aac4a92422b4b35d41e17d72b62d0336751ec52e341c8b8d10ba7",
    "0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb",
    "2000"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAAEAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQEAAAAAAAAAAQEAdCdOPcwbz3NgspHg/X1aZsRo1Wx2ZmQCjTTN12DAAJCkIFQAAAAAACC/HMsNq7PPzkJSKt1qkBzkDWjrvOSrW8fnMi8SJMWFIwAJAQIAAAAAAAAAACCIEnAC1DqsSpJCK0s11B4X1yti0DNnUexS40HIuNELpwIFAAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMKc3VpX3N5c3RlbRpyZXF1ZXN0X2FkZF9zdGFrZV9tdWxfY29pbgAEAQAAAgAAAQIAAQMAH0Rsxsqm3/Eh0VQFaOkeibfg029uAJUixZJlxiftA2EBC78rbAPLD14T1jSUU168V4VsaKHY/2c0zCGk5G36vA8p4XAAAAAAACAlGdyE6dJy1R1HDv2UJPmpwIxeq/b4rO9kZbkPBIZy1x9EbMbKpt/xIdFUBWjpHom34NNvbgCVIsWSZcYn7QNh6AMAAAAAAADQBwAAAAAAAAA=",
    "gas": [
      {
        "objectId": "0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f",
        "version": 7397673,
        "digest": "3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt"
      }
    ],
    "inputObjects": [
      {
        "SharedMoveObject": {
          "id": "0x0000000000000000000000000000000000000000000000000000000000000005",
          "initial_shared_version": "1",
          "mutable": true
        }
      },
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0x74274e3dcc1bcf7360b291e0fd7d5a66c468d56c766664028d34cdd760c00090",
          "version": 5513380,
          "digest": "Ds2LSHthqBzpEFDix7iLprGaTFgeDgyZtcDhTmZvDntJ"
        }
      },
      {
        "MovePackage": "0x0000000000000000000000000000000000000000000000000000000000000003"
      },
      {
        "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_requestAddStake",
  "params": [
    "0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361",
    [
      "0x74274e3dcc1bcf7360b291e0fd7d5a66c468d56c766664028d34cdd760c00090"
    ],
    "2",
    "0x88127002d43aac4a92422b4b35d41e17d72b62d0336751ec52e341c8b8d10ba7",
    "0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb",
    "2000"
  ]
}'
```

### JavaScript

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

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_requestAddStake
summary: Stake SUI with a validator using multiple input coins
description: |
  Creates an unsigned transaction to stake SUI by selecting one or more SUI coins,  specifying the amount, and choosing a validator's address. This operation deposits the funds  into the validator’s staking pool. Gas must be paid with a separate coin.
params:
  - name: signer
    required: true
    description: The address of the transaction signer.
    schema:
      type: string
  - name: coins
    required: true
    description: A list of Coin&lt;SUI&gt; object IDs to be used for staking.
    schema:
      type: array
      items:
        type: string
  - name: amount
    required: true
    description: The amount to stake (in SUI base units).
    schema:
      type: string
  - name: validator
    required: true
    description: The address of the validator to which the stake is delegated.
    schema:
      type: string
  - name: gas
    required: false
    description: The object ID of the gas coin to be used. If not provided, one will be auto-selected.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: Maximum gas budget for the transaction.
    schema:
      type: string
result:
  name: result
  description: The unsigned transaction for adding stake.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: The unsigned transaction encoded in base64.
      gas:
        type: array
        description: The gas object to be used.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: integer
            digest:
              type: string
      inputObjects:
        type: array
        description: List of objects required as inputs (e.g., stake coin, Move modules).
        items:
          type: object
examples:
  - name: Stake 2 SUI to a validator
    params:
      - name: signer
        value: '0x1f446cc6caa6dff121d1540568e91e89b7e0d36f6e009522c59265c627ed0361'
      - name: coins
        value:
          - '0x74274e3dcc1bcf7360b291e0fd7d5a66c468d56c766664028d34cdd760c00090'
      - name: amount
        value: '2'
      - name: validator
        value: '0x88127002d43aac4a92422b4b35d41e17d72b62d0336751ec52e341c8b8d10ba7'
      - name: gas
        value: '0x8d776bfe8433e298973f7018e195906664985a80d060a288af6f9848094738bb'
      - name: gas_budget
        value: '2000'
    result:
      name: result
      value:
        txBytes: AAAEAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQEAAAAAAAAAAQEAdCdOPcwbz3NgspHg/X1aZsRo1Wx2ZmQCjTTN12DAAJCkIFQAAAAAACC/HMsNq7PPzkJSKt1qkBzkDWjrvOSrW8fnMi8SJMWFIwAJAQIAAAAAAAAAACCIEnAC1DqsSpJCK0s11B4X1yti0DNnUexS40HIuNELpwIFAAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMKc3VpX3N5c3RlbRpyZXF1ZXN0X2FkZF9zdGFrZV9tdWxfY29pbgAEAQAAAgAAAQIAAQMAH0Rsxsqm3/Eh0VQFaOkeibfg029uAJUixZJlxiftA2EBC78rbAPLD14T1jSUU168V4VsaKHY/2c0zCGk5G36vA8p4XAAAAAAACAlGdyE6dJy1R1HDv2UJPmpwIxeq/b4rO9kZbkPBIZy1x9EbMbKpt/xIdFUBWjpHom34NNvbgCVIsWSZcYn7QNh6AMAAAAAAADQBwAAAAAAAAA=
        gas:
          - objectId: '0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f'
            version: 7397673
            digest: 3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt
        inputObjects:
          - SharedMoveObject:
              id: '0x0000000000000000000000000000000000000000000000000000000000000005'
              initial_shared_version: '1'
              mutable: true
          - ImmOrOwnedMoveObject:
              objectId: '0x74274e3dcc1bcf7360b291e0fd7d5a66c468d56c766664028d34cdd760c00090'
              version: 5513380
              digest: Ds2LSHthqBzpEFDix7iLprGaTFgeDgyZtcDhTmZvDntJ
          - MovePackage: '0x0000000000000000000000000000000000000000000000000000000000000003'
          - ImmOrOwnedMoveObject:
              objectId: '0x0bbf2b6c03cb0f5e13d63494535ebc57856c68a1d8ff6734cc21a4e46dfabc0f'
              version: 7397673
              digest: 3VpxVaviG7RykDVLx1A21yT5YD1QFJpo1AWv5hJxQjKt
```
