> ## 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.

# Polygon

> Unified API + Polygon Integration Workflow

In the following guide, the integration process for the `polygon` chain is covered. The Polygon integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters.

<Warning>
  Polygon staking is only supported on **mainnet**. There is no testnet support for Polygon. Always set `network` to `mainnet` for all Polygon requests.
</Warning>

[Get an authentication token](/docs/authentication) to start using the Unified API.

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

> To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section.

<Note>
  **Key Polygon-specific details**

  * `chain` — always set to `polygon` for Polygon-related requests.
  * `network` — environment in which the transaction is processed. Must always be set to `mainnet`.
  * `stakerAddress` — Ethereum-compatible account address initiating staking, unstaking or withdrawal transactions.
  * `amount` — amount of tokens in MATIC.
</Note>

## Staking flow

### 1. Approve token management

> Note that the flow uses transactions of type 2 (EIP-1559). Staking, unstaking, and withdrawal operations require interaction with smart contracts via prepared transactions.

Approve transferring your MATIC tokens to the staking contract by sending a POST request to [/api/v1/polygon/staking/approve](/reference/polygon-staking-approve).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/polygon/staking/approve \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '
  {
    "amount": "1000000000000000000",
    "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21"
  }'
  ```
</CodeGroup>

* `amount` — amount of tokens in POL to approve staking operations.
* `stakerAddress` — staker account address providing approval.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "serializeTx": "0x02f86c0180830e57e084b6687a7c830f424094455e53cbb86018ac2b8092fdcd39d8444affc3f680b844095ea7b3000000000000000000000000455e53cbb86018ac2b8092fdcd39d8444affc3f60000000000000000000000000000000000000000000000000de0b6b3a7640000c0",
          "to": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6",
          "gasLimit": "1000000",
          "data": "0x095ea7b3...",
          "value": "0",
          "chainId": 137,
          "type": 2,
          "maxFeePerGas": "3060300412",
          "maxPriorityFeePerGas": "940000"
      }
  }
  ```
</CodeGroup>

* `serializeTx` — serialized unsigned transaction ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) format).
* `to` — recipient contract address for approval.
* `gasLimit` — maximum <Tooltip tip="A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.">gas</Tooltip> limit for the transaction.
* `data` — transaction data.
* `value` — amount this transaction is sending in Wei.
* `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137.
* `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope.
* `maxFeePerGas` — maximum price per unit of <Tooltip tip="A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.">gas</Tooltip> this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei.
* `maxPriorityFeePerGas` — price per unit of <Tooltip tip="A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.">gas</Tooltip> in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction.

### 2. Sign and send transaction

Use `serializeTx` to [sign](/docs/unified-api-signing-transaction) the transaction using the Polygon-specific signing logic.

