Need some help. Getting different chain IDs when using different calls

Hi,
When trying to get the current chainId I get different results from different functions

const { chainId } = useMoralis(); 
// 0x4

Moralis.getChainId()
//4

I need these two to match… Any idea how I could get ‘0x4’ out of Moralis.getChainId()

Hey @niknak, they are both the same, the one that starts with 0x is hex number, you can use 3rd party library to hep convert it, e.g. https://www.npmjs.com/package/hex2dec

2 Likes

Hmmm, gotcha
This seems to work (Number(‘0x4’) == 4)

Thanks!

2 Likes