joshma91 / 721poc1

1 stars 0 forks source link

Accepting ERC-20 instead of ETH #4

Open adrianmcli opened 6 years ago

adrianmcli commented 6 years ago

I made this question: https://ethereum.stackexchange.com/questions/52713/how-to-validate-erc-20-payments-into-a-contract

And then I found these:

adrianmcli commented 6 years ago

It seems like doing approve and then transferFrom is the best way.

Some ERC20 tokens have the approve and transferFrom functions. In those cases you can have the user approve some tokens to your contract. Then, they can call a function in your contract which will call transferFrom on the token contract.

This requires the user to execute at least two transactions: one to call approve on the token contract, and one to call a function in your contract which in turn will call transferFrom on the token contract.