I want to accept erc20 payment in my smart contract. Currently the user has to approve the tokens and then my contract executes transferFrom. I am worried that from the user's perspective this is 2 txs which he has to pay gas for. Is there a better approach?

Oct 5, 2020, 7:19 AM
This is the way.
Unfortunately everything goes this way these days. It's only about 1 dollar though to approve.
Oct 5, 2020, 7:30 AM
Use INF as input in approval so you don't have to ask user for unlock everytime but just like a one time signup/unlock per erc20
Oct 5, 2020, 7:33 AM
Yes, they only have to do it once.
Oct 5, 2020, 7:35 AM
I think that is not a better approach as it makes the whole balance of user's erc20 tokens vulnerable in case my contract gets hacked. also, user may acquire new tokens in the future so his balance may change and he has to do the approval again
Oct 5, 2020, 7:37 AM
If its set to INF then doesn't matter if balance changes, uniswap currently now approve with 'unlimited' and many others...
Oct 5, 2020, 7:40 AM
yeah, then this is not the problem in this case
but it will be still a pain in the ass the first time for the user
Oct 5, 2020, 7:41 AM
Ideally only users themselves should be able to call the function of transferFrom regardless of the other functionalities
Oct 5, 2020, 7:41 AM
if he is new, unexperienced eth user, he may think that he has to go through this pain process every time
and may leave after the 1st try
Oct 5, 2020, 7:41 AM
So even when contract is compromised it won't matter
Oct 5, 2020, 7:41 AM
you know, even uniswap has a lot of complains in their support channel where users say that they didn't receive the tokens but appearantly they just executed approve, not swap
Oct 5, 2020, 7:42 AM
Yeah technically we are stuck with conventions so now it's a question of UX
Don't think this is an issue for uniswap v2 interface, the UI shows it pretty well as a 2 step process
Oct 5, 2020, 7:43 AM
yes, Uniswap does it well. I mean some users are new or let's say a little bit dumb, so they mess it up
this erc20 fee is supposed to be very small (around $1) so this extra tx may not be feasible especially when gas prices are high
Oct 5, 2020, 7:45 AM
What happens if a Contract uses a chainlink oracle, and that HTTP GET takes quite a long time to return. Does that slow down the processing of the block?
Oct 5, 2020, 7:51 AM
Callback function execution will become slow and data modifications inside that will take time to happen
Oct 5, 2020, 8:01 AM
how does mining work, with a block do all transactions have to complete, so if a trasnaction that makes an API call via an oracle is slow does that slow down the block being mined?
Oct 5, 2020, 8:11 AM
it can be mined and sent back in another block
Oct 5, 2020, 8:12 AM
look up approve and call
Oct 5, 2020, 10:22 AM

© 2024 Draquery.com All rights reserved.