0

Lets suppose here are user A and smartcontract B and C(sort of regular dapp). A has no token but little ETH for gas, but B has enough tokens(Erc20).

  1. A send TX to B
  2. B send call to C
  3. C receive tokens in B and give service to A. In addition, C check balance of msg.sender while execution.

In this case, which one should I use delegatecall or just call to make this logic feasible?

1 Answer 1

0

If B wants to send the tokens to C he must call the original token contract's transfer function to issue the send. After that transfer has succeeded (it will be done synchronously within the same transaction) B can send some dummy message to C to notify him of the transfer - otherwise C will not know that he has received tokens since it's impossible for contracts to be notified of token transfers.

B can simply call some function in C such as iHaveSentYouTokens and C can then verify his token balance from the same token contract and perform the service for A.

11
  • Is it delegatecall? or just call?
    – ikaop
    May 24, 2019 at 9:27
  • Just a normal function call May 24, 2019 at 9:48
  • Hi @Lauri, is there any requirement for dapp to be adopted as contract C in this case?
    – ikaop
    May 28, 2019 at 6:48
  • Sorry, I don't understand the question. If you mean whether C has to be a contract then yes, it has to be a contract, otherwise it can't perform anything automatically. May 28, 2019 at 6:51
  • C is contract. I am asking can any contract be adopted as contract C. or, is there any requirement here.
    – ikaop
    May 28, 2019 at 6:54

Your Answer

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

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