# unsafe_requestWithdrawStake

> 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 requests withdrawal of a staked SUI object  from a validator's staking pool. The gas coin must not be part of the staked assets.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| signer | string | Yes | The transaction signer's Sui address. |
| staked_sui | string | Yes | StakedSui object ID. |
| gas | string | Yes | Gas object to be used in this transaction. If not provided, one will be auto-selected by the node. |
| gas_budget | string | Yes | The gas budget for the transaction. The transaction will fail if the gas cost exceeds this value. |

## Result

**result** (object): The unsigned transaction to withdraw stake.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "unsafe_requestWithdrawStake",
  "params": [
    "0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56",
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "5000"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAACAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQEAAAAAAAAAAQEA7mXfRGyJZQRRLLNag/glEMEP0vq13itRo6Y/9vcQbacBAAAAAAAAACAK12msl7LT8P5mymJEPw7iN/uuGhV/TB71nx0TlEikMQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMKc3VpX3N5c3RlbRZyZXF1ZXN0X3dpdGhkcmF3X3N0YWtlAAIBAAABAQDusw9NxnWn1JuKvt9Y6y43OPrPxVTID0snq2KqAoePVgHuZd9EbIllBFEss1qD+CUQwQ/S+rXeK1Gjpj/29xBtpwEAAAAAAAAAIArXaayXstPw/mbKYkQ/DuI3+64aFX9MHvWfHROUSKQx7rMPTcZ1p9Sbir7fWOsuNzj6z8VUyA9LJ6tiqgKHj1bkAgAAAAAAAIgTAAAAAAAAAA==",
    "gas": [
      {
        "objectId": "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
        "version": 1,
        "digest": "jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW"
      }
    ],
    "inputObjects": [
      {
        "SharedMoveObject": {
          "id": "0x0000000000000000000000000000000000000000000000000000000000000005",
          "initial_shared_version": "1",
          "mutable": true
        }
      },
      {
        "ImmOrOwnedMoveObject": {
          "objectId": "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
          "version": 1,
          "digest": "jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW"
        }
      },
      {
        "MovePackage": "0x0000000000000000000000000000000000000000000000000000000000000003"
      },
      {
        "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_requestWithdrawStake",
  "params": [
    "0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56",
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7",
    "5000"
  ]
}'
```

### JavaScript

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

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

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

```


## OpenRPC Method Specification

```yaml
name: unsafe_requestWithdrawStake
summary: Withdraw a stake from a validator's staking pool
description: |
  Creates an unsigned transaction that requests withdrawal of a staked SUI object  from a validator's staking pool. The gas coin must not be part of the staked assets.
params:
  - name: signer
    required: true
    description: The transaction signer's Sui address.
    schema:
      type: string
  - name: staked_sui
    required: true
    description: StakedSui object ID.
    schema:
      type: string
  - name: gas
    required: true
    description: Gas object to be used in this transaction. If not provided, one will be auto-selected by the node.
    schema:
      type: string
  - name: gas_budget
    required: true
    description: The gas budget for the transaction. The transaction will fail if the gas cost exceeds this value.
    schema:
      type: string
result:
  name: result
  description: The unsigned transaction to withdraw stake.
  schema:
    type: object
    properties:
      txBytes:
        type: string
        description: Base64-encoded BCS transaction bytes.
      gas:
        type: array
        description: The gas object used in the transaction.
        items:
          type: object
          properties:
            objectId:
              type: string
            version:
              type: integer
            digest:
              type: string
      inputObjects:
        type: array
        description: List of input objects involved in the transaction.
        items:
          type: object
examples:
  - name: Withdraw stake
    params:
      - name: signer
        value: '0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56'
      - name: staked_sui
        value: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
      - name: gas
        value: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
      - name: gas_budget
        value: '5000'
    result:
      name: result
      value:
        txBytes: AAACAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQEAAAAAAAAAAQEA7mXfRGyJZQRRLLNag/glEMEP0vq13itRo6Y/9vcQbacBAAAAAAAAACAK12msl7LT8P5mymJEPw7iN/uuGhV/TB71nx0TlEikMQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMKc3VpX3N5c3RlbRZyZXF1ZXN0X3dpdGhkcmF3X3N0YWtlAAIBAAABAQDusw9NxnWn1JuKvt9Y6y43OPrPxVTID0snq2KqAoePVgHuZd9EbIllBFEss1qD+CUQwQ/S+rXeK1Gjpj/29xBtpwEAAAAAAAAAIArXaayXstPw/mbKYkQ/DuI3+64aFX9MHvWfHROUSKQx7rMPTcZ1p9Sbir7fWOsuNzj6z8VUyA9LJ6tiqgKHj1bkAgAAAAAAAIgTAAAAAAAAAA==
        gas:
          - objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
            version: 1
            digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
        inputObjects:
          - SharedMoveObject:
              id: '0x0000000000000000000000000000000000000000000000000000000000000005'
              initial_shared_version: '1'
              mutable: true
          - ImmOrOwnedMoveObject:
              objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
              version: 1
              digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
          - MovePackage: '0x0000000000000000000000000000000000000000000000000000000000000003'
          - ImmOrOwnedMoveObject:
              objectId: '0xee65df446c896504512cb35a83f82510c10fd2fab5de2b51a3a63ff6f7106da7'
              version: 1
              digest: jKbAsTuqaK9k6hb27Z5xxnQVmTSWoU6dkL82x44c2dW
```
