Say for example i want to execute a smart contract that upon receiving $1000 from person A, immediately executes after it is received which then takes that $1000 and disperses to 5 addresses.
Is this possible? Any links I can read if it is? Im having a hard time finding out if it is. Thanks!
Best Answer
In general this is not possible as you meant it, every time that some EVM instructions are executed there must be someone who is paying for the GAS. So it's not possible to write functions that are automatically triggered and executed when arbitrary situations occur.
However, for your particular situation:
payable
functionERC1363Receiver
interface in your contract.I want to emphasize how in each of these three hypotheses someone has to pay for the GAS that for the first two cases it must be the one that transfers the token (not necessarily the owner).