Convert hex string to integer (ethers.js) [SOLVED]

Hi guys,

How can I convert a hex sting like "0xa0712d680000000000000000000000000000000000000000000000000000000000000032" to a human readable number?

I’ve tried different methods and none so far gets me the right number. I’m using ethers.js and I cannot find any utility that does that.

Ok, it looks like simple parseInt(hex) does the job. It means there’s sth wrong with my contract then…

you get exact value with parseInt? no rounding problems?

Well for this particular one it should be:


However it turns out the number wasn’t the issue, but how I’m calling methods on the contract. I haven’t done contracts deployment for a while and now I’m just making mistakes :slight_smile: