Last active
February 22, 2024 09:19
-
-
Save earthchie/bc528f3bcbc1ef00b43c40ab9238cbd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ethers = require('ethers'); | |
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/'); | |
// you can find pair address from Factory Contract, method getPair(token1Addr, token2Addr). | |
let Contract = { | |
PancakePair: new ethers.Contract('0xb694ec7C2a7C433E69200b1dA3EBc86907B4578B',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider), | |
TwindexPair: new ethers.Contract('0xC789F6C658809eED4d1769a46fc7BCe5dbB8316E',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider) | |
} | |
provider.on('block', async (blockNumber) => { | |
const pancakeReserves = await Contract.PancakePair.getReserves(); | |
const at_pancake = pancakeReserves[1] / pancakeReserves[0]; | |
console.log(`Pancake 1 DOP = ${at_pancake} BUSD`); | |
const twindexReserves = await Contract.TwindexPair.getReserves(); | |
const at_twindex = twindexReserves[1] / twindexReserves[0]; | |
console.log(`Twindex 1 DOP = ${at_twindex} BUSD`); | |
}); |
No idea. Because this script should be read-only mode, which should not cost any gas.
I got the error "cannot estimate gas" on some coins, any idea?
try to change token to other one.
I get exactly the same message "Unhandled Rejection (Error): cannot estimate gas; transaction may fail or may require manual gas limit"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got the error "cannot estimate gas" on some coins, any idea?