Getting Started

Staking on the Polygon network using the Staking API consists of the following steps:

  1. Approve token management with the Polygon smart contract.
  2. Create a staking request.

After each operation, sign and send the transaction to the Polygon network.

Get an authentication token to start using Staking API.

Request examples are provided using cURL.

1. Approve token management

Allow the Polygon smart contract to manage tokens by obtaining approval. Any amount can be approved, but preferably specify the exact amount ready to stake.

Send a POST request to /api/v1/polygon/staking/approve. Use https://api.p2p.org for production.

Example request:

curl --request POST \
		 --url https://api.p2p.org/api/v1/polygon/staking/approve \
     --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¹⁸ Wei) to approve for staking.
  • stakerAddress — staker account address.

Example response:

{
  "result": {
    "serializeTx": "0x02f86505800214830186a094499d11e0b6eac7c0593d8fb292dcbbf815fb29ae80b844095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000c0",
    "to": "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae",
    "gasLimit": "0.0000000000001",
    "data": "0x095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000",
    "value": "0.0",
    "chainId": 1,
    "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. Create staking request

To create a stake transaction, delegate tokens to P2P validator by sending a POST request to /api/v1/polygon/staking/delegate.

Example request:

curl --request POST \
		 --url https://api.p2p.org/api/v1/polygon/staking/delegate \
     --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¹⁸ Wei) to delegate.
  • stakerAddress — staker account address.

Example response is the same as in the approve token management step.

To complete staking, sign and send the transaction to the Polygon network.

What's next?