0

We are trying to bypass allow method and make the contract more UX friendly. And instead of first allowing contract to spend and after calling transferFrom method, we are thinking about just sending ERC20 tokens directly to a contract and triggering function for example to change the state of the contract from deployed to ready ( as per our project)

Is it possible?

3
  • It is possible (but I'm not sure if it has some problem or is safe). After sending the tokens, you need someone to trigger a new tx to call the function that checks if the contract has enough balance and then does the changes (you need ofc the address of the erc20 contract). If the erc20 Contract is yours, then check this Standard (but still in Draft and maybe there is better Standard to solve that problem) github.com/Dexaran/ERC223-token-standard Anyway, Token integration is very risky so take care youtube.com/watch?v=6GaCt_lM_ak
    – Majd TL
    Commented Nov 16, 2021 at 8:50
  • It is not possible under the ERC-20 standard, EIP-777, EIP-1155. There's EIP-2612 that proposes an extension to ERC-20 that allows using a single call to replace approve+transfer.
    – Ismael
    Commented Nov 17, 2021 at 2:47
  • Perhaps reversing your logic the other way around (ie calling a function in your contract that will call transferFrom) might solve it? Commented Nov 18, 2021 at 0:10

1 Answer 1

0

One of the solutions I see for your problem is implement a event listener in Js that will listen for income ERC20 transfers and call the appropriate method on receive with the sender address in argument.

The con of if is you will pay all gas fees because it will be your address that will call the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.