Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mohammadsadeghforoughi/d97599f1f8d85138e2e9a4043bfbac3c to your computer and use it in GitHub Desktop.
Save mohammadsadeghforoughi/d97599f1f8d85138e2e9a4043bfbac3c to your computer and use it in GitHub Desktop.
How to get token decimals in web3
// 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