> ## 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 TRON with the P2P.org Staking API.

To withdraw staked TRX on the TRON network via the Staking API:

1. Create an undelegate request: remove your votes and unfreeze your TRX.
2. Create a withdrawal request to claim unfrozen TRX.
3. Sign and send the transaction to the network.

<Steps>
  <Step title="Create undelegate request">
    To initiate the token undelegation, send a POST request to [/api/v1/tron/\{network}/staking/undelegate](/reference/tron-staking-undelegate).

    Example request:

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
        --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate' \
        --header 'accept: application/json' \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
          "amount": 1000000,
          "resource": "BANDWIDTH"
      }'
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
          "amount": 1000000,
          "resource": "BANDWIDTH"
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
              "amount": 1000000,
              "resource": "BANDWIDTH"
          },
      )
      print(response.json())
      ```

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

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

      func main() {
      	payload := map[string]interface{}{
      		"delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
      		"amount": 1000000,
      		"resource": "BANDWIDTH",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate", 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 account address.

    * `amount` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).

    * `resource` — type of resources to be used for freezing TRX:

      * `BANDWIDTH` — for regular transactions on the TRON chain.
      * `ENERGY` — for using smart contracts or running DApps.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "error": null,
          "result": {
            "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
            "amount": 10000000,
            "resource": "BANDWIDTH",
            "unsignedTransaction": {
              "visible": false,
              "txID": "e8f2a91ab4ef8a26b1...",
              "raw_data_hex": "...",
              "raw_data": {
                "contract": [
                  {
                    "parameter": {
                      "value": {
                        "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1",
                        "unfreeze_balance": 1000000,
                        "resource": "BANDWIDTH"
                      },
                      "type_url": "type.googleapis.com/protocol.UnfreezeBalanceV2Contract"
                    },
                    "type": "UnfreezeBalanceV2Contract"
                  }
                ],
                "ref_block_bytes": "0e0c",
                "ref_block_hash": "7db974037137d39c",
                "expiration": 1750000200000,
                "timestamp": 1750000140000
              },
            "unsignedTransactionSerialized": "eyJ0eElEIjoidHJ4SWQifQ==",
            "createdAt": "2025-06-03T12:00:00.000Z",
            "voteAccount": "TH7Fe1W8CcLeqN4LGfqX1R9EpsnrJBQJji"
          }
        }
      ```
    </CodeGroup>

    * `delegatorAddress` — delegator account address.

    * `amount` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).

    * `resource` — type of resources used for processing the freeze transaction: `BANDWIDTH` or `ENERGY`.

    * `unsignedTransaction` — original unsigned transaction object returned by tronWeb.

      * `visible` — internal SDK parameter; always set to `false`.

      * `txID` — hash of the transaction.

      * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format.

      * `raw_data` — full decoded transaction structure with all the fields and metadata:

        * `contract` — list of TRON contracts:

          * `parameter.type_url` — TRON protocol contract, e.g., `type.googleapis.com/protocol.UnfreezeBalanceV2Contract`.
          * `parameter.value.owner_address `— TRON account address in the hexadecimal format.
          * `parameter.value.unfreeze_balance` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).
          * `parameter.value.resource` — resource type: `BANDWIDTH` or `ENERGY`.

        * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included.

        * `expiration` — timestamp of the transaction expiration in ms since last epoch.

        * `timestamp` — timestamp of the transaction in ms since last epoch.

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

    * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing.

    * `voteAccount` — address of the Super Representative for voting.
  </Step>

  <Step title="Sign and send transaction">
    Use `unsignedTransactionSerialized` to [sign and send](/docs/signing-transaction-tron) the signed transaction to the TRON network.

    By broadcasting this transaction, you're resetting all votes.

    Note that there is a protocol freeze period before the corresponding TRX tokens will be unlocked. You can verify the withdrawal by several options:

    * Get the delegator account summary via [/api/v1/tron/\{network}/account/\{address}](/reference/tron-account-get). The `availableBalance` parameter will increase after the tokens are unfrozen and unlocked.
    * Check the transaction status via [/api/v1/tron/\{network}/transaction/\{transactionHash}/status](/reference/tron-transaction-status) endpoint.
    * View your account on [Tronscan](https://nile.tronscan.org/).
  </Step>

  <Step title="Create withdraw request">
    To initiate the token withdrawal, send a POST request to [/api/v1/tron/\{network}/staking/withdraw](/reference/tron-staking-withdraw).

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
        --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/withdraw' \
        --header 'accept: application/json' \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
      }'
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch("https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/withdraw", {
        method: "POST",
        headers: {
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u"
        }),
      });
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/withdraw",
          headers={
              "Authorization": "Bearer <token>",
              "Content-Type": "application/json",
          },
          json={
              "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u"
          },
      )
      print(response.json())
      ```

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

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

      func main() {
      	payload := map[string]interface{}{
      		"delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/withdraw", 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 account address.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "error": null,
          "result": {
            "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
            "unsignedTransaction": {
              "visible": false,
              "txID": "c1516c840a85c0d0f027a2842970b1fa72f604e9d48977eded8b4a59e9596bd3",
              "raw_data_hex": "0a025e9c2208c8eb8a95e3fd058640bfb1aebfcd335a5a083812560a3b747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746864726177457870697265556e667265657a65436f6e747261637412170a15414b167d9a29108763f3794cdb295a8c0b60b21b9370df899cbfcd33",
              "raw_data": {
                "contract": [
                  {
                    "parameter": {
                      "value": {
                        "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1"
                      },
                      "type_url": "type.googleapis.com/protocol.WithdrawExpireUnfreezeContract"
                    },
                    "type": "WithdrawExpireUnfreezeContract"
                  }
                ],
                "ref_block_bytes": "5e9c",
                "ref_block_hash": "c8eb8a95e3fd0586",
                "expiration": 1773149067455,
                "timestamp": 1773148767455
              }
            },
            "unsignedTransactionSerialized": "eyJ2a...",
            "createdAt": "2026-03-10T13:19:27.087Z"
          }
        }
      ```
    </CodeGroup>

    * `delegatorAddress` — delegator account address.

    * `unsignedTransaction` — original unsigned transaction object returned by tronWeb.

      * `visible` — internal SDK parameter; always set to `false`.

      * `txID` — hash of the transaction.

      * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format.

      * `raw_data` — full decoded transaction structure with all the fields and metadata:

        * `contract` — list of TRON contracts:

          * `parameter.value.owner_address`— TRON account address in the hexadecimal format.
          * `parameter.type_url`— TRON protocol contract, e.g., `type.googleapis.com/protocol.WithdrawExpireUnfreezeContract`.
          * `type`— TRON protocol contract type

        * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included.

        * `expiration` — timestamp of the transaction expiration in ms since last epoch.

        * `timestamp` — timestamp of the transaction in ms since last epoch.

    * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing.

    * `createdAt` — timestamp of the transaction in the ISO 8601 format.
  </Step>

  <Step title="Sign and send transaction">
    Use `unsignedTransactionSerialized` to [sign and send](/docs/signing-transaction-tron) the signed transaction to the TRON network.
  </Step>
</Steps>


## Related topics

- [Sign and Send Transaction](/docs/signing-transaction-tron.md)
- [Staking API reference](/reference/tron-staking-delegate.md)
