Skip to content
Discussion options

You must be logged in to vote

Great question! This is a common confusing part for engineers.

payable functions only work for eth or native gas token functions.

For example:

function doStuff() public payable {
  require(msg.value > 1); 
}

You actually can't transferFrom with ETH/Native Gas tokens!

ERC20s on the other hand, need to use functions like transferFrom since they are smart contracts themselves.

They don't need to be payable, since they don't use ETH!

function doStuff() public {
  IERC20(some_address).transferFrom(address_a, address_b, amount);
}

Does that make sense?

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@TilakMaddy
Comment options

Answer selected by TilakMaddy
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants