How do I create an Ethereum contract which itself create multiple transactions as a result of a single invocation.
Can anyone help me out here?
contract-developmentsolidity
How do I create an Ethereum contract which itself create multiple transactions as a result of a single invocation.
Can anyone help me out here?
Best Answer
You make a Splitter contract to handle the rules and get A to send to the contract.
I wouldn't be especially hard to code, but for security reasons, you don't want to do it all at once.
Instead, have A send 20 to a contract. Have the contract calculate four equal parts and record amounts owed to B, C, D and E.
Have another function to facilitate on-demand withdrawals. B, C, D and E claim their allocations when they wish. Each withdrawal transaction is kept separate from the others.
Question rhymes with this (splitter with different rules): https://stackoverflow.com/questions/42990292/smart-contract-limitations-in-ethereum-fabric
Hope it helps.
Update:
Naive Example:
This contract doesn't conform to recommendations for the safe handling of funds. It will seem to work for a while. Edge cases (deliberate accidental) will cause serious problems.
Very simplistic example: