Skill 2.2.3
Call and create other contracts
Key Concepts
The safest way to call another contract is through its interface: IERC20(token).transfer(to, amount). The compiler encodes the call, checks the return data and reverts if the callee reverts. try IExternal(x).f() returns (uint v) { ... } catch { ... } handles failures without reverting the caller.
Low-level address.call(data) returns a success flag and raw return data and never reverts on its own. staticcall forbids state changes. delegatecall runs the callee's code in the caller's context: the caller's storage, balance, msg.sender and msg.value. It is how proxies and external libraries work, and it is dangerous when the target is untrusted.
new Child(args) deploys a contract from a contract using CREATE; adding {salt: s} uses CREATE2, which makes the address predictable from the factory, salt and code. Factory contracts use this to deploy many instances.