BNB Liquid Staking API
To integrate with BNB Liquid Staking, use the smart contract functions and examples below.
Stake BNB and claim ankrBNB
stakeCerts(payableAmount)
Stakes BNB and claims ankrBNB.
Parameters
payableAmount
(BNB, required) — amount of BNB to be staked.
Smart contract
- Mainnet BNBStakingPool Proxy (opens in a new tab) (0x9e347af362059bf2e55839002c699f7a5bafe86e)
- Testnet BNBStakingPool Proxy (opens in a new tab) (0x0ecf14f54c5ff190e025bc5e80c6351f91bfcb1c)
Example
- Mainnet live transaction example (opens in a new tab)
- Testnet live transaction example (opens in a new tab)
Unstake ankrBNB and get BNB
Unstaking ankrBNB is a two-step process:
- Approve access to ankrBNB.
- Unstake ankrBNB.
approve(spender, amount)
Approve access for the aBNBb contract to the specified amount of ankrBNB.
aBNB is a legacy contract used in Ankr's BNB Liquid Staking.
Parameters
sender
(address, required) — address of aBNBb. Possible values:0xfe39985D7eFF914c50A06bA0cFfcCA8361e00C0e
for Mainnet0x93405327644eDF8aD908e41F9a2Ecbb6714769D1
for Testnet.
amount
(uint256, required) — amount of ankrBNB to approve access to.
Smart contract
- Mainnet ankrBNB (opens in a new tab) (0x52f24a5e03aee338da5fd9df68d2b6fae1178827)
- Testnet ankrBNB (opens in a new tab) (0x3c1039c346bd5141bf2d5e855928e61655658fa7)
Example
- Mainnet live transaction example (opens in a new tab)
- Testnet live transaction example (opens in a new tab)
unstakeCerts(shares)
Unstakes ankrBNB and gets BNB for the unstaked ankrBNB.
Parameters
shares
(uint256, required) — amount of ankrBNB to be unstaked.
Smart contract
- Mainnet BNBStakingPool Proxy (opens in a new tab) (0x9e347af362059bf2e55839002c699f7a5bafe86e)
- Testnet BinancePool Proxy (opens in a new tab) (0x0ecf14f54c5ff190e025bc5e80c6351f91bfcb1c)
Example
- Mainnet live transaction example (opens in a new tab)
- Testnet live transaction example (opens in a new tab)
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 is0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827
.
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.