Using Solidity, how can I transfer ERC20 tokens from the current address to another?

Is it done using call or send? Are the balances kept in the token contract or in the address that the tokens belong to?


ERC20 Token contracts store the balances of users in its state. The exact specification of the ERC20 token contracts can be found here: https://theethereum.wiki/w/index.php/ERC20_Token_Standard

The transferFrom function can be used to transfer tokens from one address to another. function transferFrom(address _from, address _to, uint _value) returns (bool success);

This function has to be called as a transaction in order to make changes in the balance (i.e. state of the contract). The difference between a call and a transaction is detailed here. What is the difference between a transaction and a call?


To transfer EIP20 Token from another contract, use

EIP20 token = EIP20(_tokenAddr);

and call tansferFrom function to transfer tokens from one address to another; like;

token.transferFrom(msg.sender, this, _value);

Note: Before you do this, do call the approve function on the Token Contract to allow this contract to use tokens on your (or msg.sender) behalf.

approve(this, _amount)
  • How to call approve from the senders' address? – CryptoScroller Jan 22 '19 at 17:01
  • They must be both be called from the sender of the tokens into two separate transactions. – Martin Tonev Feb 9 at 20:26
  • Does EIP20 have to be the specific contract for that token or is there a general method that works for all EIP20 tokens? – mdornfe1 May 6 at 5:53

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.