React to FA2 receiving

Standard way in FA2: invert the control

The standard way in FA2 is to reverse the logic.

From (what you expected to do):

  1. Alice calls transfer on FA2.

  2. Contract C reacts to the receive.

To (what is recommended to do):

  1. Alice calls update_operators on FA2 to add C as operator.

  2. Alice calls C to start the logic.

  3. C reacts to call by calling transfer on FA2 from Alice’s token to itself.

  4. Alice calls update_operators on FA2 to remove C as operator.

Step 1, 2 and 4 starts a transaction. Those three transactions can be batched in one big batch-transaction.

1 Like