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.senderof 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.