cd reading-data-pancakeswap-v2
npm init -y
npm install
mkdir client
cd client
touch GetPrices.js
npm install ethers@5.6.4
Create AddressList.js
in ./client/
- View address and ABI of Factory: PancakeSwap Factory V2
- View address and ABI of Router: PancakeSwap Router V2
- View BUSD address and ABI: BUSD Token on BscScan
- View WBNB address and ABI: WBNB Token on BscScan
- View UniswapV2Pair ABI: Uniswap V2 Pair ABI
Create AbiList.js
in ./client/
- Find source code from BscScan by contract address
- Get ABI from the source code or documentation of PancakeSwap
Edit GetPrices.js
- BSC JSON-RPC Endpoint: BSC RPC
Run:
node client/GetPrices.js
- Use
getAmountsOut
function