I wrote my erc20 token by solidity and the decimals of token is 18. I'm testing the smart contract on truffle and one thing that I noticed was the octal number is returned when I called the balanceOf() function. I want to check the balance of accounts as decimals which is fixed as 18. For example, I want to transfer the 1.001 or 22.0000003 and then get the return value of balanceOf() as 23.0010003. However, this is the result I got.

> cc.transfer(user1, 000000000000000100, {from: owner})
{ [String: '512'] s: 1, e: 2, c: [ 512 ] }

How can I transfer or check the balance as fixed 18 Decimals not the octal number? Please help!

1 Answer 1


In JavaScript, a leading zero indicates an octal number.

Just don't include the leading zeros. Use 100.

  • I get it. When I call balanceOf() function on Remix, it returned the number like 10010000000000000100123. The actual balance is 10010.000000000000100123. I was confused! Thanks a lot!! Apr 2, 2018 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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