This is more a note to myself as to when is transfer used and when is transferFrom and that with transferFrom you need to have approval of token transfers and for just pure transfer its not needed.
transfer
function: This function allows a token holder to directly transfer their tokens to another address. It does not require any prior approval because the token holder is initiating the transfer of their own tokens. The syntax is generally like transfer(recipient, amount)
, where the sender is the one who is currently connected and authenticated.
transferFrom
function: This function allows an address to transfer tokens on behalf of another address. Before transferFrom
can be executed, the token owner must explicitly allow a third party (the spender) to transfer a specified amount of tokens from their balance. This is done using the approve
function. The approve
function sets an allowance, which is the maximum the spender can transfer on behalf of the owner. After approval, transferFrom
can be used by the spender to transfer the specified amount of tokens up to the allowance. The syntax is like transferFrom(sender, recipient, amount)