-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Token Value #1
Comments
Have you ever met the situation that you can sell normally when Decimals is 18, but report an error when Decimals is 9? |
I too am able to make a successful sell only when decimals == 18. |
Hey guys, I still have the same problem. Did you find anything new? I tried to calculate the value with balance = balanceOf * math.pow(10, dec) |
My token is 18 decimals. I got this error message.
File "C:\Python37-32\lib\site-packages\web3\contract.py", line 1089, in buildTransaction |
Call the decimal of the token you are trying to sell and use that instead of ether |
When you convert the token value from and to wei, you use the built in functions with the parameter 'ether'. However, if the number of decimals of the token that we are selling is different from that of (W)BNB this will give the incorrect value. You want to obtain the decimals from the token contract and then do something like
balance = raw_balance / math.pow(10, decimals)
raw_balance = balance * math.pow(10, decimals)
The text was updated successfully, but these errors were encountered: