0

I need to read and write some Uniswap Transactions using Nethereum/Web3. The uniswap methds expect BigInteger data types, but the UI expects so called Display unit types, which essentially convert the BigInteger type into a decimal, using the number of decimals of the ERC20 token contract in question.

If I know that the token I'm working with has 9 decimals and the value is given is 12356789123456, how do I convert that number to one with 9 decimals? I.e. shift the decimal point to the left 9 spaces?

Similarly, if a user enters 0.01 BNB, how do I convert that to a BigInteger if I know that BNB has 18 decimal points? I.e. shift the decimal point to the right 18 spaces?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.