> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdrawal

> Withdraw staked assets on Monad with the P2P.org Staking API.

The withdrawal process on the Monad network using the Staking API can be done in a few steps:

1. Undelegate the staked tokens from the P2P validator.

2. Withdraw unstaked tokens after the waiting period.

After each operation, [sign and send](/docs/signing-transaction-monad) the transaction to the network.

Request examples are provided using [cURL](https://curl.se/).

<Steps>
  <Step title="Create undelegate request">
    1. To remove tokens from being actively delegated, send a POST request to [/api/v2/monad/\{network}/delegators/\{delegatorAddress}/stakes/undelegations](/reference/monad-delegators-create-undelegation).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/undelegations \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "gas": {
          "priorityPricePerGas": "21000",
          "maxPricePerGas": "1000000000"
        },
        "amount": "1000000000000000000"
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/undelegations", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "gas": {
            "priorityPricePerGas": "21000",
            "maxPricePerGas": "1000000000"
          },
          "amount": "1000000000000000000"
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/undelegations",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "gas": {
                  "priorityPricePerGas": "21000",
                  "maxPricePerGas": "1000000000"
              },
              "amount": "1000000000000000000"
          },
      )
      print(response.json())
      ```

      ```go Go theme={null}
      package main

      import (
      	"bytes"
      	"encoding/json"
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	payload := map[string]interface{}{
      		"gas": map[string]interface{}{
      			"priorityPricePerGas": "21000",
      			"maxPricePerGas": "1000000000",
      		},
      		"amount": "1000000000000000000",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/undelegations", bytes.NewBuffer(body))
      	req.Header.Set("Authorization", "Bearer <token>")
      	req.Header.Set("Content-Type", "application/json")
      	resp, _ := http.DefaultClient.Do(req)
      	defer resp.Body.Close()
      	respBody, _ := io.ReadAll(resp.Body)
      	fmt.Println(string(respBody))
      }
      ```
    </CodeGroup>

    * `delegatorAddress` — delegator address on the Monad network.

    * `amount` — amount of tokens to undelegate in Wei (1 MON = 10¹⁸ Wei).

    * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load.

      * `priorityPricePerGas` — price per unit of gas in Wei (1 Wei = 10⁻¹⁸ MON), which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction.
      * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei (1 Wei = 10⁻¹⁸ MON).

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": "1000000000000000000",
            "createdAt": "2025-05-06T10:40:00.000Z",
            "delegatorAddress": "0x1234567890abcdef1234567890abcdef12345678",
            "gas": {
              "gasLimit": "260850",
              "priorityPricePerGas": "1000000000",
              "maxPricePerGas": "2000000000"
            },
            "unsignedTransaction": "0x02f8758301e24004...",
            "validatorId": 1,
            "withdrawId": 0
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to undelegate in Wei (1 MON = 10¹⁸ Wei).

    * `createdAt` — timestamp of the transaction in the ISO 8601 format.

    * `delegatorAddress` — delegator address on the Monad network.

    * `gas` — computational effort required to execute the transaction measured in gas units:

      * `gasLimit` — maximum gas limit for the transaction.
      * `priorityPricePerGas` — price per unit of gas in Wei (1 Wei = 10⁻¹⁸ MON), which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction.
      * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei (1 Wei = 10⁻¹⁸ MON).

    * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.

    * `validatorId` — ID of the validator to which the tokens were delegated.

    * `withdrawId` — identifier of the withdrawal request represented as an integer between 0 and 255; up to 256 in-flight withdrawal requests are available.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-monad) the transaction to the Monad network.

    <Note>
      Note that it may take up to 12 hours to undelegate your tokens depending on the request time, since Monad uses a system of epochs, each of which lasts around 5,5 hours.

      In order to ensure fairness and network security when you deactivate your stake, it will remain locked up until remaining this epoch.
    </Note>
  </Step>

  <Step title="Create withdrawal request">
    1. To withdraw undelegated tokens, send a POST request to [/api/v2/monad/\{network}/delegators/\{delegatorAddress}/stakes/withdrawals](/reference/monad-delegators-create-withdrawal).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/withdrawals \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "gas": {
          "priorityPricePerGas": "21000",
          "maxPricePerGas": "1000000000"
        },
        "withdrawId": 0
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/withdrawals", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "gas": {
            "priorityPricePerGas": "21000",
            "maxPricePerGas": "1000000000"
          },
          "withdrawId": 0
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/withdrawals",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "gas": {
                  "priorityPricePerGas": "21000",
                  "maxPricePerGas": "1000000000"
              },
              "withdrawId": 0
          },
      )
      print(response.json())
      ```

      ```go Go theme={null}
      package main

      import (
      	"bytes"
      	"encoding/json"
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	payload := map[string]interface{}{
      		"gas": map[string]interface{}{
      			"priorityPricePerGas": "21000",
      			"maxPricePerGas": "1000000000",
      		},
      		"withdrawId": 0,
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/withdrawals", bytes.NewBuffer(body))
      	req.Header.Set("Authorization", "Bearer <token>")
      	req.Header.Set("Content-Type", "application/json")
      	resp, _ := http.DefaultClient.Do(req)
      	defer resp.Body.Close()
      	respBody, _ := io.ReadAll(resp.Body)
      	fmt.Println(string(respBody))
      }
      ```
    </CodeGroup>

    * `delegatorAddress` — delegator address on the Monad network.
    * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load.
    * `withdrawId` — identifier of the withdrawal request.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "createdAt": "2025-05-06T10:40:00.000Z",
            "delegatorAddress": "0x1234567890abcdef1234567890abcdef12345678",
            "gas": {
              "gasLimit": "260850",
              "priorityPricePerGas": "1000000000",
              "maxPricePerGas": "2000000000"
            },
            "unsignedTransaction": "0x02f8758301e24004...",
            "validatorId": 1,
            "withdrawId": 0
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `createdAt` — timestamp of the transaction in the ISO 8601 format.

    * `delegatorAddress` — delegator address on the Monad network.

    * `gas` — computational effort required to execute the transaction measured in gas units:

      * `gasLimit` — maximum gas limit for the transaction.
      * `priorityPricePerGas` — price per unit of gas in Wei (1 Wei = 10⁻¹⁸ MON), which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction.
      * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei (1 Wei = 10⁻¹⁸ MON).

    * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.

    * `validatorId` — ID of the validator from which the tokens are withdrawn.

    * `withdrawId` — identifier of the withdrawal request.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-monad) the transaction to the Monad network.
  </Step>
</Steps>


## Related topics

- [Sign and Broadcast Transaction](/docs/signing-transaction-monad.md)
- [Staking API reference](/reference/monad-delegators-create-delegation.md)