To broadcast the signed transaction to the Polygon network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '
  {
    "chain": "polygon",
    "network": "mainnet",
    "signedTransaction": "<SIGNED_TX_HEX>",
    "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network, always set to `polygon` for Polygon-related requests.
* `network` — must always be set to `mainnet`. Polygon does not support testnet.
* `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.
* `stakerAddress` — staker account address initiating the staking transaction.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "extraData": {
              "transactionHash": "0x2423921ace5d44e1df4f61a966917b738ae1dd3eaad085efc6eef4275e454088",
              "signedTransaction": "<SIGNED_TX_HEX>",
              "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
              "sentAt": "2025-04-23T17:21:11.991Z"
          }
      }
  }
  ```
</CodeGroup>

* `extraData` — additional transaction details:

  * `transactionHash` — hash of the broadcasted approval transaction.
  * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.
  * `stakerAddress` — staking account address initiating the delegate transaction.
  * `sentAt` — timestamp of the transaction in the ISO 8601 format.

### 3. Create staking request

Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/stake \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '
  {
    "chain": "polygon",
    "network": "mainnet",
    "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
    "amount": "1"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — staker account address initiating the staking transaction.
* `amount` — amount of tokens to delegate in MATIC.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
          "unsignedTransactionData": "0x02f86c0180830e57e084a51c350e830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b8446ab150710000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000c0",
          "extraData": {
              "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995",
              "gasLimit": "1000000",
              "data": "0x6ab15071...",
              "value": "0",
              "chainId": 137,
              "type": 2,
              "maxFeePerGas": "2770089230",
              "maxPriorityFeePerGas": "940000"
          }
      }
  }
  ```
</CodeGroup>

* `stakerAddress` — staker account address initiated the delegate transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.

* `extraData` — additional transaction details:

  * `to` — recipient contract address for approval.
  * `gasLimit` — maximum <Tooltip tip="A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.">gas</Tooltip> limit for the transaction.
  * `data` — transaction data.
  * `value` — amount this transaction is sending in Wei.
  * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137.
  * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope.
  * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/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](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction.

### 4. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic.

## Unstaking flow

### 1. Create unstaking request

Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/unstake \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '
  {
    "chain": "polygon",
    "network": "mainnet",
    "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
    "extra": {
      "amount": "1"
    }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — staker account address initiating the undelegate transaction.
* `extra` — additional parameters:
  * `amount` — amount of tokens to undelegate in MATIC.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
          "unsignedTransactionData": "0x02f86c0180830e57e084a8c1ba86830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b844c83ec04d...",
          "extraData": {
              "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995",
              "gasLimit": "1000000",
              "data": "0xc83ec04d...",
              "value": "0",
              "chainId": 137,
              "type": 2,
              "maxFeePerGas": "2831268486",
              "maxPriorityFeePerGas": "940000"
          }
      }
  }
  ```
</CodeGroup>

* `stakerAddress` — staker account address initiated the undelegate transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.

* `extraData` — additional transaction details:

  * `to` — recipient contract address for approval.
  * `gasLimit` — maximum gas limit for the transaction.
  * `data` — transaction data.
  * `value` — amount this transaction is sending in Wei.
  * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137.
  * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope.
  * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/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](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction.

### 2. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic.

### 3. Create withdrawal request

<Note>
  Note that it takes up to 3-4 days to prepare your tokens for unstaking as Polygon uses a system of <Tooltip tip="On Polygon, a means of measure for the undelegate period. 1 checkpoint takes approximately 3 hours. However, some checkpoints could be delayed due to congestion on Ethereum. This period applies to the originally delegated amount and re-delegated amounts. It does not apply to any rewards that were not re-delegated.">checkpoints</Tooltip>. The average undelegate period on Polygon is 80 checkpoints. Withdrawal is only available after the undelegate period ends.
</Note>

Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction).

Example request:

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '
  {
    "chain": "polygon",
    "network": "mainnet",
    "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — staker account address initiating the withdrawal transaction.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21",
          "unsignedTransactionData": "0x02f86c0180830e57e084a51c350e830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b8444e71d92d...",
          "extraData": {
              "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995",
              "gasLimit": "1000000",
              "data": "0x4e71d92d...",
              "value": "0",
              "chainId": 137,
              "type": 2,
              "maxFeePerGas": "2770089230",
              "maxPriorityFeePerGas": "940000"
          }
      }
  }
  ```
</CodeGroup>

* `stakerAddress` — staker account address initiated the withdrawal transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.

* `extraData` — additional transaction details:

  * `to` — recipient contract address for approval.
  * `gasLimit` — maximum gas limit for the transaction.
  * `data` — transaction data.
  * `value` — amount this transaction is sending in Wei.
  * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137.
  * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope.
  * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/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](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction.

### 4. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic.


## Related topics

- [Unified API Reference](/reference/unified-create-stake-transaction.md)
- [Integration Workflow Example](/docs/unified-api-getting-started.md)
- [Networks Supported](/docs/unified-api-networks.md)
