0

Is there any way to make ethereum wallet can input decimal type parameter for contract at "WRITE TO CONTRACT". For example, "sellToken" function, I want user can sell 1.23 tokens. I have see the method to use uint which let user to input 123 and handle logic in contract, but it is not friendly to user. Is there any way to make user just input 1.23?

0

@XLeo, it's great to see that you are thinking about the usability of Ethereum wallets - as this is how we will get more people excited about Ethereum and Dapps.

In the case of most Ethereum tokens - they have a large, integer, quantity, but this also represents a large number of decimal places (the standard is 18 decimals). This, constant, value is defined in the ERC20 standard and is, therefore, usually readable from any token contract.

In this instance where we have 18 decimal places the token balance of 1000000000000000000 can also be represented as 1.0 - one token. Similarly, 1.23 will be represented in the contract as 1230000000000000000.

An Ethereum wallet, therefore, could take a user's input of 1.23 and multiply it by 10^n where n is the number of decimal places e.g. 1.23 * 10^18 to find the uint value that should be entered into the contract's function.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.