1

I have deployed an erc20 contract on ethereum testnet and want to transfer a fraction of erc20.

I used the transfer function to transfer tokens but I don't have any idea how can I transfer a fraction of a token using the transfer function.

1 Answer 1

2

ERC-20 tokens actually do not have fractions, but internally use 256-bit words for accounting.

It is just convention that we set the decimal point on 10 exp 18 on this number, to communicate with humans.

So you can transfer a fraction of tokens by just calling transfer() with a number that is less than 10 exp 18.

3
  • I am using remix IDE and the transfer() doesn't accept value in decimal like "0.5" so how should I transfer in fraction? Jun 15, 2021 at 5:07
  • 1
    Here is an answer: wolframalpha.com/input/?i=0.5*10%5E18 Jun 15, 2021 at 8:11
  • Pleae note that StackExchange breaks the link above, it should be a calculation Jun 16, 2021 at 8:54

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.