I am rethinking the flow for token transfer and confirmation on the network (ERC20,ERC721...).

I am unaware of a way presently to:

1- transfer tokens and
2- trigger a call in different contract,

all in one transaction, with the call to the different contract still originating from the msg.sender(owner of the tokens).
i am aware, that it can be achieved n two transactions.

While investigating, I thought about the possibility of smart contracts relaying raw signed transactions, the same way it could be sent to a rpc endpoint.

Flow (modifier style):

  • User signs transaction to send tokens to an address
  • User sends the transaction to the smart contract as bytes
  • contract relays the signed transaction, which should maintain the msg.sender of the owner of the tokens.
  • contract confirms the transaction was successful, then calls next function

This is based on the assumption, that you do not have control over token smart contract, so you can not design the function to support it. SO, basically should work for any token already deployed on the network.

  • Just to make sure: you do realize you can have it all in one transaction if the token transfer function supports such extra stuff? Commented Mar 13, 2019 at 19:53
  • 1
    @LauriPeltonen Yes, I am aware, that was why I added the condition, that you do not have control of the token smart contract, so you can't have those extra stuff in.
    – Adibas03
    Commented Mar 13, 2019 at 20:01

1 Answer 1


Unfortunately a contract can't handle raw transactions. We would face all sorts of new issues if it was possible (such as who pays for the gas).

Nothing prevents you from creating your own contract which transfers tokens and triggers another contract. But this way the contract would have to own the tokens itself so they'd need to be transferred to the contract in advance, which would probably make this option rather pointless.

Alternatively, you could give token transfer allowance to your custom contract. This might make your scenario a bit more plausible, depending on your specific business needs.

  • You are right, requiring preapproval, or having transferred the tokens prior would work just fine, but those would require needing two steps to complete the process: Approval/transfer, then external contract call. I was hoping there was some sort of hacky method using assembly, that might bring the possibility a step closer.
    – Adibas03
    Commented Mar 13, 2019 at 20:49
  • Depending on your business needs, it might be feasible to for example first once approve a lot of token transfers and then later utilize those approvals in a single transaction, once a day or whatever Commented Mar 14, 2019 at 7:16
  • Thanks Lauri. I guess I am stuck with two-stepped procedure for now. Hopefully, down the line, we would have a single transaction flow, which would greatly help user experience imo.
    – Adibas03
    Commented Mar 14, 2019 at 8:39

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.