For Developers
Smart Contract API
Binance Liquid Staking API

BNB Liquid Staking API

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

Switch aBNBb to ankrBNB

unlockShares(shares)

Switches aBNBb to ankrBNB.

Parameters

shares (uint256, required) — amount of aBNBb to be switched to ankrBNB.

Smart contract
Example

Mainnet live transaction example (opens in a new tab)

Stake BNB and claim ankrBNB

stakeCerts(payableAmount)

Stakes BNB and claims ankrBNB.

Parameters

payableAmount (BNB, required) — amount of BNB to be staked.

Smart contract
Example

Mainnet live transaction example (opens in a new tab)

Unstake ankrBNB and get BNB

unstakeCerts(shares)

Unstakes ankrBNB and gets BNB for the unstaked ankrBNB.

Parameters

shares (uint256, required) — amount of ankrBNB to be unstaked.

Smart contract
Example

Get APR

averagePercentageRate(uint256 day, address addr)

Gets the APR for ankrBNB.

The formula is best expressed by an example.

With 3 provided as the depth, the APR = ((((day 3 - day 2) / day 3) * 100) + ((day 2 - day 1) / day 2) * 100) + ((day 1 - current day) / day 1) * 100) / 3) * 365.

Parameters
  • day (uint256, required) — number of days to get the APR for. Max value — 7 days.
  • address (address, required) — address of the token contract. The address of ankrBNB is 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827.
Smart contract
Example

averagePercentageRate being a read function, we suggest you visit the links and make a query entering a desired number of days to see an example.

Get staking metrics

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