Questions tagged [decimals]
The decimals tag has no usage guidance.
42 questions
0
votes
0
answers
16
views
Subdecimals in ERC20 tokens and wallets?
Is there any standard or any discussion of standard for wallets to display not the standard unit of a token, but perhaps 10^-3n, such as one thousandth, one millionth. Much like wei, gigawei, etc. ...
1
vote
2
answers
46
views
Does anyone know any stablecoins that has more than 18 decimals?
Does anyone know of any stablecoins that have more than 18 decimals?
I only see fewer than 18 decimals, not more.
0
votes
0
answers
31
views
How to convert takerRate to readable value from 1inch API OrderBook?
I use 1inch API to get a list of order limits by the specific token.
https://portal.1inch.dev/documentation/orderbook/introduction
pair AXL/axlUSDC
and I get a response something like that:
[
{
...
1
vote
1
answer
112
views
Any actively used ERC20 tokens that have more than 18 decimals?
Any examples? I'm wondering if there's a strong reason to support tokens with more than 18 decimals.
Please note it's related to, but different from the question "Can an ERC-20 have more than 18 ...
0
votes
2
answers
801
views
Does solidity interpret 1e18 as 1,000,000,000,000,000,000 or as 1.000000000000000000?
Say I have a super simple function like the following one which just returns 1e18. If I test this in remix I get 1000000000000000000. But I'm second guessing myself because I am new to this and I am ...
0
votes
1
answer
38
views
What does decimals/fungible token normalization mean? I need help with mitigating precision loss
What is the code to convert them to correct decimals without precision loss?Does it mean that you should make all the token decimals to a certain standard of the protocol? Let say 18?
If Token A is 16 ...
0
votes
1
answer
60
views
Incorrect Decimals & Max Total Supply ERC20 Token
After deploying token contract on ethereum I am getting 0 decimals being shown on etherscan whilst other explorers displaying correctly.
I presume because of this Max Total Supply displays as:-
3,200,...
0
votes
1
answer
25
views
Using decimals in intermediate calculations?
I'm looking at a contract that takes a uint88 and divides by the product of a uint80 and a uint104. The uint80 is the inverse of ETH/USDC (ie, it is the price of one USDC in terms of ETH)...obviously ...
4
votes
2
answers
252
views
Why uint8 for decimals in ERC20 tokens?
Is there a specific reason why pretty much everyone uses uint8 for the decimals in ERC20 tokens?
I would get it if it was to limit the size, because the decimals will never be big enough to exceed the ...
3
votes
1
answer
38
views
Issue with sending tokens after performing arithmetic operations
I'm implementing a fundraising contract where a user can create a fundraiser but when creating they must send a rewardingToken (ERC20 token) to the contract and the user also specifies a token which ...
2
votes
2
answers
436
views
Strategy in saving and displaying ETH decimal places
What is your strategy for storing and displaying decimal places for ETH?
I noticed most exchanges use only 4 (Binance) to 8 (CEX) decimal places when displaying ETH amount. What is your take?
And do ...
0
votes
1
answer
281
views
Can't make it compatible with 9 decimals tokens (newbie question)
I'm trying to fork a miner contract. Everything works fine with 18 decimals tokens, but I just can't make it work with 9 decimals tokens (which is the main target of what I'm trying to do). The ...
0
votes
1
answer
403
views
Why does chainlink price feed use 8 as decimal in USD pairs? [duplicate]
I am trying to implement Chainlink's price feed in my contract.
I've learned that when using the USD pair, it always uses 8 as the decimal.
I am curious as to why 8 is used instead of 18, is there a ...
0
votes
0
answers
183
views
Etherscan Shows Token TotalSupply with all 18 Decimals. Why?
I just deployed the token smart contract and Etherscan shows the TotalSupply with all 18 decimals for some reason. Basically, it shows excessive 18 zeroes in the TotalSupply section. Could you please ...
3
votes
1
answer
182
views
Any known ERC20 Tokens that don't implement the decimals() function?
Are there any ERC20 Tokens that don't implement the decimals() functionality?
1
vote
1
answer
442
views
I dont understand how to use ABDKMath64x64 for mul and div
If i console.log this
ABDKMath64x64.add(3, 2);
I get the result of BigNumber { value: "5" } which is correct.
But
ABDKMath64x64.mul(3, 2);
returns BigNumber { value: "0" }
and
...
0
votes
1
answer
315
views
What should be the decimals for ERC20 token when you want to deploy in Solana network using NeonEVM?
I'm trying to get my head around the concept of this decimal in Eth. Should I change the decimals when I want to deploy outside of the Ethereum network? What would be the correct decimals value when I ...
2
votes
1
answer
1k
views
What is the best way to divide BN by a decimal?
I am using ethers npm library to divide BN by a decimal. The account(0x..) has 10.99999 GLD.
const {ethers} = require('ethers');
const token = myGoldContract.balanceOf('0x....').toString();
console....
1
vote
0
answers
39
views
I created a custom token in my wallet and sent tokens to it after the didn't show up I I put wrong decibel can it be fixed? [closed]
Trust wallet etherscan shows coins to bi in my wallet with the rest of my coins
But wallet shows no coins for the one I made custom token I put 12 decibel instead of 9 how can I fix this?
0
votes
3
answers
1k
views
Uniswap V2, getAmountsOut and toWei/fromWei
I have a simple code to get prices from Uniswap V2
const getTokenExchangeRate = async (tokenA, tokenB) => {
return (
await dexRouter.methods.getAmountsOut(toWei("1"), [tokenA, ...
0
votes
0
answers
27
views
How do I remove decimals from a uint256 [duplicate]
I am calculating a buyPrice that has a factor of 1.2 times the normal price.
To do this I get the token price and multiply it by 1200000000000000000 (18). It looks something like:
uint256 buyPrice = ...
0
votes
1
answer
28
views
Is there a list of all Ethereum unit converters?
I'm interested in converting Ether units to wei, plus other custom token amounts where the decimals may be different to 18.
Is there a list of all Ethereum unit converters?
0
votes
1
answer
240
views
Best Practice to handle big number
i have erc20 token with 18 decimal, the problem is if i want to transfer 100k token, the javascript can't handle that, because there will lot of 0.
so in smart contract i override all the transfer ...
0
votes
0
answers
20
views
how to store and use a fractionnal number for arithmetic operations in solidity? [duplicate]
I am trying to write a presale contract as an exercise that would allow the deployer to collect ether from buyers, then redistribute the amount of tokens proportionately to the amount spent by the ...
0
votes
1
answer
128
views
How to converted a string into four numbers in smart contract?
I want to have a string that can be converted into four numbers.
For example, it converts a string from E17B1237 into (225, 123, 18, 55), this is converted from hexadecimal into decimal.
E1 => 225,
...
7
votes
1
answer
4k
views
Can an ERC-20 have more than 18 decimals?
I've seen most tokens use 18 decimals and USDC use 6 decimals. Is it possible for a token to have over 18?
1
vote
1
answer
319
views
How to calculate $10 of ETH without arithmetic overflow
I'm using Chainlink's pricefeed to get the latest ETHUSD price.
The value returned is 10**8, i.e. if the price of ETHUSD is 3981.43 then the value will be 398143000000.
How can I calculate the WEI ...
0
votes
1
answer
1k
views
Transaction failing due to can't estimate Gas Cost on Polygon
I have a function
function tokenValue( address _token, uint _amount ) public view returns ( uint ) {
return _amount.mul( 10 ** IERC20( MY_TOKEN ).decimals() ).div( 10 ** IERC20( _token )....
1
vote
1
answer
914
views
How convert hex number to decimal in solidity? [duplicate]
I would like to convert a hex number to decimal.
0
votes
2
answers
4k
views
Decimal in Solidity [duplicate]
I'm new to solidity but I program in other languages, solidity looks a bit like javascript but recently I noticed a problem with solidity.
it doesn't accept decimals and float numbers, like "0....
1
vote
2
answers
2k
views
How to choose number of decimal places for token
What should I consider when choosing the number of decimal places for an ERC20 token/stablecoin?
My first thought was to just use 18 which seems to be the standard because Ether uses 18. However ...
1
vote
1
answer
86
views
ERC-20 interface decimal issue
i have created erc20 token with 100000 supply and decimal with 0.
i wonder that if i ask an exchange to list my token. Are these decimal is problem?
regards
1
vote
1
answer
889
views
I'm confused about decimals and total Supply with my erc20 token
I created erc20 token. I want total supply of 50,00,000.
And I want to give 7% tax on every transaction.
So if anyone sends single coin then, how can I get 7% and transfer remaining to receiver?
For ...
3
votes
2
answers
2k
views
price conversion using chainlink ETHUSD price
I'm storing a product's USD value in contract.
mapping (string => uint256) productUSD;
For example, if it's $52 I'd store it as productUSD[_product] = 52;
Now, when people paying in ETH, I want to ...
2
votes
2
answers
2k
views
How can I multiply a fixed decimal var by a uint in solidity?
In base to this example:
Dealing with multiplying fractions in solidity
I am adding th DSMath correctly.
I can operate and compile with integers but if I try to compile a contract with any decimal ...
1
vote
0
answers
1k
views
Division and floor rounding with 18 decimals
I am recreating a UNISWAP-like AMM and have encountered problems anytime I want to divide the balances of tokens in my pool. For example: I want to require() that tokens are deposited in the correct ...
0
votes
1
answer
174
views
I want to store decimal value in a storage variable and later use that variable at same precision in the formula later internally
I want to store uint public MINTING_VELOCITY = 0.000002;
And later use it in the formula: A x t x MINTING_VELOCITY ,where A = 2000 ,t(staking_duration_time) = 120
Issue is currently MINTING_VELOCITY ...
2
votes
1
answer
1k
views
Vyper binary fixed point vs Decimal fixed point
there is something i do not understand in Vyper documentation:
https://vyper.readthedocs.io/en/stable/index.html
Binary fixed point: Decimal fixed point is better, because any decimal
fixed point ...
1
vote
1
answer
2k
views
ERC20 Token convert unit256 format depending on decimal
Hello i am trying to convert unit256 format depending on the decimal value of each token address.
Decimal 9 and 18 ı did converted. they work fine as seen in the code below
but I don't know what to do ...
1
vote
1
answer
206
views
Why do almost all of the ERC20 tokens have even number of decimals?
I'm thinking of creating a token with a decimal point of odd number.
However I'm kind of worried if there is any issue that can be caused by using an odd number for the decimal point.
Is there any ...
0
votes
1
answer
412
views
How to calculate the right amount of a token to use in 0x quote endpoint
I'm trying to use 0x to buy tokens with ETH. I'm following the sample at https://0x.org/docs/guides/swap-tokens-with-0x-api#swap-eth-for-1-dai.
I got the token address, and the decimals. let's say ...
1
vote
1
answer
415
views
Why don't decimals work in solidity?
I've read this question and answer thread about representing decimal values in solidity, and I understand that math is entirely done using fixed-point.
However, I'm curious as to why this is the case. ...