We can send tokens using below ERC20 contract methods
- approve() and transferFrom()
- transfer()
Here if i use 2nd option the tokens are directly transferred, while if i use 1st option its a two step process
I am new to this and i want to understand the difference between the two ways?
Best Answer
Transfer method
The transfer method is for a 2 party transfer, where a sender wishes to transfer some tokens to a receiver.
transfer(receiver, amount)
Approve and transferFrom method
The approve + transferFrom is for a 3 party transfer, usually, but not necessarily that of an exchange, where the sender wishes to authorise a second party to transfer some tokens on their behalf.
approve(exchange, amount)
transferFrom(sender, buyer, amount)