Chapter 13, Writing Secure ContractsÂ
Msg.sender
refers to the immediate caller whiletx.origin
refers to the original caller inchain
.tx.origin
is always an externally owned account whereas themsg.sender
value can be a contract account or an externally owned account.- Recursion happens because the
receive
function in thehacker
contract calls thewithdraw
function, which, in turn, calls thereceive
function unknowingly because it transfers Ether to thehacker
contract. - Checks, effects, and the interaction pattern are three distinct stages in a sequence within a function that change the contract state and help transfer tokens and Ethers to other accounts securely. All incoming argument validation for correctness is executed as part of the check stage. This stage also includes validating the current state of the contract. By checking that the context and environment are at the conducive stage, the check stage ensures that nothing goes wrong from a state and incoming...