Created
January 8, 2022 14:27
-
-
Save mohammadsadeghforoughi/d97599f1f8d85138e2e9a4043bfbac3c to your computer and use it in GitHub Desktop.
How to get token decimals in web3
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
// initate the web3 here | |
const getTokenDecimals = async (address: string) => { | |
const tokenContract = await new web3.eth.Contract(tokenAbi, address); | |
let decimals = await tokenContract.methods.decimals().call(); | |
return decimals; | |
}; | |
let decimals = await getTokenDecimals('0xeae2bbbc0000f605bd37a02c7fe346a3b68b03eb') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment