Skip to content

Mc01/bsc-api

Repository files navigation

BSC API

Binance Smart Chain On-Chain API (Live example)

Contracts

API Contract:

Autofarm Proxy:

Pancakeswap Proxy:

Pancakeswap Proxy V2:

Configuration

API first argument is key for accessing proxies:

  • Autofarm Proxy under auto key
  • Pancakeswap Proxy under cake key
  • Pancakeswap Proxy V2 under cake2 key

Autofarm CAKE Vault pid is 7 (full list available on Autofarm Vault contract)

Pancakeswap CAKE Pool pid is 0 (full list available on Pancakeswap Pool contract)

Pancekeswap V2 does not use pids for Pool (first argument can be omitted)

Example usage

Check balance of CAKE token:

address = 0x...
BscApi.getBalance("cake", address)

Get staked CAKE tokens:

cakePoolPid = 0
address = 0x...
BscApi.getStaked("cake", cakePoolPid, address)

Get pending AUTO tokens:

cakeVaultPid = 7
address = 0x...
BscApi.getPending("auto", cakeVaultPid, address)

Get balance, staked and pending for CAKE:

cakePoolPid = 0
address = 0x...
BscApi.get("cake", cakePoolPid, address)

Get balance, staked and pending for CAKE V2:

pid = 0 (is not used)
address = 0x...
BscApi.get("cake2", pid, address)

Read contract

Test it on Etherscan

Example implementation

With Ethers.js