If I have several transactions in the same function, can I be sure that they will be executed one just after the other.
Example with a dummy code:
Contract store {
constructor() public returns(bool){
return true;
}
function withdraw(){
msg.sender.transfer(address(this).balance)
}
function() payable(){}
}
contract Exploit {
function execute(uint amount) public {
store s = store();
s.tranfer(amount);
// Other code
s.withdraw();
}
}
If we take this example: if I send money to a contract, execute some code, and call the withdraw function to retrieve money from the contract.
Can I be sure that nobody will be able to call withdraw() before I do ? ie:
- Can a miner put his transaction in the middle in hope of mining the block ?
- Can someone listening to an Ethereum node, send a withdraw transaction with a high gas as soon as he sees a payment to the store contract?
Regards,