Skip to main content

MATIC Liquid Staking API

To integrate with MATIC Liquid Staking, use the smart contract functions and examples below.

Stake MATIC and claim aMATICb​

approve(spender, value)​

Lets the PolygonPool smart contract transfer user's MATIC tokens.

Parameters​
  • spender (address, required) β€” address of the PolygonPool contract.
  • value (uint256, required) β€” amount of MATIC to be staked.
Smart contract​

Testnet Matic.

Example​

Testnet live transaction example.

stakeAndClaimBonds(amount)​

Stakes MATIC and claims aMATICb for the staked MATIC.

Parameters​

amount (uint256, required) β€” amount of MATIC to be staked.

Smart contract​

Testnet PolygonPool Proxy.

Example​

Testnet live transaction example.

Stake MATIC and claim aMATICc​

approve(spender, value)​

Lets the PolygonPool smart contract transfer user's MATIC tokens.

Parameters​
  • spender (address, required) β€” address of the PolygonPool contract.
  • value (uint256, required) β€” amount of MATIC to be staked.
Smart contract​

Testnet MATIC.

Example​

Testnet live transaction example.

stakeAndClaimCerts(amount)​

Stakes MATIC and claims aMATICc for the staked MATIC.

Parameters​

amount (uint256, required) β€” amount of MATIC to be staked.

Smart contract​

Testnet PolygonPool Proxy.

Example​

Testnet live transaction example.

Unstake aMATICb and claim MATIC​

unstakeFee​

RESTful API endpoint that returns the current fee value for the unstaking operation.

Host​

https://api.dev.stkr.io/

Endpoint​

GET /v1alpha/polygon/unstakeFee

Parameters​
  • address (address, required) β€” address of the staker.
Request​
curl https://api.dev.stkr.io/v1alpha/polygon/unstakeFee?address=0x0000000000000000000000000000000000000000
Response​
200​
{"unstakeFee":"50000000000000000000","useBeforeBlock":6946279,"signature":"0x7ed0ac683aca82358813f0e40dd2f636b1e12e48d9c3f79194272b8da26cb770273d5c39d99981e8387f6d8c1ae69e9a3bb0dd4fd76cfb92d8ab3b1d3a0094e51c"}

approve(spender, value)​

Lets the PolygonPool smart contract transfer user's ANKR tokens (needed to pay fees when unstaking aMATICb).

Parameters​
  • spender (address, required) β€” address of the PolygonPool contract.
  • value (uint256, required) β€” amount of ANKR to be transferred.
Smart contract​
Example​

unstakeBonds(uint256 amount, uint256 fee, uint256 useBeforeBlock, bytes signature)​

Lets the PolygonPool to exchange aMATICb for MATIC.

Parameters​
  • amount (uint256, required) β€” amount aMATICc to be unstake.
  • fee (uint256, required) β€” fee paid in ANKR for the unstaking operation. Get the value from the unstakeFee endpoint response.
  • useBeforeBlock (uint256, required) β€” last valid blockchain block to unstake before. Get the value from the unstakeFee endpoint response.
  • signature (bytes, required) β€” notary signature for the fees. Get the value from the unstakeFee endpoint response.
Smart contract​
Example​

Unstake aMATICc and claim MATIC​

unstakeFee​

RESTful API endpoint that return the current fee value for the unstaking operation.

Parameters​
  • address (address, required) β€” address of the staker.
Request​
GET https://api.dev.stkr.io/v1alpha/polygon/unstakeFee?address=0x0000000000000000000000000000000000000000
Response​
200​
{"unstakeFee":"50000000000000000000","useBeforeBlock":6946279,"signature":"0x7ed0ac683aca82358813f0e40dd2f636b1e12e48d9c3f79194272b8da26cb770273d5c39d99981e8387f6d8c1ae69e9a3bb0dd4fd76cfb92d8ab3b1d3a0094e51c"}

approve(spender, value)​

Lets the PolygonPool smart contract transfer user's ANKR tokens (needed to pay fees when unstaking aMATICb).

Parameters​
  • spender (address, required) β€” address of the PolygonPool contract.
  • value (uint256, required) β€” amount of ANKR to be transferred.
Smart contract​
Example​

approve(spender, amount)​

Approves the aMATICb smart contract to transfer user's aMATICc tokens to itself from the aMATICc smart contact and burn them.

Parameters​
  • spender (address, required) β€” address of the aMATICb contract.
  • amount (uint256, required) β€” amount of aMATICc to be burned.
Smart contract​
Example​

unstakeCerts(uint256 shares, uint256 fee, uint256 useBeforeBlock, bytes signature)​

Lets the PolygonPool to exchange aMATICc for MATIC.

Parameters​
  • shares (uint256, required) β€” amount aMATICc to be unstake.
  • fee (uint256, required) β€” fee paid in ANKR for the unstaking operation. Get the value from the unstakeFee endpoint response.
  • useBeforeBlock (uint256, required) β€” last valid blockchain block to unstake before. Get the value from the unstakeFee endpoint response.
  • signature (bytes, required) β€” notary signature for the fees. Get the value from the unstakeFee endpoint response.
Smart contract​
Example​

Get staking metrics​

To integrate Ankr Staking metrics into your dashboards or use metrics like APY in your products, read Liquid Staking Metrics.