# Error using ERC20 transferFrom in a buy function selling tokens

**URL:** <https://forum.openzeppelin.com/t/error-using-erc20-transferfrom-in-a-buy-function-selling-tokens/3186>\
**Category:** Contracts\
**Tags:** erc20\
**Created:** [June 25, 2020, 12:23pm UTC](https://forum.openzeppelin.com/t/error-using-erc20-transferfrom-in-a-buy-function-selling-tokens/3186 "2020-06-25T12:23:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 29, 2020, 4:50am UTC](https://forum.openzeppelin.com/t/error-using-erc20-transferfrom-in-a-buy-function-selling-tokens/3186/4 "2020-06-29T04:50:01Z")

</div>

> [@PreciousChicken](#):
>
> So to conclude: in the code above there is no way; at least the way I’ve structured these contracts; for the ‘from’ element (currently pointing to msg.sender) to point to the actual holder of the coins in a programmatic way?

Correct. `transferFrom` is used with `approve` where first a token holder approves an allowance and then calls a smart contract that can use that allowance with `transferFrom`.

> [@PreciousChicken](#):
>
> So what would be the v3 way of selling tokens for Ether? Would the preferred way be to do it in just one contract? Or are we just saying that the whole concept of selling tokens for Ether is just so 2017 it isn’t the done thing anymore!

You can still use OpenZeppelin Contracts 2.x to create a crowdsale, though I recommend looking at [Points to consider when creating a fungible token (ERC20, ERC777)](https://forum.openzeppelin.com/t/points-to-consider-when-creating-a-fungible-token-erc20-erc777/2915)

You could potentially add your token to a decentralized exchange and provide liquidity. Though a working solution requiring your token should come first.

Distributing tokens to users of your solution is also a way to go.

> [@PreciousChicken](#):
>
> 👍, I’m just trying to extend my familiarisation here, rather than trying to put anything into production; but it never hurts to be precise with language, so thank you.

I think non-fungible tokens (such ERC721) are fun to experiment with. I also like experiments with personal tokens.

---

_[View the full topic](https://forum.openzeppelin.com/t/error-using-erc20-transferfrom-in-a-buy-function-selling-tokens/3186)._
