Withdrawal

The withdrawal process in the Polygon network using the Staking API can be done following these steps:

  1. Undelegate staked tokens.

It takes up to 3-4 days to prepare your tokens for unstaking as Polygon uses a system of checkpoints. The average undelegate period on Polygon is 80 checkpoints.

  1. Unstake tokens — available after the undelegate period.
  2. Withdraw unstaked tokens.

After all operations, you need to sign and send the transaction to the Polygon network.

1. Undelegate Staked Tokens

Prepare previously staked tokens to unstake by sending a POST request to ​/api​/v1​/polygon​/staking​/undelegate.

Example request:

curl --request POST \
		 --url https://api-test.p2p.org/api/v1/polygon/staking/undelegate \
     --head 'accept: application/json' \
     --head 'Authorization: Bearer <token>' \
     --head 'Content-Type: application/json' \
     --data '
{
  "amount": "100000000000000000",
  "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17"
}
'
  • amount — amount of tokens in Wei (1 MATIC = 10^18 Wei) to undelegate.
  • stakerAddress — staker account address.

Example response:

{
  "result": {
    "serializeTx": "0x02f86505800214830186a094499d11e0b6eac7c0593d8fb292dcbbf815fb29ae80b844095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000c0",
    "to": "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae",
    "gasLimit": "0.0000000000001",
    "data": "0x095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000",
    "value": "0.0",
    "chainId": 5,
    "type": 2,
    "maxFeePerGas": "0.00000000000000002",
    "maxPriorityFeePerGas": "2"
  }
}
  • serializeTx — serialized unsigned transaction.
  • to — recipient address for this transaction.
  • gasLimit — maximum gas limit for this block.
  • data — transaction data.
  • value — amount this transaction is sending in Wei.
  • chainId — chain ID this transaction is authorized on, as specified by EIP-155.
  • typeEIP-2718 type of this transaction envelope.
  • maxFeePerGas — 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.
  • maxPriorityFeePerGas — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize miners to prioritize this transaction.

2. Unstake Tokens

After the undelegate period on Polygon is complete, unstake your tokens by sending a POST request to /api/v1/polygon/staking/unstake.

Example request:

curl --request POST \
		 --url https://api-test.p2p.org/api/v1/polygon/staking/unstake \
     --head 'accept: application/json' \
     --head 'Authorization: Bearer <token>' \
     --head 'Content-Type: application/json' \
     --data '
{
  "unbondNonce": "100",
  "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17"
}
'
  • unbondNonce — unique identifier (nonce) of the undelegate request.
  • stakerAddress — staker account address.

Example response is the same as in the first Undelegate Staked Tokens step.

3. Withdraw Unstaked Tokens

To withdraw unstaked tokens:

  1. Send a POST request to /api/v1/polygon/staking/withdraw.

Example request:

curl --request POST \
		 --url https://api-test.p2p.org/api/v1/polygon/staking/withdraw \
     --head 'accept: application/json' \
     --head 'Authorization: Bearer <token>' \
     --head 'Content-Type: application/json' \
     --data '
{
  "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17"
}
'
  • stakerAddress — staker account address.

Example response is the same as for the two previous steps.

  1. Sign and send the transaction to the Polygon network.

What's Next?