Last active
April 26, 2021 04:49
-
-
Save Paulius11/ba90af6cd6cac2fd60a565b3ec2fb2e3 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
import Web3 from "web3"; | |
import ERC20ABI from './abi/api-moonDoge.js'; | |
const tokenData = async (token = "") => { | |
const web3 = new Web3( | |
new Web3.providers.HttpProvider("https://bsc-dataseed1.binance.org:443") | |
); | |
if (!token) { | |
var customToken = new web3.eth.Contract( | |
ERC20ABI, | |
"0x3a2646fed69112698d3e8a9ab43ae23974e01a26" | |
); | |
} else { | |
var customToken = new web3.eth.Contract(ERC20ABI, token); | |
} | |
console.log(`token`, token); | |
const name = await customToken.methods.name().call(); | |
const symbol = await customToken.methods.symbol().call(); | |
const decimals = await customToken.methods.decimals().call(); | |
const totalSupply = await customToken.methods.totalSupply().call(); | |
const totalSupplyFixed = | |
(await customToken.methods.totalSupply().call()) / Math.pow(10, decimals); | |
const totalFeesFixed = | |
(await customToken.methods.totalFees().call()) / Math.pow(10, decimals); | |
const balanceOfDeadAddress = | |
(await customToken.methods | |
.balanceOf("0x000000000000000000000000000000000000dEaD") | |
.call()) / Math.pow(10, decimals); | |
var getTaxFee; | |
try { | |
getTaxFee = await customToken.methods._taxFee().call(); | |
} catch (error) { | |
console.log(`getTax`, getTaxFee) | |
} | |
var liquidityFee; | |
try { | |
liquidityFee = await customToken.methods._liquidityFee().call(); | |
} catch (error) { | |
console.log(`getLiquidityFee`, liquidityFee) | |
console.log(error) | |
} | |
return { | |
name: name, | |
symbol: symbol, | |
decimals: decimals, | |
totalSupply: totalSupplyFixed, | |
totalFees: totalFeesFixed, | |
balanceOfDeadAddress: balanceOfDeadAddress, | |
taxFee: getTaxFee, | |
liqFee: liquidityFee | |
}; | |
}; | |
export default tokenData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment